Package com.sun.source.tree

Examples of com.sun.source.tree.Tree


   */
  public static TreePath pathTillOfKind(final TreePath path, final Set<Tree.Kind> kinds) {
    TreePath p = path;

    while (p != null) {
      Tree leaf = p.getLeaf();
      assert leaf != null; /* nninvariant */
      if (kinds.contains(leaf.getKind())) {
        return p;
      }
      p = p.getParentPath();
    }

View Full Code Here


   */
  public static <T extends Tree> T enclosingOfClass(final TreePath path, final Class<T> treeClass) {
    TreePath p = path;

    while (p != null) {
      Tree leaf = p.getLeaf();
      if (treeClass.isInstance(leaf)) {
        return treeClass.cast(leaf);
      }
      p = p.getParentPath();
    }
View Full Code Here

    TreePath path = treePath.getParentPath();

    if (path == null) {
      return null;
    }
    Tree node = path.getLeaf();
    if ((node instanceof AssignmentTree) || (node instanceof CompoundAssignmentTree) || (node instanceof MethodInvocationTree)
        || (node instanceof NewArrayTree) || (node instanceof NewClassTree) || (node instanceof ReturnTree)
        || (node instanceof VariableTree)) {
      return node;
    }
View Full Code Here

    return "this".contentEquals(TreeUtils.methodName(invocation));
  }

  public static final Tree firstStatement(Tree tree) {
    Tree first;
    if (tree.getKind() == Tree.Kind.BLOCK) {
      BlockTree block = (BlockTree) tree;
      if (block.getStatements().isEmpty()) {
        first = block;
      } else {
View Full Code Here

*/
public class VariableWriter<JS> implements WriterContributor<VariableTree, JS> {
  private final FieldWriter<JS> fieldWriter = new FieldWriter<JS>();

  private boolean isLoopInitializer(GenerationContext<JS> context) {
    Tree parent = context.getCurrentPath().getParentPath().getLeaf();
    return parent instanceof ForLoopTree || parent instanceof EnhancedForLoopTree;
  }
View Full Code Here

*/
public class SwitchWriter<JS> implements WriterContributor<SwitchTree, JS> {

  @Override
  public JS visit(WriterVisitor<JS> visitor, SwitchTree tree, GenerationContext<JS> context) {
    Tree expr = tree.getExpression();
    if (expr instanceof ParenthesizedTree) {
      // remove the parans
      expr = ((ParenthesizedTree) expr).getExpression();
    }
    JS jsExpr = visitor.scan(expr, context);
View Full Code Here

      // super.field does not make sense, so convert it to this
      return context.js().keyword(Keyword.THIS);
    }

    TreeWrapper<IdentifierTree, JS> tw = context.getCurrentWrapper();
    Tree target = tree.getExpression();
    JS targetJS = visitor.scan(target, context);
    if (tw.isStatic() && !ElementUtils.isTypeKind(tw.child(target).getElement())) {
      //this is static method called from an instances: e.g. x.staticField
      targetJS = tw.getContext().js().property(targetJS, JavascriptKeywords.CONSTRUCTOR);
    }
View Full Code Here

*
* @author acraciun
*/
public class VariableFinalInLoopCheck implements CheckContributor<VariableTree> {
  private static boolean isLoop(TreePath path) {
    Tree tree = path.getLeaf();
    return tree instanceof ForLoopTree || tree instanceof EnhancedForLoopTree || tree instanceof WhileLoopTree;
  }
View Full Code Here

    Tree tree = path.getLeaf();
    return tree instanceof ForLoopTree || tree instanceof EnhancedForLoopTree || tree instanceof WhileLoopTree;
  }

  private static boolean isMethodOrClassDeclaration(TreePath path) {
    Tree tree = path.getLeaf();
    return tree instanceof MethodTree || tree instanceof ClassTree;
  }
View Full Code Here

            return null;
        return TreePath.getPath(treeTopLevel.snd, treeTopLevel.fst);
    }
   
    public Element getElement(TreePath path) {
        Tree t = path.getLeaf();
        return TreeInfo.symbolFor((JCTree) t);
    }
View Full Code Here

TOP

Related Classes of com.sun.source.tree.Tree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.