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


Java ParenthesizedTree类代码示例

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


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

示例1: computeParenthesis

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
private static List<? extends TypeMirror> computeParenthesis(Set<ElementKind> types, CompilationInfo info, TreePath parent, Tree error, int offset) {
    ParenthesizedTree pt = (ParenthesizedTree) parent.getLeaf();
    
    if (pt.getExpression() != error) {
        return null;
    }
    
    TreePath parentParent = parent.getParentPath();
    List<? extends TypeMirror> upperTypes = resolveType(types, info, parentParent, pt, offset, null, null);
    
    if (upperTypes == null) {
        return null;
    }
    
    return upperTypes;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CreateElementUtilities.java

示例2: performRewrite

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
@Override
protected void performRewrite(TransformationContext ctx) {
    WorkingCopy wc = ctx.getWorkingCopy();
    TreePath path = ctx.getPath();
    TypeCastTree tct = (TypeCastTree) path.getLeaf();
    ExpressionTree expression = tct.getExpression();

    while (expression.getKind() == Kind.PARENTHESIZED
           && !JavaFixUtilities.requiresParenthesis(((ParenthesizedTree) expression).getExpression(), tct, path.getParentPath().getLeaf())) {
        expression = ((ParenthesizedTree) expression).getExpression();
    }

    while (path.getParentPath().getLeaf().getKind() == Kind.PARENTHESIZED
           && !JavaFixUtilities.requiresParenthesis(expression, path.getLeaf(), path.getParentPath().getParentPath().getLeaf())) {
        path = path.getParentPath();
    }

    wc.rewrite(path.getLeaf(), expression);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:RemoveUselessCast.java

示例3: performRewrite

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
@Override
protected void performRewrite(final TransformationContext ctx) throws Exception {
    IfTree toRewrite = (IfTree) ctx.getPath().getLeaf();
    StatementTree elseStatement = toRewrite.getElseStatement();
    if (toRewrite.getCondition() == null ||
        toRewrite.getCondition().getKind() != Tree.Kind.PARENTHESIZED) {
        return;
    }
    ParenthesizedTree ptt = (ParenthesizedTree)toRewrite.getCondition();
    if (ptt.getExpression() == null) {
        return;
    }
    if (elseStatement == null) elseStatement = ctx.getWorkingCopy().getTreeMaker().Block(Collections.<StatementTree>emptyList(), false);
    
    ctx.getWorkingCopy().rewrite(toRewrite, ctx.getWorkingCopy().getTreeMaker().If(toRewrite.getCondition(), elseStatement, toRewrite.getThenStatement()));
    ExpressionTree negated = Utilities.negate(
            ctx.getWorkingCopy().getTreeMaker(), ptt.getExpression(), ptt);
    ctx.getWorkingCopy().rewrite(ptt.getExpression(), negated);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Ifs.java

示例4: stripParensAndCasts

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
/**
 * strip out enclosing parentheses and type casts.
 *
 * @param expr
 * @return
 */
private static ExpressionTree stripParensAndCasts(ExpressionTree expr) {
  boolean someChange = true;
  while (someChange) {
    someChange = false;
    if (expr.getKind().equals(PARENTHESIZED)) {
      expr = ((ParenthesizedTree) expr).getExpression();
      someChange = true;
    }
    if (expr.getKind().equals(TYPE_CAST)) {
      expr = ((TypeCastTree) expr).getExpression();
      someChange = true;
    }
  }
  return expr;
}
 
开发者ID:uber,项目名称:NullAway,代码行数:22,代码来源:NullAway.java

示例5: visitParenthesized

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
@Override
public Tree visitParenthesized(ParenthesizedTree tree, Void p) {
    ParenthesizedTree n = make.Parenthesized(tree.getExpression());
    model.setType(n, model.getType(tree));
    comments.copyComments(tree, n);
    model.setPos(n, model.getPos(tree));
    return n;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:TreeDuplicator.java

示例6: visitParenthesized

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
public Boolean visitParenthesized(ParenthesizedTree node, TreePath p) {
    if (p == null)
        return super.visitParenthesized(node, p);

    ParenthesizedTree t = (ParenthesizedTree) p.getLeaf();

    return scan(node.getExpression(), t.getExpression(), p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CopyFinder.java

示例7: visitParenthesized

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
@Override
public Void visitParenthesized(ParenthesizedTree tree, EnumSet<UseTypes> d) {
    ExpressionTree expr = tree.getExpression();
    
    if (expr instanceof IdentifierTree) {
        handlePossibleIdentifier(new TreePath(getCurrentPath(), expr), EnumSet.of(UseTypes.READ));
    }
    
    super.visitParenthesized(tree, d);
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:SemanticHighlighterBase.java

示例8: visitParenthesized

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
@Override
public Object visitParenthesized(ParenthesizedTree node, Object p) {
    boolean b = isCorrectType(node);
    currentMatches = b;
    Object o = super.visitParenthesized(node, p);
    increment(node, b);
    return o;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ExpressionVisitor.java

示例9: visitParenthesized

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
@Override
public Void visitParenthesized(ParenthesizedTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();
    
    addCorrespondingType(below);
    addCorrespondingComments(below);
    super.visitParenthesized(tree, below);
    
    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:TreeNode.java

示例10: hintOnAssignment

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

示例11: getSubExpressionType

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
private Type getSubExpressionType(Tree t) {
    Type type = subExpressionTypes.get(t);
    if (type != null) {
        return type;
    } else {
        if (t.getKind() == Tree.Kind.PARENTHESIZED) {
            return getSubExpressionType(((ParenthesizedTree) t).getExpression());
        }
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:EvaluatorVisitor.java

示例12: getElement

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
private Element getElement(Tree tree) {
    TreePath expPath = TreePath.getPath(cut, tree);
    Element e = trees.getElement(expPath);
    if (e == null) {
        if (tree instanceof ParenthesizedTree) {
            e = getElement(((ParenthesizedTree) tree).getExpression());
            //if (e == null) {
            //    System.err.println("Have null element for "+tree);
            //}
            //System.err.println("\nHAVE "+e.asType().toString()+" for ParenthesizedTree "+tree);
        }
        else if (tree instanceof TypeCastTree) {
            e = getElement(((TypeCastTree) tree).getType());
            //if (e == null) {
            //    System.err.println("Have null element for "+tree);
            //}
            //System.err.println("\nHAVE "+e.asType().toString()+" for TypeCastTree "+tree);
        }
        else if (tree instanceof AssignmentTree) {
            e = getElement(((AssignmentTree) tree).getVariable());
        }
        else if (tree instanceof ArrayAccessTree) {
            e = getElement(((ArrayAccessTree) tree).getExpression());
            if (e != null) {
                TypeMirror tm = e.asType();
                if (tm.getKind() == TypeKind.ARRAY) {
                    tm = ((ArrayType) tm).getComponentType();
                    e = types.asElement(tm);
                }
            }
            //System.err.println("ArrayAccessTree = "+((ArrayAccessTree) tree).getExpression()+", element = "+getElement(((ArrayAccessTree) tree).getExpression())+", type = "+getElement(((ArrayAccessTree) tree).getExpression()).asType());
        }
    }
    return e;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:JDIWrappersTest.java

示例13: visitParenthesized

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
@Override
public Void visitParenthesized(ParenthesizedTree node, Void unused) {
    token("(");
    scan(node.getExpression(), null);
    token(")");
    return null;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:8,代码来源:JavaInputAstVisitor.java

示例14: stripParentheses

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
/** Removes any enclosing parentheses from the tree. */
public static Tree stripParentheses(Tree tree) {
  while (tree instanceof ParenthesizedTree) {
    tree = ((ParenthesizedTree) tree).getExpression();
  }
  return tree;
}
 
开发者ID:google,项目名称:error-prone,代码行数:8,代码来源:ASTHelpers.java

示例15: visitParenthesized

import com.sun.source.tree.ParenthesizedTree; //导入依赖的package包/类
@Override
public Void visitParenthesized(ParenthesizedTree tree, VisitorState visitorState) {
  VisitorState state = visitorState.withPath(getCurrentPath());
  for (ParenthesizedTreeMatcher matcher : parenthesizedMatchers) {
    if (!isSuppressed(matcher, state)) {
      try {
        reportMatch(matcher.matchParenthesized(tree, state), tree, state);
      } catch (Throwable t) {
        handleError(matcher, t);
      }
    }
  }
  return super.visitParenthesized(tree, state);
}
 
开发者ID:google,项目名称:error-prone,代码行数:15,代码来源:ErrorProneScanner.java


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