com.sun.source.tree.MemberSelectTree Java Examples

The following examples show how to use com.sun.source.tree.MemberSelectTree. 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: ReplaceBufferByString.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Object visitMemberSelect(MemberSelectTree node, Object p) {
    if (wc.getTrees().getElement(new TreePath(getCurrentPath(), node.getExpression())) != varElement) {
        return super.visitMemberSelect(node, p);
    }
    Element target = wc.getTrees().getElement(getCurrentPath());
    if (target != null && target.getKind() == ElementKind.METHOD) {
        Tree x = getCurrentPath().getParentPath().getLeaf();
        Tree.Kind k = x.getKind();
        if (k == Tree.Kind.METHOD_INVOCATION) {
            if (node.getIdentifier().contentEquals("toString")) { // NOI18N
                // rewrite the node to just the variable, which is going to change the type
                gu.copyComments(x, node.getExpression(), true);
                gu.copyComments(x, node.getExpression(), false);
                wc.rewrite(x, node.getExpression());
            }
        }
    }
    return super.visitMemberSelect(node, p);
}
 
Example #2
Source File: FindLocalUsagesQuery.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Void visitImport(ImportTree node, Void p) {
    if (node.isStatic() && toFind.getModifiers().contains(Modifier.STATIC)) {
        Tree qualIdent = node.getQualifiedIdentifier();
        if (qualIdent.getKind() == Kind.MEMBER_SELECT) {
            MemberSelectTree mst = (MemberSelectTree) qualIdent;
            if (toFind.getSimpleName().contentEquals(mst.getIdentifier())) {
                Element el = info.getTrees().getElement(new TreePath(getCurrentPath(), mst.getExpression()));
                if (el != null && el.equals(toFind.getEnclosingElement())) {
                    try {
                        int[] span = treeUtils.findNameSpan(mst);
                        if(span != null) {
                            MutablePositionRegion region = createRegion(doc, span[0], span[1]);
                            usages.add(region);
                        }
                    } catch (BadLocationException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }
            }
        }
    }
    return super.visitImport(node, p);
}
 
Example #3
Source File: XPFlagCleaner.java    From piranha with Apache License 2.0 6 votes vote down vote up
private API getXPAPI(ExpressionTree et) {
  et = ASTHelpers.stripParentheses(et);
  Kind k = et.getKind();
  if (k.equals(Tree.Kind.METHOD_INVOCATION)) {
    MethodInvocationTree mit = (MethodInvocationTree) et;
    if (!mit.getMethodSelect().getKind().equals(Kind.MEMBER_SELECT)) {
      return API.UNKNOWN;
    }
    MemberSelectTree mst = (MemberSelectTree) mit.getMethodSelect();
    String methodName = mst.getIdentifier().toString();
    if (!disabled && configMethodProperties.containsKey(methodName)) {
      return getXPAPI(mit, configMethodProperties.get(methodName));
    }
  }
  return API.UNKNOWN;
}
 
Example #4
Source File: FindLocalUsagesQuery.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Void visitImport(ImportTree node, Stack<Tree> p) {
    if (node.isStatic() && toFind.getModifiers().contains(Modifier.STATIC)) {
        Tree qualIdent = node.getQualifiedIdentifier();
        if (qualIdent.getKind() == Kind.MEMBER_SELECT) {
            MemberSelectTree mst = (MemberSelectTree) qualIdent;
            if (toFind.getSimpleName().contentEquals(mst.getIdentifier())) {
                Element el = info.getTrees().getElement(new TreePath(getCurrentPath(), mst.getExpression()));
                if (el != null && el.equals(toFind.getEnclosingElement())) {
                    Token<JavaTokenId> t = Utilities.getToken(info, doc, new TreePath(getCurrentPath(), mst));
                    if (t != null)
                        usages.add(t);
                }
            }
        }
    }
    return super.visitImport(node, p);
}
 
Example #5
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private void dotExpressionUpToArgs(ExpressionTree expression, Optional<BreakTag> tyargTag) {
    expression = getArrayBase(expression);
    switch (expression.getKind()) {
        case MEMBER_SELECT:
            MemberSelectTree fieldAccess = (MemberSelectTree) expression;
            visit(fieldAccess.getIdentifier());
            break;
        case METHOD_INVOCATION:
            MethodInvocationTree methodInvocation = (MethodInvocationTree) expression;
            if (!methodInvocation.getTypeArguments().isEmpty()) {
                builder.open(plusFour);
                addTypeArguments(methodInvocation.getTypeArguments(), ZERO);
                // TODO(jdd): Should indent the name -4.
                builder.breakOp(Doc.FillMode.UNIFIED, "", ZERO, tyargTag);
                builder.close();
            }
            visit(getMethodName(methodInvocation));
            break;
        case IDENTIFIER:
            visit(((IdentifierTree) expression).getName());
            break;
        default:
            scan(expression, null);
            break;
    }
}
 
Example #6
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method for import declarations, names, and qualified names.
 */
private void visitName(Tree node) {
    Deque<Name> stack = new ArrayDeque<>();
    for (; node instanceof MemberSelectTree; node = ((MemberSelectTree) node).getExpression()) {
        stack.addFirst(((MemberSelectTree) node).getIdentifier());
    }
    stack.addFirst(((IdentifierTree) node).getName());
    boolean first = true;
    for (Name name : stack) {
        if (!first) {
            token(".");
        }
        token(name.toString());
        first = false;
    }
}
 
Example #7
Source File: TreeUtilitiesTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testForEachLoop() throws Exception {
    prepareTest("Test", "package test; public class Test { public Test(java.util.List<String> ll) { for (String s : ll.subList(0, ll.size())  ) { } } }");

    TreePath tp1 = info.getTreeUtilities().pathFor(122 - 30);
    assertEquals(Kind.IDENTIFIER, tp1.getLeaf().getKind());
    assertEquals("ll", ((IdentifierTree) tp1.getLeaf()).getName().toString());

    TreePath tp2 = info.getTreeUtilities().pathFor(127 - 30);
    assertEquals(Kind.MEMBER_SELECT, tp2.getLeaf().getKind());
    assertEquals("subList", ((MemberSelectTree) tp2.getLeaf()).getIdentifier().toString());

    TreePath tp3 = info.getTreeUtilities().pathFor(140 - 30);
    assertEquals(Kind.MEMBER_SELECT, tp3.getLeaf().getKind());
    assertEquals("size", ((MemberSelectTree) tp3.getLeaf()).getIdentifier().toString());

    TreePath tp4 = info.getTreeUtilities().pathFor(146 - 30);
    assertEquals(Kind.METHOD_INVOCATION, tp4.getLeaf().getKind());
    assertEquals("subList", ((MemberSelectTree) ((MethodInvocationTree) tp4.getLeaf()).getMethodSelect()).getIdentifier().toString());
}
 
Example #8
Source File: Imports.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Hint(displayName = "#DN_Imports_EXCLUDED", description = "#DESC_Imports_EXCLUDED", category="imports", id="Imports_EXCLUDED", options=Options.QUERY)
@TriggerTreeKind(Kind.IMPORT)
public static ErrorDescription exlucded(HintContext ctx) throws IOException {
    ImportTree it = (ImportTree) ctx.getPath().getLeaf();

    if (it.isStatic() || !(it.getQualifiedIdentifier() instanceof MemberSelectTree)) {
        return null; // XXX
    }

    MemberSelectTree ms = (MemberSelectTree) it.getQualifiedIdentifier();
    String pkg = ms.getExpression().toString();
    String klass = ms.getIdentifier().toString();
    String exp = pkg + "." + (!klass.equals("*") ? klass : ""); //NOI18N
    if (Utilities.isExcluded(exp)) {
        return ErrorDescriptionFactory.forTree(ctx, ctx.getPath(), NbBundle.getMessage(Imports.class, "DN_Imports_EXCLUDED"));
    }

    return null;
}
 
Example #9
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 6 votes vote down vote up
private void dotExpressionUpToArgs(ExpressionTree expression, Optional<BreakTag> tyargTag) {
  expression = getArrayBase(expression);
  switch (expression.getKind()) {
    case MEMBER_SELECT:
      MemberSelectTree fieldAccess = (MemberSelectTree) expression;
      visit(fieldAccess.getIdentifier());
      break;
    case METHOD_INVOCATION:
      MethodInvocationTree methodInvocation = (MethodInvocationTree) expression;
      if (!methodInvocation.getTypeArguments().isEmpty()) {
        builder.open(plusFour);
        addTypeArguments(methodInvocation.getTypeArguments(), ZERO);
        // TODO(jdd): Should indent the name -4.
        builder.breakOp(Doc.FillMode.UNIFIED, "", ZERO, tyargTag);
        builder.close();
      }
      visit(getMethodName(methodInvocation));
      break;
    case IDENTIFIER:
      visit(((IdentifierTree) expression).getName());
      break;
    default:
      scan(expression, null);
      break;
  }
}
 
Example #10
Source File: InstanceRefFinder.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Object visitMemberSelect(MemberSelectTree node, Object p) {
    String exp = node.getExpression().toString();
    // ClassName.this
    if (exp.equals("this") || exp.endsWith(".this")) { // NOI18N
        addInstanceForType(findType(node.getExpression()));
    } else if (exp.equals("super")) { // NOI18N
        // reference to superclass of this type
        addSuperInstance(enclosingType);
    } else if (exp.endsWith(".super")) { // NOI18N
        // this is a reference to the superclass of some enclosing type.
        if (node.getExpression().getKind() == Tree.Kind.MEMBER_SELECT) {
            Tree t = ((MemberSelectTree)node.getExpression()).getExpression();
            addSuperInstance(findType(t));
        }
    } else if (node.getIdentifier().contentEquals("this")) { // NOI18N
        // reference to this
        addInstanceForType(findType(node.getExpression()));
    } else {
        // references to Clazz.super are invalid, references to Clazz.super.whatever() must be
        // a pert of a broader memberSelect, which will be caught one level up.
        return super.visitMemberSelect(node, p);
    }
    return null;
}
 
Example #11
Source File: ScopeTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void verifyLambdaScopeCorrect(final String packageClause) throws Exception {
    JavacTool tool = JavacTool.create();
    JavaFileObject source = new SimpleJavaFileObject(URI.create("mem://Test.java"), Kind.SOURCE) {
        @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
            return packageClause + SOURCE_CODE;
        }
        @Override public boolean isNameCompatible(String simpleName, Kind kind) {
            return true;
        }
    };
    Iterable<? extends JavaFileObject> fos = Collections.singletonList(source);
    JavacTask task = tool.getTask(null, null, null, new ArrayList<String>(), null, fos);
    final Types types = JavacTypes.instance(((JavacTaskImpl) task).getContext());
    final Trees trees = Trees.instance(task);
    CompilationUnitTree cu = task.parse().iterator().next();

    task.analyze();

    new TreePathScanner<Void, Void>() {
        @Override public Void visitMemberSelect(MemberSelectTree node, Void p) {
            if (node.getIdentifier().contentEquals("correct")) {
                TypeMirror xType = trees.getTypeMirror(new TreePath(getCurrentPath(), node.getExpression()));
                Scope scope = trees.getScope(getCurrentPath());
                for (Element l : scope.getLocalElements()) {
                    if (!l.getSimpleName().contentEquals("x")) continue;
                    if (!types.isSameType(xType, l.asType())) {
                        throw new IllegalStateException("Incorrect variable type in scope: " + l.asType() + "; should be: " + xType);
                    }
                }
            }
            return super.visitMemberSelect(node, p);
        }
    }.scan(cu, null);
}
 
