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


Java NewClassTree.getEnclosingExpression方法代码示例

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


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

示例1: visitNewClass

import com.sun.source.tree.NewClassTree; //导入方法依赖的package包/类
@Override
public Tree visitNewClass(NewClassTree node, Trees p) {
    Tree t = super.visitNewClass(node, p);
    // new class tree > expression statement tree > block. Does not accept anonymous classes for ctor references.
    if (node.getClassBody() == null && singleStatementLambdaMethodBody == getCurrentPath().getParentPath().getParentPath().getLeaf()) {
        Tree parent = getCurrentPath().getParentPath().getLeaf();
        Element el = info.getTrees().getElement(getCurrentPath());
        if (el == null || el.getKind() != ElementKind.CONSTRUCTOR || !el.getEnclosingElement().getKind().isClass()) {
            return t;
        }
        el = el.getEnclosingElement();
        if (parent.getKind() == Tree.Kind.EXPRESSION_STATEMENT || parent.getKind() == Tree.Kind.RETURN) {
            ExpressionTree et = node.getEnclosingExpression();
            if (et != null) {
                if (el.getModifiers().contains(Modifier.STATIC) || !isMeaninglessQualifier(new TreePath(getCurrentPath().getParentPath(), et))) {
                    return t;
                }
            }
            foundConstructorReferenceCandidate = true;
        }
    }
    return t;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ConvertToLambdaPreconditionChecker.java

示例2: visitNewClass

import com.sun.source.tree.NewClassTree; //导入方法依赖的package包/类
@Override
public List<? extends TypeMirror> visitNewClass(NewClassTree node, Object p) {
    TypeMirror tm = info.getTrees().getTypeMirror(getCurrentPath());
    if (tm == null || tm.getKind() != TypeKind.DECLARED) {
        return null;
    }
    Element el = info.getTrees().getElement(getCurrentPath());
    if (el == null) {
        return null;
    }
    if (theExpression.getLeaf() != node.getEnclosingExpression()) {
        ExecutableType execType = (ExecutableType)info.getTypes().asMemberOf((DeclaredType)tm, el);
        return visitMethodOrNew(node, p, node.getArguments(), execType);
    } else {
        DeclaredType dt = (DeclaredType)tm;
        if (dt.getEnclosingType() == null) {
            return null;
        }
        return Collections.singletonList(dt.getEnclosingType());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ExpectedTypeResolver.java

示例3: visitNewClass

import com.sun.source.tree.NewClassTree; //导入方法依赖的package包/类
@Override
public Void visitNewClass(NewClassTree node, Void unused) {
    sync(node);
    builder.open(ZERO);
    if (node.getEnclosingExpression() != null) {
        scan(node.getEnclosingExpression(), null);
        builder.breakOp();
        token(".");
    }
    token("new");
    builder.space();
    addTypeArguments(node.getTypeArguments(), plusFour);
    if (node.getClassBody() != null) {
        List<Op> ops = visitModifiers(node.getClassBody().getModifiers(),
                Direction.HORIZONTAL, Optional.<BreakTag>absent());
        builder.addAll(ops);
    }
    scan(node.getIdentifier(), null);
    addArguments(node.getArguments(), plusFour);
    builder.close();
    if (node.getClassBody() != null) {
        addBodyDeclarations(
                node.getClassBody().getMembers(), BracesOrNot.YES, FirstDeclarationsOrNot.YES);
    }
    return null;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:27,代码来源:JavaInputAstVisitor.java

示例4: visitNewClass

import com.sun.source.tree.NewClassTree; //导入方法依赖的package包/类
@Override
public Void visitNewClass(NewClassTree node, Void p) {
    //XXX:
    if (node.getEnclosingExpression() != null) {
        tree2Variable.put(node, make.Identifier("$" + currentVariableIndex++));
        return null;
    }

    NewClassTree nue = make.NewClass(node.getEnclosingExpression(), Collections.<ExpressionTree>singletonList(make.Identifier("$" + currentVariableIndex++ + "$")), make.Identifier("$" + currentVariableIndex++), Collections.<ExpressionTree>singletonList(make.Identifier("$" + currentVariableIndex++ + "$")), null);

    tree2Variable.put(node, nue);

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

示例5: visitNewClass

import com.sun.source.tree.NewClassTree; //导入方法依赖的package包/类
@Override
public Choice<State<JCNewClass>> visitNewClass(final NewClassTree node, State<?> state) {
  if (node.getEnclosingExpression() != null
      || (node.getTypeArguments() != null && !node.getTypeArguments().isEmpty())
      || node.getClassBody() != null) {
    return Choice.none();
  }
  return chooseSubtrees(
      state,
      s -> unifyExpression(node.getIdentifier(), s),
      s -> unifyExpressions(node.getArguments(), s),
      (ident, args) -> maker().NewClass(null, null, ident, args, null));
}
 
开发者ID:google,项目名称:error-prone,代码行数:14,代码来源:PlaceholderUnificationVisitor.java

示例6: visitNewClass

import com.sun.source.tree.NewClassTree; //导入方法依赖的package包/类
@Override
public Node visitNewClass(NewClassTree tree, Void p) {
    // see JLS 15.9

    Tree enclosingExpr = tree.getEnclosingExpression();
    if (enclosingExpr != null) {
        scan(enclosingExpr, p);
    }

    // We ignore any class body because its methods should
    // be visited separately.

    // Convert constructor arguments
    ExecutableElement constructor = TreeUtils.elementFromUse(tree);

    List<? extends ExpressionTree> actualExprs = tree.getArguments();

    List<Node> arguments = convertCallArguments(constructor,
            actualExprs);

    Node constructorNode = scan(tree.getIdentifier(), p);

    Node node = new ObjectCreationNode(tree, constructorNode, arguments);

    Set<TypeMirror> thrownSet = new HashSet<>();
    // Add exceptions explicitly mentioned in the throws clause.
    List<? extends TypeMirror> thrownTypes = constructor.getThrownTypes();
    thrownSet.addAll(thrownTypes);
    // Add Throwable to account for unchecked exceptions
    TypeElement throwableElement = elements
            .getTypeElement("java.lang.Throwable");
    thrownSet.add(throwableElement.asType());

    extendWithNodeWithExceptions(node, thrownSet);

    return node;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:38,代码来源:CFGBuilder.java

示例7: visitNewClass

import com.sun.source.tree.NewClassTree; //导入方法依赖的package包/类
@Override
public Node visitNewClass(NewClassTree tree, Void p) {
    // see JLS 15.9

    Tree enclosingExpr = tree.getEnclosingExpression();
    if (enclosingExpr != null) {
        scan(enclosingExpr, p);
    }

    // We ignore any class body because its methods should
    // be visited separately.
    // TODO: For anonymous classes we want to propagate the current store
    // to the anonymous class.
    // See Issues 266, 811.

    // Convert constructor arguments
    ExecutableElement constructor = TreeUtils.elementFromUse(tree);

    List<? extends ExpressionTree> actualExprs = tree.getArguments();

    List<Node> arguments = convertCallArguments(constructor, actualExprs);

    // TODO: for anonymous classes, don't use the identifier alone.
    // See Issue 890.
    Node constructorNode = scan(tree.getIdentifier(), p);

    Node node = new ObjectCreationNode(tree, constructorNode, arguments);

    Set<TypeMirror> thrownSet = new HashSet<>();
    // Add exceptions explicitly mentioned in the throws clause.
    List<? extends TypeMirror> thrownTypes = constructor.getThrownTypes();
    thrownSet.addAll(thrownTypes);
    // Add Throwable to account for unchecked exceptions
    TypeElement throwableElement = elements.getTypeElement("java.lang.Throwable");
    thrownSet.add(throwableElement.asType());

    extendWithNodeWithExceptions(node, thrownSet);

    return node;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:41,代码来源:CFGBuilder.java

示例8: visitNewClass

import com.sun.source.tree.NewClassTree; //导入方法依赖的package包/类
@Override
public Wrapper visitNewClass(NewClassTree arg0, Void arg1) {
    if (arg0.getEnclosingExpression() != null) {
        // expr.new C< ... > ( ... )
        throw new AssertionError("TODO: Handle enclosing expression.");
    }
    return new NewInstanceWrapper(arg0, visit(arg0.getIdentifier(),
            ExpressionWrapper.class), visitList(
            arg0.getTypeArguments(), ExpressionWrapper.class),
            visitList(arg0.getArguments(), ExpressionWrapper.class),
            visit(arg0.getClassBody(), Wrapper.class));
}
 
开发者ID:provegard,项目名称:yield4j,代码行数:13,代码来源:JavaTreeBuilderNew.java


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