예제 #1
0
 @Override
 public boolean visit(MethodInvocation node) {
   List<IVariableBinding> path = OuterReferenceResolver.getPath(node);
   if (path != null) {
     node.setExpression(Name.newName(fixPath(path)));
   }
   return true;
 }
예제 #2
0
 @Override
 public boolean visit(ThisExpression node) {
   List<IVariableBinding> path = OuterReferenceResolver.getPath(node);
   if (path != null) {
     node.replaceWith(Name.newName(fixPath(path)));
   } else {
     node.setQualifier(null);
   }
   return true;
 }
예제 #3
0
 @Override
 public void endVisit(SuperMethodInvocation node) {
   List<IVariableBinding> path = OuterReferenceResolver.getPath(node);
   if (path != null) {
     // We substitute the qualifying type name with the outer variable name.
     node.setQualifier(Name.newName(fixPath(path)));
   } else {
     node.setQualifier(null);
   }
 }
예제 #4
0
 @Override
 public boolean visit(SimpleName node) {
   List<IVariableBinding> path = OuterReferenceResolver.getPath(node);
   if (path != null) {
     if (path.size() == 1 && path.get(0).getConstantValue() != null) {
       IVariableBinding var = path.get(0);
       node.replaceWith(TreeUtil.newLiteral(var.getConstantValue()));
     } else {
       node.replaceWith(Name.newName(fixPath(path)));
     }
   }
   return true;
 }
예제 #5
0
  private void addOuterArg(
      ClassInstanceCreation node, GeneratedMethodBinding binding, ITypeBinding declaringClass) {
    ITypeBinding type = node.getTypeBinding().getTypeDeclaration();
    if (!OuterReferenceResolver.needsOuterParam(type)) {
      return;
    }

    Expression outerExpr = node.getExpression();
    List<IVariableBinding> path = OuterReferenceResolver.getPath(node);
    Expression outerArg = null;

    if (outerExpr != null) {
      node.setExpression(null);
      outerArg = outerExpr;
    } else if (path != null) {
      outerArg = Name.newName(fixPath(path));
    } else {
      outerArg = new ThisExpression(declaringClass);
    }

    node.getArguments().add(0, outerArg);
    binding.addParameter(0, declaringClass);
  }