Example #12
Source File: BreadCrumbsNodeImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static String simpleName(Tree t) {
    switch (t.getKind()) {
        case PARAMETERIZED_TYPE:
            return simpleName(((ParameterizedTypeTree) t).getType());
        case IDENTIFIER:
            return ((IdentifierTree) t).getName().toString();
        case MEMBER_SELECT:
            return ((MemberSelectTree) t).getIdentifier().toString();
        default:
            return "";//XXX
    }
}
 
Example #13
Source File: JavaRefactoringUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Tree visitMemberSelect(MemberSelectTree node, ElementHandle p) {
    assert cc != null;
    Element e = p.resolve(cc);
    addIfMatch(getCurrentPath(), node, e);
    return super.visitMemberSelect(node, p);
}
 
Example #14
Source File: Attr.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Symbol visitMemberSelect(MemberSelectTree node, Env<AttrContext> env) {
    Symbol site = visit(node.getExpression(), env);
    if (site.kind == ERR)
        return site;
    Name name = (Name)node.getIdentifier();
    if (site.kind == PCK) {
        env.toplevel.packge = (PackageSymbol)site;
        return rs.findIdentInPackage(env, (TypeSymbol)site, name, TYP | PCK);
    } else {
        env.enclClass.sym = (ClassSymbol)site;
        return rs.findMemberType(env, site.asType(), name, (TypeSymbol)site);
    }
}
 
