Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.MethodDeclaration


    "}";
 
  @Test
  public void testReadThis() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("ThisRead", THIS_READ);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    FieldAccess read = (FieldAccess) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
View Full Code Here


    "}";
 
  @Test
  public void testObjectRead() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("ObjectRead", OBJECT_READ);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Expression read = (Expression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
    Assert.assertEquals(
        tac.sourceVariable(((SingleVariableDeclaration) m.parameters().get(0)).resolveBinding()),
        load.getSourceObject());
    Assert.assertEquals("f", load.getFieldName());
  }
View Full Code Here

    "}";
 
  @Test
  public void testFieldWrite() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldWrite", FIELD_WRITE);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Assignment write = (Assignment) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(write);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof StoreFieldInstruction);
   
    StoreFieldInstruction store = (StoreFieldInstruction) instr;
    Assert.assertTrue(store.getDestinationObject() instanceof ThisVariable);
    Assert.assertTrue(store.getDestinationObject().isUnqualifiedThis());
    Assert.assertEquals(
        tac.sourceVariable(((SingleVariableDeclaration) m.parameters().get(0)).resolveBinding()),
        store.getSourceOperand());
    Assert.assertEquals("f", store.getFieldName());
   
    Assert.assertEquals(tac.variable(write.getRightHandSide()), store.getSourceOperand());
   
View Full Code Here

    "}";
 
  @Test
  public void testFieldInc() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldInc", FIELD_INC);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    PostfixExpression inc = (PostfixExpression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(inc);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof EclipseInstructionSequence);
    LoadFieldInstruction load = (LoadFieldInstruction) tac.instruction(inc.getOperand());
View Full Code Here

    "}";
 
  @Test
  public void testNestedFieldWrite() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("NestedFieldWrite", NESTED_FIELD_WRITE);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation inv = (MethodInvocation) ((ExpressionStatement) EclipseTACSimpleTestDriver.getLastStatement(m)).getExpression();
    TACInstruction instr = tac.instruction(inv);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
View Full Code Here

    "}";
 
  @Test
  public void testPrivateOuterField() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("PrivateOuterField", PRIVATE_OUTER_FIELD);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu); // method in inner class
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Expression read = (Expression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
View Full Code Here

    "}";
 
  @Test
  public void testVisibleOuterField() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("VisibleOuterField", VISIBLE_OUTER_FIELD);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu); // method in inner class
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Expression read = (Expression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
View Full Code Here

 
  public IResult<LE> getLabeledResultsAfter(ASTNode node) {
    /*
     * TODO: Need a find a way to get rid of this call...
     */
    MethodDeclaration decl = Utilities.getMethodDeclaration(node);
   
    if( decl!= null && this.analyzedMethods.containsKey(decl) ) {
      try {
        return this.analyzedMethods.get(decl).get().getLabeledResultsAfter(node);
      } catch (Exception e) {/* Do nothing, let fall through to default. */ }
View Full Code Here

    }
    return addAsFakeFuture(decl,defaultFlowAnalysis).getLabeledResultsAfter(node);
  }

  public IResult<LE> getLabeledResultsBefore(ASTNode node) {
    MethodDeclaration decl = Utilities.getMethodDeclaration(node);
   
    if( decl!= null && this.analyzedMethods.containsKey(decl) ) {
      try {
        return this.analyzedMethods.get(decl).get().getLabeledResultsBefore(node);
      } catch (Exception e) {/* Do nothing, let fall through to default. */ }
View Full Code Here

  public LE getResultsBefore(ASTNode node) {
    return getResultsBeforeCFG(node);
  }

  public LE getResultsAfterCFG(ASTNode node) {
    MethodDeclaration decl = Utilities.getMethodDeclaration(node);
   
    if( decl!= null && this.analyzedMethods.containsKey(decl) ) {
      try {
        return this.analyzedMethods.get(decl).get().getResultsAfterCFG(node);
      } catch (Exception e) {/* Do nothing, let fall through to default. */ }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.MethodDeclaration

Copyright © 2018 www.massapicom. 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.