com.sun.source.tree.MemberReferenceTree Java Examples

The following examples show how to use com.sun.source.tree.MemberReferenceTree. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModelBuilder.java    From vertx-codetrans with Apache License 2.0 6 votes vote down vote up
@Override
public CodeModel visitMemberReference(MemberReferenceTree node, VisitContext p) {
  if (node.getMode() == MemberReferenceTree.ReferenceMode.INVOKE) {
    JCTree.JCMemberReference refTree = (JCTree.JCMemberReference) node;
    ExecutableElement method = (ExecutableElement) refTree.sym;
    MethodSignature signature = createMethodSignature(method, false);
    ExpressionModel expression = scan(node.getQualifierExpression(), p);
    if (expression instanceof ThisModel) {
      p.getReferencedMethods().add(node.getName().toString());
    }
    ExpressionModel methodReferenceExpression = expression.onMethodReference(signature);
    return methodReferenceExpression;
  } else {
    throw new UnsupportedOperationException("New reference not implemented yet");
  }
}
 
Example #2
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 6 votes vote down vote up
@Override
public Void visitMemberReference(MemberReferenceTree node, Void unused) {
  sync(node);
  builder.open(plusFour);
  scan(node.getQualifierExpression(), null);
  builder.breakOp();
  builder.op("::");
  addTypeArguments(node.getTypeArguments(), plusFour);
  switch (node.getMode()) {
    case INVOKE:
      visit(node.getName());
      break;
    case NEW:
      token("new");
      break;
    default:
      throw new AssertionError(node.getMode());
  }
  builder.close();
  return null;
}
 
Example #3
Source File: CopyFinder.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean visitMemberReference(MemberReferenceTree node, TreePath p) {
    if (p == null)
        return super.visitMemberReference(node, p);

    MemberReferenceTree t = (MemberReferenceTree) p.getLeaf();
    
    if (!node.getMode().equals(t.getMode()))
        return false;

    if (!scan(node.getQualifierExpression(), t.getQualifierExpression(), p))
        return false;

    String ident = t.getName().toString();

    if (ident.startsWith("$")) { //XXX: there should be a utility method for this check
        if (bindState.variables2Names.containsKey(ident)) {
            return node.getName().contentEquals(bindState.variables2Names.get(ident));
        } else {
            bindState.variables2Names.put(ident, node.getName().toString());
        }
        return true;
    }

    return node.getName().contentEquals(t.getName());
}
 
Example #4
Source File: FindLocalUsagesQuery.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Void visitMemberReference(MemberReferenceTree node, Void p) {
    Element el = info.getTrees().getElement(getCurrentPath());
    if (toFind.equals(el)) {
        try {
            int[] span = treeUtils.findNameSpan(node);
            if(span != null) {
                MutablePositionRegion region = createRegion(doc, span[0], span[1]);
                usages.add(region);
            }
        } catch (BadLocationException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    return super.visitMemberReference(node, p);
}
 
Example #5
Source File: Kinds.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
    switch (mode) {
        case INVOKE: return KindName.METHOD;
        case NEW: return KindName.CONSTRUCTOR;
        default : throw new AssertionError("Unexpected mode: "+ mode);
    }
}
 
Example #6
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMethodReferenceDiff() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = hierbas.del.litoral.Test :: taragui;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test :: taragui;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                    workingCopy.rewrite(node, make.MemberReference(node.getMode(), make.Identifier("Test"), node.getName(), node.getTypeArguments()));
                    return super.visitMemberReference(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    System.err.println(res);
    assertEquals(golden, res);
}
 
Example #7
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMethodReferenceNameDiff() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test :: taragui;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test :: taragui2;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                    workingCopy.rewrite(node, make.setLabel(node, "taragui2"));
                    return super.visitMemberReference(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    System.err.println(res);
    assertEquals(golden, res);
}
 
Example #8
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMethodReferenceFirstTypeParam() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::taragui;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::<String>taragui;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                    workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), Collections.singletonList(make.Identifier("String"))));
                    return super.visitMemberReference(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    System.err.println(res);
    assertEquals(golden, res);
}
 
Example #9
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMethodReferenceLastTypeParam() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::<String>taragui;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::taragui;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                    workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), null));
                    return super.visitMemberReference(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    System.err.println(res);
    assertEquals(golden, res);
}
 