Example #15
Source File: TreePathScannerForTypeResolution.java    From buck with Apache License 2.0 5 votes vote down vote up
@Nullable
protected final R resolveEnclosingElement(P p) {
  Tree leaf = getCurrentPath().getLeaf();
  if (leaf.getKind() == Kind.MEMBER_SELECT) {
    MemberSelectTree memberSelect = (MemberSelectTree) leaf;
    return super.visitMemberSelect(memberSelect, p);
  } else {
    return null;
  }
}
 
Example #16
Source File: SuspiciousNamesCombination.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static String getName(ExpressionTree et) {
    if (et == null)
        return null;
    
    switch (et.getKind()) {
        case IDENTIFIER:
            return ((IdentifierTree) et).getName().toString();
        case METHOD_INVOCATION:
            return getName(((MethodInvocationTree) et).getMethodSelect());
        case MEMBER_SELECT:
            return ((MemberSelectTree) et).getIdentifier().toString();
        default:
            return null;
    }
}
 
Example #17
Source File: Unbalanced.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@TriggerTreeKind({Kind.IDENTIFIER, Kind.MEMBER_SELECT})
@TriggerOptions(TriggerOptions.PROCESS_GUARDED)
public static ErrorDescription before(HintContext ctx) {
    TreePath tp = ctx.getPath();
    VariableElement var = testElement(ctx);

    if (var == null) return null;

    if (tp.getParentPath().getLeaf().getKind() == Kind.MEMBER_SELECT && tp.getParentPath().getParentPath().getLeaf().getKind() == Kind.METHOD_INVOCATION) {
        String methodName = ((MemberSelectTree) tp.getParentPath().getLeaf()).getIdentifier().toString();
        if (READ_METHODS.contains(methodName)) {
            if (tp.getParentPath().getParentPath().getParentPath().getLeaf().getKind() != Kind.EXPRESSION_STATEMENT) {
                record(ctx.getInfo(), var, State.READ);
            }
            return null;
        } else if (WRITE_METHODS.contains(methodName)) {
            if (tp.getParentPath().getParentPath().getParentPath().getLeaf().getKind() != Kind.EXPRESSION_STATEMENT) {
                record(ctx.getInfo(), var, State.WRITE, State.READ);
            } else {
                record(ctx.getInfo(), var, State.WRITE);
            }
            return null;
        }
    }

    record(ctx.getInfo(), var, State.WRITE, State.READ);

    return null;
}
 
