Package com.sun.source.util

Examples of com.sun.source.util.TreePath


  public static void main(String[] ignored)
  {
    try
    {
      JavaFileParser parser = new JavaFileParser("C:/temp/JavaFileParser.java");
      TreePath sourcecode = parser.getSourcecode();
      String sourcecodeString = parser.getSourcecodeString();
      System.out.println("sourcecode:\n" + sourcecodeString);
     
      for (Tree type: parser.getTypes())
      {
View Full Code Here


    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnvironment) {
      for (Element e : roundEnvironment.getRootElements()) {
        // Normally the ellement should represent a class
        TreePath tp = trees.getPath(e);
        // invoke the scanner
        visitor.scan(tp, trees);
      }
      return true;    // handled, don't invoke other processors
    }
View Full Code Here

        methTree = (JCMethodDecl) elementUtils.getTree(e);

        thisExp = tm.This((Type) encClass.asType());

        final TreePath treePath = trees.getPath(e);
        final CompilationUnitTree cut = treePath.getCompilationUnit();
        boolean reflectOnlyThis = false;
        if (!reflectAll) {
            if (annName.equals(Reflect.class.getCanonicalName())) {
                final Reflect refAnn = e.getAnnotation(Reflect.class);
                reflectOnlyThis = refAnn.all();
View Full Code Here

    private Scope getScope(Tree stmt, final CompilationUnitTree cut, Scope validScope) {
        if (stmt instanceof JCVariableDecl) {
            JCExpression exp = ((JCVariableDecl) stmt).init;
            ((JCVariableDecl) stmt).init = null;
            TreePath path = TreePath.getPath(cut, stmt);
            validScope = trees.getScope(path);
            ((JCVariableDecl) stmt).init = exp;
        } else if (stmt instanceof JCEnhancedForLoop) {
            return getScope(((JCEnhancedForLoop) stmt).var, cut, validScope);
        } else if (stmt instanceof JCForLoop) {
View Full Code Here

                final JCStatement dummyStmt = tm.Exec(dummyMi);
                final JCMethodDecl mt = (JCMethodDecl) scopeTree;
                mt.body.stats = injectBefore(mt.body.stats.head, mt.body.stats, dummyStmt);
                scopeTree = mt.body.stats.head;
                dummyInjected = true;
                final TreePath path = trees.getPath(cut, scopeTree);
                scope = trees.getScope(path);
                mt.body.stats = rs.injectBefore(mt.body.stats.head, mt.body.stats, true);
            }
        }

        if (!dummyInjected) {
            final TreePath path = trees.getPath(cut, scopeTree);
            scope = trees.getScope(path);
        }
        return processElement((JCBlock) tree, cut, scope);
    }
View Full Code Here

                    refStmts.add(setAccessibleExec);
                    throwExceptions(exceptions);
                }
                encBlock.stats = injectBefore((JCStatement) n.actual, encBlock.stats, refStmts.toArray(new JCStatement[0]));

                TreePath refPath = trees.getPath(cut, refStmts.getLast());
                n.scope = getScope(n.actual, cut, trees.getScope(refPath));
            }
        }
    }
View Full Code Here

  }

  @Override
  public JS visit(WriterVisitor<JS> visitor, MemberReferenceTree tree, GenerationContext<JS> context) {
    ExecutableElement methodElement = (ExecutableElement) context.getTrees().getElement(context.getCurrentPath());
    Element qualifierElement = context.getTrees().getElement(new TreePath(context.getCurrentPath(), tree.getQualifierExpression()));

    // System.out.println(tree + ":left:" + tree.getQualifierExpression().getClass() + ", kind:" +
    // qualifierElemenet.getKind());
    if (tree.getMode() == ReferenceMode.INVOKE) {
      if (qualifierElement.getKind() == ElementKind.CLASS) {
View Full Code Here

    Element fieldElement = TreeUtils.elementFromUse(tree);
    if (!IdentifierAccessOuterScopeCheck.isRegularInstanceField(fieldElement, tree)) {
      return null;
    }

    TreePath enclosingLambdaPath = TreeUtils.enclosingPathOfType(context.getCurrentPath(), LambdaExpressionTree.class);

    if (enclosingLambdaPath != null) {
      context.addError(
          tree,
          "In Javascript you cannot access a field from the outer type. "
View Full Code Here

    if (!(tree.getMethodSelect() instanceof IdentifierTree)) {
      // check for Outer.this check
      return null;
    }

    TreePath enclosingLambdaPath = TreeUtils.enclosingPathOfType(context.getCurrentPath(), LambdaExpressionTree.class);

    if (enclosingLambdaPath != null) {
      context.addError(tree, "In Javascript you cannot access a method from the outer type. "
          + "You should define a variable var that=this outside your lamda expression and use the method of this object. The method: "
          + tree);
View Full Code Here

  public static/* @Nullable */MethodTree enclosingMethod(final/* @Nullable */TreePath path) {
    return (MethodTree) enclosingOfKind(path, Tree.Kind.METHOD);
  }

  public static/* @Nullable */BlockTree enclosingTopLevelBlock(TreePath path) {
    TreePath parpath = path.getParentPath();
    while (parpath != null && parpath.getLeaf().getKind() != Tree.Kind.CLASS) {
      path = parpath;
      parpath = parpath.getParentPath();
    }
    if (path.getLeaf().getKind() == Tree.Kind.BLOCK) {
      return (BlockTree) path.getLeaf();
    }
    return null;
View Full Code Here

TOP

Related Classes of com.sun.source.util.TreePath

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.