Examples of MethodControlFlowGraph


Examples of ai.cfg.MethodControlFlowGraph

  @Test
  public void testEmptyMethod() throws CoreException{
    ProjectFile pf = project.openFile("cfg", "MethodNames.java");
    //top level methods
    MethodControlFlowGraph cfg = pf.getCFG("MethodNames", "topLevelMethod");
    org.junit.Assert.assertEquals(cfg.getCodeFragment().getUniqueName(), "cfg.MethodNames:topLevelMethod()");

    cfg = pf.getCFG("MethodNames", "anotherTopLevelMethod");
    org.junit.Assert.assertEquals(cfg.getCodeFragment().getUniqueName(), "cfg.MethodNames:anotherTopLevelMethod()");

    //inner class methods
    cfg = pf.getCFG("MethodNames$InnerClass", "innerClassMethod");
    org.junit.Assert.assertEquals(cfg.getCodeFragment().getUniqueName(), "cfg.MethodNames$InnerClass:innerClassMethod()");
   
    cfg = pf.getCFG("MethodNames$InnerClass", "anotherInnerClassMethod");
    org.junit.Assert.assertEquals(cfg.getCodeFragment().getUniqueName(), "cfg.MethodNames$InnerClass:anotherInnerClassMethod()");

    //top level anonymous methods
    cfg = pf.getCFG("MethodNames$1", "compareTo");
    org.junit.Assert.assertEquals(cfg.getCodeFragment().getUniqueName(), "cfg.MethodNames$1:compareTo(String)");
   
    //inner class anonymous
    cfg = pf.getCFG("MethodNames$InnerClass$1", "compareTo");
    org.junit.Assert.assertEquals(cfg.getCodeFragment().getUniqueName(), "cfg.MethodNames$InnerClass$1:compareTo(String)");
  }
View Full Code Here

Examples of ai.cfg.MethodControlFlowGraph

    TestCommentData.parseComments(project.getControlFlowGraph("cfg", "SimpleInstructions.java", "SimpleInstructions:statementIf"));
  }

  @Test
  public void testSimpleIfOnlyTrue() {
    MethodControlFlowGraph cfg = project.getControlFlowGraph("cfg", "SimpleInstructions.java", "SimpleInstructions:statementIfOnlyTrue");
    TestCommentData.parseComments(cfg);
    org.junit.Assert.assertEquals("Loop vertice found!!", Utils.findLoopVertices(cfg).size(), 0);
  }
View Full Code Here

Examples of ai.cfg.MethodControlFlowGraph

    org.junit.Assert.assertEquals("Loop vertice found!!", Utils.findLoopVertices(cfg).size(), 0);
  }

  @Test
  public void testSimpleIfOnlyFalse() {
    MethodControlFlowGraph cfg = project.getControlFlowGraph("cfg", "SimpleInstructions.java", "SimpleInstructions:statementIfOnlyFalse");
    TestCommentData.parseComments(cfg);
    org.junit.Assert.assertEquals("Loop vertice found!!", Utils.findLoopVertices(cfg).size(), 0);
  }
View Full Code Here

Examples of ai.cfg.MethodControlFlowGraph

  // --------------------------- DO-WHILE ------------------------------

  @Test
  public void testDoWhile() {
    MethodControlFlowGraph graph = project.getControlFlowGraph("cfg", "Loops.java", "Loops:statementDoWhile");
    TestCommentData.parseComments(graph);
  }
View Full Code Here

Examples of ai.cfg.MethodControlFlowGraph

  @Override
  public Map<ASTNode, Object> analyse(CompilationUnit cu) {
    System.gc(); // FIXME: trying to solve memory issues
    Map<ASTNode, AIAnalysisResult> result = new HashMap<ASTNode, AIAnalysisResult>();
    for (InterestingCodeFragment codeFragment: MethodFinder.findMethods(cu)) {
      MethodControlFlowGraph graph = buildGraph(codeFragment);
      if (graph == null)
        continue;
     
      Pair<Multimap<CFGVertice, ASTNode>, Multimap<CFGVertice, ASTNode>> mappings = graph.getVerticeMappings();
      Map<CFGVertice, ASTNode> loopVerticesMap = graph.getLoopVerticesMapping();
     
      for(Map.Entry<String, AbstractSemanticsIntf<?>> entry: semanticsToApply.entrySet()) {       
        Map<CFGVertice, ?> results = ExecutionUtils.analyseOne(graph, entry.getValue(), aeh, codeFragment, timeoutSeconds);
        if (results == null) {
          results = new HashMap<CFGVertice, Object>();
          for(CFGVertice vertice: graph.getVertices())
            results.put(vertice, null);
        }
        analyseResult(entry.getKey(), results, mappings, result, loopVerticesMap);
      }
    }
View Full Code Here

Examples of ai.cfg.MethodControlFlowGraph

    int count = 0;
    for (InterestingCodeFragment codeFragment: MethodFinder.findMethods(cu)) {
      if (Prefs.ONLY_METHOD != null && !codeFragment.getUniqueName().equals(Prefs.ONLY_METHOD))
        continue;
      // build graph
      MethodControlFlowGraph graph;
      try {
        graph = MethodCFGBuilder.buildCFG(codeFragment);
      } catch (RuntimeException e) {
        System.err.println("Error building graph for:" + codeFragment.getUniqueName());
        e.printStackTrace(System.err);
View Full Code Here

Examples of ai.cfg.MethodControlFlowGraph

//    List<MethodControlFlowGraph> result = new LinkedList<MethodControlFlowGraph>();
    int count = 0;
    for(InterestingCodeFragment codeFragment: MethodFinder.findMethods(cu)){
      if (Prefs.ONLY_METHOD != null && !codeFragment.getUniqueName().equals(Prefs.ONLY_METHOD))
        continue;
      MethodControlFlowGraph graph;
      try {
        graph = MethodCFGBuilder.buildCFG(codeFragment);
      } catch (RuntimeException e) {
        System.err.println("Error parsing method:" + codeFragment.getUniqueName());
        e.printStackTrace(System.err);
View Full Code Here

Examples of ai.cfg.MethodControlFlowGraph

    int count = 0;
    for(InterestingCodeFragment codeFragment: MethodFinder.findMethods(cu)){
      if (Prefs.ONLY_METHOD != null && !codeFragment.getUniqueName().equals(Prefs.ONLY_METHOD))
        continue;
      //build graph
      MethodControlFlowGraph graph;
      try {
         graph = MethodCFGBuilder.buildCFG(codeFragment);
      } catch (RuntimeException e) {
        System.err.println("Error building graph for:" + codeFragment.getUniqueName());
        e.printStackTrace(System.err);
View Full Code Here

Examples of ai.cfg.MethodControlFlowGraph

  @Test
  public void testNumericArgument() throws CoreException{
    Logger logger = Logger.getRootLogger();
    logger.setLevel(Level.DEBUG);
   
    MethodControlFlowGraph cfg = project.getControlFlowGraph("domain.intervals", "Basics.java", "Basics:numericArgument");
    performTest(cfg);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.