Example #18
Source File: CreateElementUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static List<? extends TypeMirror> computeMemberSelect(Set<ElementKind> types, CompilationInfo info, TreePath parent, Tree error, int offset) {
    //class or field:
    MemberSelectTree ms = (MemberSelectTree) parent.getLeaf();
    final TypeElement jlObject = info.getElements().getTypeElement("java.lang.Object");
    
    if (jlObject != null) { //may happen if the platform is broken
        if (!"class".equals(ms.getIdentifier().toString())) {
            types.add(ElementKind.FIELD);
            types.add(ElementKind.CLASS);
            return Collections.singletonList(jlObject.asType());
        } else {
            List<? extends TypeMirror> targetTypes = resolveType(new HashSet<ElementKind>(), info, parent.getParentPath(), ms, offset, null, null);
            boolean alreadyAddedObject = false;
            List<TypeMirror> resolvedTargetTypes = new ArrayList<>();
            if (targetTypes == null || targetTypes.isEmpty()) {
                resolvedTargetTypes.add(jlObject.asType());
            } else {
                for (TypeMirror tm : targetTypes) {
                    if (   tm != null
                        && tm.getKind() == TypeKind.DECLARED
                        && ((TypeElement) info.getTypes().asElement(tm)).getQualifiedName().contentEquals("java.lang.Class")
                        && ((DeclaredType) tm).getTypeArguments().size() == 1) {
                        resolvedTargetTypes.add(((DeclaredType) tm).getTypeArguments().get(0));
                        continue;
                    }
                    if (!alreadyAddedObject) {
                        alreadyAddedObject = true;
                        resolvedTargetTypes.add(jlObject.asType());
                    }
                }
            }
            types.add(ElementKind.CLASS);
            return resolvedTargetTypes;
        }
    }
    
    return null;
}
 
