当前位置: 首页>>代码示例>>Java>>正文


Java MemberSelectTree类代码示例

本文整理汇总了Java中com.sun.source.tree.MemberSelectTree的典型用法代码示例。如果您正苦于以下问题:Java MemberSelectTree类的具体用法?Java MemberSelectTree怎么用?Java MemberSelectTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MemberSelectTree类属于com.sun.source.tree包,在下文中一共展示了MemberSelectTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deepVerifyIdentifier2MemberSelect

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
private boolean deepVerifyIdentifier2MemberSelect(TreePath identifier, TreePath memberSelect) {
    for (TreePath thisPath : prepareThis(identifier)) {
        State origState = State.copyOf(bindState);
        try {
            MemberSelectTree t = (MemberSelectTree) memberSelect.getLeaf();

            if (scan(thisPath.getLeaf(), t.getExpression(), memberSelect) == Boolean.TRUE) {
                return true;
            }
        } finally {
            bindState = origState;
        }
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CopyFinder.java

示例2: visitImport

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:FindLocalUsagesQuery.java

示例3: visitMemberSelect

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@Override
public Void visitMemberSelect(MemberSelectTree 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.visitMemberSelect(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:FindLocalUsagesQuery.java

示例4: visitImport

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:FindLocalUsagesQuery.java

示例5: visitMemberSelect

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@Override
public Void visitMemberSelect(MemberSelectTree node, Void p) {
    int s = (int) wc.getTrees().getSourcePositions().getStartPosition(wc.getCompilationUnit(), node);
    int e = (int) wc.getTrees().getSourcePositions().getEndPosition(wc.getCompilationUnit(), node);

    if (s >= start && e <= end) {
        Element el = wc.getTrees().getElement(getCurrentPath());

        if (el != null && (el.getKind().isClass() || el.getKind().isInterface()) && ((TypeElement) el).asType().getKind() != TypeKind.ERROR) {
            wc.rewrite(node, wc.getTreeMaker().QualIdent(el));
            return null;
        }
    }

    return super.visitMemberSelect(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:AddPropertyCodeGenerator.java

示例6: exlucded

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Imports.java

示例7: performRewrite

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@Override
protected void performRewrite(JavaFix.TransformationContext ctx) throws Exception {
    Tree t = ctx.getPath().getLeaf();
    if (t.getKind() != Tree.Kind.METHOD_INVOCATION) {
        return;
    }
    MethodInvocationTree mi = (MethodInvocationTree)t;
    if (mi.getMethodSelect().getKind() != Tree.Kind.MEMBER_SELECT) {
        return;
    }
    MemberSelectTree selector = ((MemberSelectTree)mi.getMethodSelect());
    TreeMaker maker = ctx.getWorkingCopy().getTreeMaker();
    ExpressionTree ms = maker.MemberSelect(maker.QualIdent("java.util.Arrays"), deep ? "deepHashCode" : "hashCode"); // NOI18N
    Tree nue = maker.MethodInvocation(
                    Collections.<ExpressionTree>emptyList(), 
                    ms, 
                    Collections.singletonList(selector.getExpression())
    );
    ctx.getWorkingCopy().rewrite(t, nue);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Tiny.java

示例8: visitMemberSelect

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ReplaceBufferByString.java

示例9: visitMethodInvocation

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    if (!node.getArguments().isEmpty()) {
        return null;
    }
    final ExpressionTree et = node.getMethodSelect();
    if (et.getKind() != Tree.Kind.MEMBER_SELECT) {
        return null;
    }
    final MemberSelectTree mst = (MemberSelectTree) et;
    if (!FINALIZE.contentEquals(mst.getIdentifier())) {
        return null;
    }
    if (mst.getExpression().getKind() != Tree.Kind.IDENTIFIER) {
        return null;
    }
    if (!SUPER.contentEquals(((IdentifierTree)mst.getExpression()).getName())) {
        return null;
    }
    found = true;
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FinalizeDoesNotCallSuper.java

示例10: visitMemberSelect

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:InstanceRefFinder.java

示例11: visitMethodInvocation

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    if (node.getArguments().isEmpty()) {
        if (node.getMethodSelect().getKind() == Kind.MEMBER_SELECT) {
            MemberSelectTree mst = (MemberSelectTree) node.getMethodSelect();
            Element e = info.getTrees().getElement(new TreePath(new TreePath(getCurrentPath(), mst), mst.getExpression()));

            if (parameter.equals(e) && mst.getIdentifier().contentEquals("getClass")) { // NOI18N
                throw new Found();
            }
        } else if (node.getMethodSelect().getKind() == Kind.IDENTIFIER) {
            IdentifierTree it = (IdentifierTree) node.getMethodSelect();

            if (it.getName().contentEquals("getClass")) { // NOI18N
                throw new Found();
            }
        }
    }
    
    return super.visitMethodInvocation(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:EqualsMethodHint.java

示例12: invocationOnThis

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
private static boolean invocationOnThis(MethodInvocationTree mit) {
    Tree select = mit.getMethodSelect();
    
    switch (select.getKind()) {
        case IDENTIFIER:
            return true;
        case MEMBER_SELECT:
            if (((MemberSelectTree) select).getExpression().getKind() == Kind.IDENTIFIER) {
                IdentifierTree ident = (IdentifierTree) ((MemberSelectTree) select).getExpression();

                return ident.getName().contentEquals("this");
            }
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:OverridableMethodCallInConstructor.java

示例13: getBundleName

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
private String getBundleName(MethodInvocationTree n, int index, String bfn) {
    if (n.getArguments().size() <= index) {
        return null;
    }
    ExpressionTree t = n.getArguments().get(index);
    // recognize just string literals + .class references
    if (t.getKind() == Tree.Kind.STRING_LITERAL) {
        Object o = ((LiteralTree)t).getValue();
        return o == null ? null : o.toString();
    } else if (t.getKind() == Tree.Kind.MEMBER_SELECT) {
        MemberSelectTree mst = (MemberSelectTree)t;
        if (!mst.getIdentifier().contentEquals("class")) {
            return null;
        }
        return bundleFileFromClass(new TreePath(getCurrentPath(), mst.getExpression()), bfn);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ResourceStringFoldProvider.java

示例14: matchMemberSelect

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@Override
public Description matchMemberSelect(MemberSelectTree tree, VisitorState state) {
  if (!matchWithinClass) {
    return Description.NO_MATCH;
  }
  Symbol symbol = ASTHelpers.getSymbol(tree);
  // some checks for cases where we know it is not
  // a null dereference
  if (symbol == null || symbol.getSimpleName().toString().equals("class") || symbol.isEnum()) {
    return Description.NO_MATCH;
  }

  Description badDeref = matchDereference(tree.getExpression(), tree, state);
  if (!badDeref.equals(Description.NO_MATCH)) {
    return badDeref;
  }
  // if we're accessing a field of this, make sure we're not reading the field before init
  if (tree.getExpression() instanceof IdentifierTree
      && ((IdentifierTree) tree.getExpression()).getName().toString().equals("this")) {
    return checkForReadBeforeInit(tree, state);
  }
  return Description.NO_MATCH;
}
 
开发者ID:uber,项目名称:NullAway,代码行数:24,代码来源:NullAway.java

示例15: depth

import com.sun.source.tree.MemberSelectTree; //导入依赖的package包/类
@SuppressWarnings("unused")
private int depth(ExpressionTree expression) {
  switch (expression.getKind()) {
    case MEMBER_SELECT:
      MemberSelectTree selectTree = (MemberSelectTree) expression;
      return 1 + depth(selectTree.getExpression());
    case METHOD_INVOCATION:
      MethodInvocationTree invTree = (MethodInvocationTree) expression;
      return depth(invTree.getMethodSelect());
    case IDENTIFIER:
      IdentifierTree varTree = (IdentifierTree) expression;
      Symbol symbol = ASTHelpers.getSymbol(varTree);
      return (symbol.getKind().equals(ElementKind.FIELD)) ? 2 : 1;
    default:
      return 0;
  }
}
 
开发者ID:uber,项目名称:NullAway,代码行数:18,代码来源:NullAway.java


注:本文中的com.sun.source.tree.MemberSelectTree类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。