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


Java MethodInvocationTree.getMethodSelect方法代码示例

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


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

示例1: performRewrite

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的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

示例2: visitMethodInvocation

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的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

示例3: visitMethodInvocation

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的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

示例4: checkAlternativeInvocation

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
/**
 * Attempts to resolve a method or a constructor call with an altered argument tree.
 * 
 * @param ci the context
 * @param invPath path to the method invocation node
 * @param origPath path to the Tree within method's arguments which should be replaced
 * @param valPath the replacement tree
 * @return 
 */
public static boolean checkAlternativeInvocation(CompilationInfo ci, TreePath invPath, 
        TreePath origPath,
        TreePath valPath, String customPrefix) {
    Tree l = invPath.getLeaf();
    Tree sel;
    
    if (l.getKind() == Tree.Kind.NEW_CLASS) {
        NewClassTree nct = (NewClassTree)invPath.getLeaf();
        sel = nct.getIdentifier();
    } else if (l.getKind() == Tree.Kind.METHOD_INVOCATION) {
        MethodInvocationTree mit = (MethodInvocationTree)invPath.getLeaf();
        sel = mit.getMethodSelect();
    } else {
        return false;
    }
    
    return resolveAlternativeInvocation(ci, invPath, 
            origPath, sel, valPath, customPrefix);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:Utilities.java

示例5: invocationOnThis

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的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

示例6: isFirstStatementThisOrSuperCall

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
private static boolean isFirstStatementThisOrSuperCall(@NotNull JCTree.JCBlock body) {
    List<JCTree.JCStatement> statements = body.getStatements();
    if (statements.isEmpty()) {
        return false;
    }
    JCTree.JCStatement expressionCandidate = statements.get(0);
    if (expressionCandidate instanceof ExpressionStatementTree) {
        ExpressionStatementTree expression = (ExpressionStatementTree) expressionCandidate;
        ExpressionTree methodInvocationCandidate = expression.getExpression();
        if (methodInvocationCandidate instanceof MethodInvocationTree) {
            MethodInvocationTree methodInvocation = (MethodInvocationTree) methodInvocationCandidate;
            ExpressionTree methodSelect = methodInvocation.getMethodSelect();
            if (methodSelect != null) {
                String select = methodSelect.toString();
                return "this".equals(select) || "super".equals(select);
            }
        }
    }
    return false;
}
 
开发者ID:denis-zhdanov,项目名称:traute,代码行数:21,代码来源:ParameterInstrumentator.java

示例7: matches

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
@Override
public boolean matches(ExpressionTree tree, VisitorState state) {
  if (!(tree instanceof MethodInvocationTree)) {
    return false;
  }
  MethodInvocationTree invTree = (MethodInvocationTree) tree;

  final MemberSelectTree memberTree = (MemberSelectTree) invTree.getMethodSelect();
  if (!memberTree.getIdentifier().contentEquals(TO)) {
    return false;
  }

  for (MethodMatchers.MethodNameMatcher nameMatcher : METHOD_NAME_MATCHERS) {
    if (nameMatcher.matches(invTree, state)) {
      ExpressionTree arg = invTree.getArguments().get(0);
      final Type scoper = state.getTypeFromString("com.uber.autodispose.Scoper");
      return ASTHelpers.isSubtype(ASTHelpers.getType(arg), scoper, state);
    }
  }
  return false;
}
 
开发者ID:uber,项目名称:RIBs,代码行数:22,代码来源:RxJavaMissingAutodisposeErrorChecker.java

示例8: isSynthetic

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
private static boolean isSynthetic(CompilationUnitTree cut, Tree leaf) throws NullPointerException {
    JCTree tree = (JCTree) leaf;

    if (tree.pos == (-1))
        return true;

    if (leaf.getKind() == Kind.METHOD) {
        //check for synthetic constructor:
        return (((JCMethodDecl)leaf).mods.flags & Flags.GENERATEDCONSTR) != 0L;
    }

    //check for synthetic superconstructor call:
    if (cut != null && leaf.getKind() == Kind.EXPRESSION_STATEMENT) {
        ExpressionStatementTree est = (ExpressionStatementTree) leaf;

        if (est.getExpression().getKind() == Kind.METHOD_INVOCATION) {
            MethodInvocationTree mit = (MethodInvocationTree) est.getExpression();

            if (mit.getMethodSelect().getKind() == Kind.IDENTIFIER) {
                IdentifierTree it = (IdentifierTree) mit.getMethodSelect();

                if ("super".equals(it.getName().toString())) {
                    return ((JCCompilationUnit) cut).endPositions.getEndPos(tree) == (-1);
                }
            }
        }
    }

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

示例9: visitMethodInvocation

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
@Override
public Tree visitMethodInvocation(MethodInvocationTree methodInvocationTree, Trees trees) {
    String nameSuggestion = org.netbeans.modules.editor.java.Utilities.varNameSuggestion(methodInvocationTree.getMethodSelect());
    //check for recursion
    if (nameSuggestion != null && lambdaMethodTree.getName().contentEquals(nameSuggestion)) {
        ExpressionTree selector = getSelector(methodInvocationTree);
        if (selector == null || (org.netbeans.modules.editor.java.Utilities.varNameSuggestion(selector) != null
                && org.netbeans.modules.editor.java.Utilities.varNameSuggestion(selector).contentEquals("this"))) {
            foundRecursiveCall = true;
        }
    }
    if (singleStatementLambdaMethodBody == getCurrentPath().getParentPath().getParentPath().getLeaf()) {
        Tree parent = getCurrentPath().getParentPath().getLeaf();
        if (parent.getKind() == Tree.Kind.EXPRESSION_STATEMENT || parent.getKind() == Tree.Kind.RETURN) {
            boolean check = true;
            Iterator<? extends VariableTree> paramsIt = lambdaMethodTree.getParameters().iterator();
            ExpressionTree methodSelect = methodInvocationTree.getMethodSelect();
            if (paramsIt.hasNext() && methodSelect.getKind() == Tree.Kind.MEMBER_SELECT) {
                ExpressionTree expr = ((MemberSelectTree) methodSelect).getExpression();
                if (expr.getKind() == Tree.Kind.IDENTIFIER) {
                    if (!((IdentifierTree)expr).getName().contentEquals(paramsIt.next().getName())) {
                        paramsIt = lambdaMethodTree.getParameters().iterator();
                    }
                }
            }
            Iterator<? extends ExpressionTree> argsIt = methodInvocationTree.getArguments().iterator();
            while (check && argsIt.hasNext() && paramsIt.hasNext()) {
                ExpressionTree arg = argsIt.next();
                if (arg.getKind() != Tree.Kind.IDENTIFIER || !paramsIt.next().getName().contentEquals(((IdentifierTree)arg).getName())) {
                    check = false;
                }
            }
            if (check && !paramsIt.hasNext() && !argsIt.hasNext()) {
                foundMemberReferenceCandidate = true;
            }
        }
    }
    return super.visitMethodInvocation(methodInvocationTree, trees);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:ConvertToLambdaPreconditionChecker.java

示例10: isSuperCtorInvocation

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
private static boolean isSuperCtorInvocation(Tree t) {
    if (t.getKind() == Tree.Kind.EXPRESSION_STATEMENT) {
        t = ((ExpressionStatementTree)t).getExpression();
    }
    if (t.getKind() != Tree.Kind.METHOD_INVOCATION) {
        return false;
    }
    MethodInvocationTree mit = (MethodInvocationTree)t;
    if (mit.getMethodSelect() == null || 
        mit.getMethodSelect().getKind() != Tree.Kind.IDENTIFIER) {
        return false;
    }
    return ((IdentifierTree)mit.getMethodSelect()).getName().contentEquals("super");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:Utilities.java

示例11: methodName

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
private static String methodName(MethodInvocationTree mit) {
    ExpressionTree select = mit.getMethodSelect();

    switch (select.getKind()) {
        case IDENTIFIER: return ((IdentifierTree) select).getName().toString();
        case MEMBER_SELECT: return ((MemberSelectTree) select).getIdentifier().toString();
        default: throw new UnsupportedOperationException(select.getKind().toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:Tiny.java

示例12: buildObservableCallChain

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
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.
}
 
开发者ID:uber,项目名称:NullAway,代码行数:10,代码来源:RxNullabilityPropagator.java

示例13: getMethodName

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
/**
 * Returns the simple name of a (possibly qualified) method invocation expression.
 */
static Name getMethodName(MethodInvocationTree methodInvocation) {
    ExpressionTree select = methodInvocation.getMethodSelect();
    return select instanceof MemberSelectTree
            ? ((MemberSelectTree) select).getIdentifier()
            : ((IdentifierTree) select).getName();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:10,代码来源:Trees.java

示例14: fillFirstArgument

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
private boolean fillFirstArgument(
        ExpressionTree e,
        List<ExpressionTree> items,
        Indent indent) {
    // is there a trailing dereference?
    if (items.size() < 2) {
        return false;
    }
    // don't special-case calls nested inside expressions
    if (e.getKind() != METHOD_INVOCATION) {
        return false;
    }
    MethodInvocationTree methodInvocation = (MethodInvocationTree) e;
    Name name = getMethodName(methodInvocation);
    if (!(methodInvocation.getMethodSelect() instanceof IdentifierTree)
            || name.length() > 4
            || !methodInvocation.getTypeArguments().isEmpty()
            || methodInvocation.getArguments().size() != 1) {
        return false;
    }
    builder.open(ZERO);
    builder.open(indent);
    visit(name);
    token("(");
    ExpressionTree arg = getOnlyElement(methodInvocation.getArguments());
    scan(arg, null);
    builder.close();
    token(")");
    builder.close();
    return true;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:32,代码来源:JavaInputAstVisitor.java

示例15: visitMethodInvocation

import com.sun.source.tree.MethodInvocationTree; //导入方法依赖的package包/类
@Override
        public Void visitMethodInvocation(MethodInvocationTree tree, EnumSet<UseTypes> d) {
            Tree possibleIdent = tree.getMethodSelect();
            boolean handled = false;
            
            if (possibleIdent.getKind() == Kind.IDENTIFIER) {
                //handle "this" and "super" constructors:
                String ident = ((IdentifierTree) possibleIdent).getName().toString();
                
                if ("super".equals(ident) || "this".equals(ident)) { //NOI18N
                    Element resolved = info.getTrees().getElement(getCurrentPath());
                    
                    addUse(resolved, EnumSet.of(UseTypes.EXECUTE), null, null);
                    handled = true;
                }
            }
            
            if (!handled) {
                handlePossibleIdentifier(new TreePath(getCurrentPath(), possibleIdent), EnumSet.of(UseTypes.EXECUTE));
            }
            
            List<? extends Tree> ta = tree.getTypeArguments();
            long afterTypeArguments = ta.isEmpty() ? -1 : info.getTrees().getSourcePositions().getEndPosition(info.getCompilationUnit(), ta.get(ta.size() - 1));
            
            switch (tree.getMethodSelect().getKind()) {
                case IDENTIFIER:
                case MEMBER_SELECT:
                    memberSelectBypass = afterTypeArguments;
                    scan(tree.getMethodSelect(), EnumSet.of(UseTypes.READ));
                    memberSelectBypass = -1;
                    break;
                default:
                    //todo: log
                    scan(tree.getMethodSelect(), EnumSet.of(UseTypes.READ));
            }

            handleMethodTypeArguments(getCurrentPath(), ta);
            
            scan(tree.getTypeArguments(), null);
            
//            if (tree.getMethodSelect().getKind() == Kind.MEMBER_SELECT && tree2Token.get(tree.getMethodSelect()) == null) {
////                if (ts.moveNext()) ???
//                    firstIdentifier(((MemberSelectTree) tree.getMethodSelect()).getIdentifier().toString());
//            }

            if (tree.getArguments() != null) {
                for (Tree expr : tree.getArguments()) {
                    if (expr instanceof IdentifierTree) {
                        handlePossibleIdentifier(new TreePath(getCurrentPath(), expr), EnumSet.of(UseTypes.READ));
                    }
                }
            }
            
            scan(tree.getArguments(), EnumSet.of(UseTypes.READ));
            
//            super.visitMethodInvocation(tree, null);
            return null;
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:59,代码来源:SemanticHighlighterBase.java


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