Example #19
Source File: JavaFixAllImports.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Object visitImport(ImportTree node, Object d) {
    if (node.getQualifiedIdentifier().getKind() == Kind.MEMBER_SELECT) {
        ExpressionTree exp = ((MemberSelectTree) node.getQualifiedIdentifier()).getExpression();
        if (exp.toString().equals(currentPackage)) {
            imports.add(TreePathHandle.create(getCurrentPath(), info));
        }
    }

    super.visitImport(node, null);
    return null;
}
 
Example #20
Source File: TreeConverter.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private static String getMemberName(ExpressionTree node) {
  switch (node.getKind()) {
    case IDENTIFIER:
      return node.toString();
    case MEMBER_SELECT:
      return ((MemberSelectTree) node).getIdentifier().toString();
    default:
      return null;
  }
}
 
Example #21
Source File: ConvertToLambdaPreconditionChecker.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private ExpressionTree getSelector(Tree tree) {
    switch (tree.getKind()) {
        case MEMBER_SELECT:
            return ((MemberSelectTree) tree).getExpression();
        case METHOD_INVOCATION:
            return getSelector(((MethodInvocationTree) tree).getMethodSelect());
        case NEW_CLASS:
            return getSelector(((NewClassTree) tree).getIdentifier());
        default:
            return null;
    }
}
 
Example #22
Source File: LeakingThisInConstructor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@TriggerPattern(value="$v=$this") // NOI18N
public static ErrorDescription hintOnAssignment(HintContext ctx) {
    Map<String,TreePath> variables = ctx.getVariables ();
    TreePath thisPath = variables.get ("$this"); // NOI18N
    if (   thisPath.getLeaf().getKind() != Kind.IDENTIFIER
        || !((IdentifierTree) thisPath.getLeaf()).getName().contentEquals(THIS_KEYWORD)) {
        return null;
    }
    if (!Utilities.isInConstructor(ctx)) {
        return null;
    }
    TreePath storePath = variables.get("$v");
    Tree t = storePath.getLeaf();
    if (t.getKind() == Tree.Kind.MEMBER_SELECT) {
        t = ((MemberSelectTree)t).getExpression();
        while (t != null && t.getKind() == Tree.Kind.PARENTHESIZED) {
            t = ((ParenthesizedTree)t).getExpression();
        }
        if (t == null) {
            return null;
        } else if (t.getKind() == Tree.Kind.IDENTIFIER) {
            IdentifierTree it = (IdentifierTree)t;
            if (it.getName().contentEquals(THIS_KEYWORD) ||
                it.getName().contentEquals(SUPER_KEYWORD)) {
                return null;
            }
        }
    } else {
        return null;
    }
    return ErrorDescriptionFactory.forName(ctx, ctx.getPath(),
            NbBundle.getMessage(
                LeakingThisInConstructor.class,
                "MSG_org.netbeans.modules.java.hints.LeakingThisInConstructor"));
}
 