Example #10
Source File: NullabilityUtil.java    From NullAway with MIT License 5 votes vote down vote up
/**
 * finds the corresponding functional interface method for a lambda expression or method reference
 *
 * @param tree the lambda expression or method reference
 * @return the functional interface method
 */
public static Symbol.MethodSymbol getFunctionalInterfaceMethod(ExpressionTree tree, Types types) {
  Preconditions.checkArgument(
      (tree instanceof LambdaExpressionTree) || (tree instanceof MemberReferenceTree));
  Type funcInterfaceType = ((JCTree.JCFunctionalExpression) tree).type;
  return (Symbol.MethodSymbol) types.findDescriptorSymbol(funcInterfaceType.tsym);
}
 
Example #11
Source File: CompositeHandler.java    From NullAway with MIT License 5 votes vote down vote up
@Override
public void onMatchMethodReference(
    NullAway analysis,
    MemberReferenceTree tree,
    VisitorState state,
    Symbol.MethodSymbol methodSymbol) {
  for (Handler h : handlers) {
    h.onMatchMethodReference(analysis, tree, state, methodSymbol);
  }
}
 
Example #12
Source File: BaseNoOpHandler.java    From NullAway with MIT License 5 votes vote down vote up
@Override
public void onMatchMethodReference(
    NullAway analysis,
    MemberReferenceTree tree,
    VisitorState state,
    Symbol.MethodSymbol methodSymbol) {
  // NoOp
}
 
Example #13
Source File: NullAway.java    From NullAway with MIT License 5 votes vote down vote up
/**
 * for method references, we check that the referenced method correctly overrides the
 * corresponding functional interface method
 */
@Override
public Description matchMemberReference(MemberReferenceTree tree, VisitorState state) {
  if (!matchWithinClass) {
    return Description.NO_MATCH;
  }
  Symbol.MethodSymbol referencedMethod = ASTHelpers.getSymbol(tree);
  Symbol.MethodSymbol funcInterfaceSymbol =
      NullabilityUtil.getFunctionalInterfaceMethod(tree, state.getTypes());
  handler.onMatchMethodReference(this, tree, state, referencedMethod);
  return checkOverriding(funcInterfaceSymbol, referencedMethod, tree, state);
}
 
Example #14
Source File: Kinds.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
    switch (mode) {
        case INVOKE: return KindName.METHOD;
        case NEW: return KindName.CONSTRUCTOR;
        default : throw new AssertionError("Unexpected mode: "+ mode);
    }
}
 
Example #15
Source File: Kinds.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
    switch (mode) {
        case INVOKE: return KindName.METHOD;
        case NEW: return KindName.CONSTRUCTOR;
        default : throw new AssertionError("Unexpected mode: "+ mode);
    }
}
 
Example #16
Source File: Kinds.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
    switch (mode) {
        case INVOKE: return KindName.METHOD;
        case NEW: return KindName.CONSTRUCTOR;
        default : throw new AssertionError("Unexpected mode: "+ mode);
    }
}
 
Example #17
Source File: Kinds.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
    switch (mode) {
        case INVOKE: return KindName.METHOD;
        case NEW: return KindName.CONSTRUCTOR;
        default : throw new AssertionError("Unexpected mode: "+ mode);
    }
}
 
Example #18
Source File: Kinds.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
    switch (mode) {
        case INVOKE: return KindName.METHOD;
        case NEW: return KindName.CONSTRUCTOR;
        default : throw new AssertionError("Unexpected mode: "+ mode);
    }
}
 
Example #19
Source File: MemberReferenceScanner.java    From annotation-tools with MIT License 5 votes vote down vote up
@Override
public Void visitMemberReference(MemberReferenceTree node, Void p) {
  if (!done) {
    index++;
  }
  if (tree == node) {
    done = true;
  }
  return super.visitMemberReference(node, p);
}
 
Example #20
Source File: TreeConverter.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private TreeNode convertMethodReference(
    MemberReferenceTree node, TreePath parent, MethodReference newNode) {
  TreePath path = getTreePath(parent, node);
  convertFunctionalExpression((JCMemberReference) node, parent, newNode);
  if (node.getTypeArguments() != null) {
    for (ExpressionTree typeArg : node.getTypeArguments()) {
      newNode.addTypeArgument(Type.newType(((JCExpression) typeArg).type));
    }
  }
  return newNode
      .setExecutableElement((ExecutableElement) getElement(path))
      .setVarargsType(((JCMemberReference) node).varargsElement);
}
 