Example #23
Source File: DoubleCheck.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Object visitMemberSelect(MemberSelectTree node, Object p) {
    if (ifEncountered) {
        // inside the inner if-statement, all but assignments should transform to local variable references.
        Element el = wc.getTrees().getElement(getCurrentPath());
        if (el == originalVariable) {
            // rewrite the member select to whatever tree access is necessary
            wc.rewrite(node, localVarTree);
            // skip the member select
            return null;
        }
    }
    return super.visitMemberSelect(node, p);
}
 
Example #24
Source File: UnusedImports.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isStar(ImportTree tree) {
    Tree qualIdent = tree.getQualifiedIdentifier();
    
    if (qualIdent == null || qualIdent.getKind() == Kind.IDENTIFIER) {
        return false;
    }
    
    return ((MemberSelectTree) qualIdent).getIdentifier().contentEquals("*");
}
 
Example #25
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static boolean isNonCtorKeyword(Tree tree) {
    if (tree.getKind() == Kind.IDENTIFIER) {
        return nonCtorKeywords.contains(((IdentifierTree) tree).getName().toString());
    }
    if (tree.getKind() == Kind.MEMBER_SELECT) {
        return nonCtorKeywords.contains(((MemberSelectTree) tree).getIdentifier().toString());
    }

    return false;
}
 
Example #26
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static boolean isKeyword(Tree tree) {
    if (tree.getKind() == Kind.IDENTIFIER) {
        return keywords.contains(((IdentifierTree) tree).getName().toString());
    }
    if (tree.getKind() == Kind.MEMBER_SELECT) {
        return keywords.contains(((MemberSelectTree) tree).getIdentifier().toString());
    }
    
    return false;
}
 
Example #27
Source File: JavacJ2ObjCIncompatibleStripper.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private String getLastComponent(Tree name) {
  switch (name.getKind()) {
    case IDENTIFIER:
      return ((IdentifierTree) name).getName().toString();
    case MEMBER_SELECT:
      return ((MemberSelectTree) name).getIdentifier().toString();
    default:
      return "";
  }
}
 
Example #28
Source File: StreamNullabilityPropagator.java    From NullAway with MIT License 5 votes vote down vote up
private void buildObservableCallChain(MethodInvocationTree tree) {
  ExpressionTree methodSelect = tree.getMethodSelect();
  if (methodSelect instanceof MemberSelectTree) {
    ExpressionTree receiverExpression = ((MemberSelectTree) methodSelect).getExpression();
    if (receiverExpression instanceof MethodInvocationTree) {
      observableOuterCallInChain.put((MethodInvocationTree) receiverExpression, tree);
    }
  } // ToDo: What else can be here? If there are other cases than MemberSelectTree, handle them.
}
 
Example #29
Source File: LabelsTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Void visitMemberSelect(MemberSelectTree node, Object p) {
    System.err.println("visitMemberSelect: " + node.getIdentifier());
    super.visitMemberSelect(node, p);
    MemberSelectTree copy = make.setLabel(node, node.getIdentifier() + "0");
    this.copy.rewrite(node, copy);
    return null;
}
 
Example #30
Source File: SemanticHighlighterBase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitMemberSelect(MemberSelectTree tree, Void p) {
    if (info.getTreeUtilities().isSynthetic(getCurrentPath()))
        return null;

    long memberSelectBypassLoc = memberSelectBypass;
    
    memberSelectBypass = -1;
    
    Element el = info.getTrees().getElement(getCurrentPath());
    
    if (el != null && el.getKind() == ElementKind.MODULE) {
        //Xxx
        handlePossibleIdentifier(getCurrentPath(), false);
        tl.moduleNameHere(tree, tree2Tokens);
        return null;
    }

    super.visitMemberSelect(tree, p);
    
    tl.moveToEnd(tree.getExpression());
    
    if (memberSelectBypassLoc != (-1)) {
        tl.moveToOffset(memberSelectBypassLoc);
    }
    
    handlePossibleIdentifier(getCurrentPath(), false);
    firstIdentifier(tree.getIdentifier().toString());
    addParameterInlineHint(tree);
    return null;
}