Example #21
Source File: TreeDiffer.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitMemberReference(MemberReferenceTree expected, Tree actual) {
  Optional<MemberReferenceTree> other = checkTypeAndCast(expected, actual);
  if (!other.isPresent()) {
    addTypeMismatch(expected, actual);
    return null;
  }

  scan(expected.getQualifierExpression(), other.get().getQualifierExpression());
  parallelScan(expected.getTypeArguments(), other.get().getTypeArguments());
  checkForDiff(expected.getName().contentEquals(other.get().getName()),
      "Expected identifier to be <%s> but was <%s>.",
      expected.getName(), other.get().getName());
  return null;
}
 
Example #22
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Token<JavaTokenId> findIdentifierSpanImpl(CompilationInfo info, MemberReferenceTree tree, CompilationUnitTree cu, SourcePositions positions) {
    int start = (int)positions.getStartPosition(cu, tree);
    int endPosition = (int)positions.getEndPosition(cu, tree);
    
    if (start == (-1) || endPosition == (-1))
        return null;

    String member = tree.getName().toString();

    TokenHierarchy<?> th = info.getTokenHierarchy();
    TokenSequence<JavaTokenId> ts = th.tokenSequence(JavaTokenId.language());

    if (ts.move(endPosition) == Integer.MAX_VALUE) {
        return null;
    }

    if (ts.moveNext()) {
        while (ts.offset() >= start) {
            Token<JavaTokenId> t = ts.token();

            if (t.id() == JavaTokenId.IDENTIFIER && member.equals(info.getTreeUtilities().decodeIdentifier(t.text()).toString())) {
                return t;
            }

            if (!ts.movePrevious())
                break;
        }
    }
    return null;
}
 
Example #23
Source File: Kinds.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
    switch (mode) {
        case INVOKE: return KindName.METHOD;
        case NEW: return KindName.CONSTRUCTOR;
        default : throw new AssertionError("Unexpected mode: "+ mode);
    }
}
 
Example #24
Source File: Kinds.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
    switch (mode) {
        case INVOKE: return KindName.METHOD;
        case NEW: return KindName.CONSTRUCTOR;
        default : throw new AssertionError("Unexpected mode: "+ mode);
    }
}
 
Example #25
Source File: Kinds.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
    switch (mode) {
        case INVOKE: return KindName.METHOD;
        case NEW: return KindName.CONSTRUCTOR;
        default : throw new AssertionError("Unexpected mode: "+ mode);
    }
}
 
Example #26
Source File: TreeDuplicator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Tree visitMemberReference(MemberReferenceTree tree, Void p) {
    MemberReferenceTree n = make.MemberReference(tree.getMode(), tree.getName(), tree.getQualifierExpression(), (List<ExpressionTree>)tree.getTypeArguments());
    model.setType(n, model.getType(tree));
    comments.copyComments(tree, n);
    model.setPos(n, model.getPos(tree));
    return n;
}
 
Example #27
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMethodReferenceDiff() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = hierbas.del.litoral.Test :: taragui;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test :: taragui;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                    workingCopy.rewrite(node, make.MemberReference(node.getMode(), make.Identifier("Test"), node.getName(), node.getTypeArguments()));
                    return super.visitMemberReference(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    //System.err.println(res);
    assertEquals(golden, res);
}
 
Example #28
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMethodReferenceNameDiff() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test :: taragui;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test :: taragui2;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                    workingCopy.rewrite(node, make.setLabel(node, "taragui2"));
                    return super.visitMemberReference(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    //System.err.println(res);
    assertEquals(golden, res);
}
 
Example #29
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMethodReferenceFirstTypeParam() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::taragui;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::<String>taragui;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                    workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), Collections.singletonList(make.Identifier("String"))));
                    return super.visitMemberReference(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    //System.err.println(res);
    assertEquals(golden, res);
}
 
Example #30
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMethodReferenceLastTypeParam() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::<String>taragui;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::taragui;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                    workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), null));
                    return super.visitMemberReference(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    //System.err.println(res);
    assertEquals(golden, res);
}