Package com.sun.source.tree

Examples of com.sun.source.tree.Tree


            List<Tree> treeNodes,
            ExpressionScanner.ExpressionsInfo info,
            Map<Tree, Operation> nodeOperations) {
        int length = treeNodes.size();
        for (int treeIndex = 0; treeIndex < length; treeIndex++) {
            Tree node = treeNodes.get(treeIndex);
            Set<Tree> nextNodes = info.getNextExpressions(node);
            if (nextNodes != null) {
                EditorContext.Operation op = nodeOperations.get(node);
                if (op == null) {
                    for (int backIndex = treeIndex - 1; backIndex >= 0; backIndex--) {
View Full Code Here


        LineMap lineMap = cu.getLineMap();
        int indexesIndex = 0;
        int from = indexes[indexesIndex];
        int to = indexes[indexesIndex + 1];
        for (int treeIndex = 0; treeIndex < length; treeIndex++) {
            Tree node = treeNodes.get(treeIndex);
            Tree.Kind kind = node.getKind();
            EditorContext.Operation op = null;
            if (kind.equals(Tree.Kind.METHOD_INVOCATION) ||
                kind.equals(Tree.Kind.NEW_CLASS)) {
               
                int opcode;
                do {
                    do {
                        opcode = bytecodes[from] & 0xFF;
                        if (isMethodCall(opcode)) {
                            break;
                        }
                        from += getInstrSize(opcode, bytecodes, from);
                    } while (from < to);
                    if (from < to) {
                        break;
                    }
                    if ((indexesIndex + 2) < indexes.length) {
                        indexesIndex += 2;
                        from = indexes[indexesIndex];
                        to = indexes[indexesIndex + 1];
                    } else {
                        break;
                    }
                } while (true);
                if (from < to) { // We have the method call
                    if (!ci.getTreeUtilities().isSynthetic(ci.getTrees().getPath(cu, node))) {
                        int pos = (int) sp.getStartPosition(cu, node);
                        EditorContext.Position startPosition =
                                opCreationDelegate.createPosition(
                                        pos,
                                        (int) lineMap.getLineNumber(pos),
                                        (int) lineMap.getColumnNumber(pos)
                                );
                        pos = (int) sp.getEndPosition(cu, node);
                        EditorContext.Position endPosition =
                                opCreationDelegate.createPosition(
                                        pos,
                                        (int) lineMap.getLineNumber(pos),
                                        (int) lineMap.getColumnNumber(pos)
                                );
                        Tree identifier;
                        String methodName;
                        String methodClassType;
                        boolean getStartPosFromMethodLength = false;
                        if (kind.equals(Tree.Kind.NEW_CLASS)) {
                            identifier = ((NewClassTree) node).getIdentifier();
                            methodName = "<init>";
                            TreePath iPath = TreePath.getPath(cu, identifier);
                            TypeMirror type = trees.getTypeMirror(iPath);
                            if (type.getKind() == TypeKind.ERROR) {
                                // There are errors, give it up.
                                return null;
                            }
                            assert type.getKind() == TypeKind.DECLARED;
                            TypeElement te = (TypeElement) types.asElement(type);
                            methodClassType = ElementUtilities.getBinaryName(te);
                        } else {
                            //identifier = ((MemberSelectTree) ((MethodInvocationTree) node).getMethodSelect()).getIdentifier();
                            identifier = ((MethodInvocationTree) node).getMethodSelect();
                            if (identifier.getKind() == Tree.Kind.IDENTIFIER) {
                                methodName = ((IdentifierTree) identifier).getName().toString();
                                TreePath iPath = TreePath.getPath(cu, identifier);
                                TypeElement te = trees.getScope(iPath).getEnclosingClass();
                                if (te == null) {
                                    // No enclosing class? Some error, give it up.
View Full Code Here

    //public List<Tree> visitClass(ClassTree node, ExpressionScanner.ExpressionsInfo p) {
    //}

    public List<Tree> visitConditionalExpression(ConditionalExpressionTree node, ExpressionScanner.ExpressionsInfo p) {
        List<Tree> cond = scan(node.getCondition(), p);
        Tree lastCond = null;
        if (cond != null) {
            lastCond = cond.get(cond.size() - 1);
        }
        List<Tree> rT = scan(node.getTrueExpression(), p);
        List<Tree> rF = scan(node.getFalseExpression(), p);
View Full Code Here

        List<Tree> cond = null;
        if (acceptsTree(node.getCondition())) {
            cond = scan(node.getCondition(), p);
        }
        if (cond != null && cond.size() > 0 && statements != null && statements.size() > 0) {
            Tree lastCond = cond.get(cond.size() - 1);
            p.addNextExpression(lastCond, statements.get(0));
        }
        return reduce(statements, cond);
    }
View Full Code Here

    //public List<Tree> visitIdentifier(IdentifierTree node, ExpressionScanner.ExpressionsInfo p) {
    //}

    public List<Tree> visitIf(IfTree node, ExpressionScanner.ExpressionsInfo p) {
        List<Tree> cond = null;
        Tree lastCond = null;
        if (acceptsTree(node)) {
            cond = scan(node.getCondition(), p);
            if (cond != null) {
                lastCond = cond.get(cond.size() - 1);
            }
View Full Code Here

        return results;
    }

    public TypeMirror getTypeMirror(Iterable<? extends Tree> path) {
        // TODO: Should complete attribution if necessary
        Tree last = null;
        for (Tree node : path)
            last = node;
        return ((JCTree)last).type;
    }
View Full Code Here

        return results;
    }

    public TypeMirror getTypeMirror(Iterable<? extends Tree> path) {
        // TODO: Should complete attribution if necessary
        Tree last = null;
        for (Tree node : path)
            last = node;
        return ((JCTree)last).type;
    }
View Full Code Here

      // Skip or bad stuff happens
      if (typeNameQualified == null) {
        return super.visitMethod(methodTree, trees);
      }

      Tree returnType = methodTree.getReturnType();   // null for void method
      if (getter(methodTree) && returnType instanceof ParameterizedTypeTree) {
        assert Tree.Kind.PARAMETERIZED_TYPE == returnType.getKind();
        ParameterizedTypeTree parametrizedReturnType = (ParameterizedTypeTree) returnType;

        TypeCategory category = detectTypeCategory(parametrizedReturnType);
        if (category.isCollectionOrMap()) {
          Tree valueTypeArgument = parametrizedReturnType.getTypeArguments().get(category.getValueTypeArgumentIdx());
          final String qualifiedGenericTypeName = getQualifiedType(valueTypeArgument);

          String methodJsfName = getMethodJsfName(methodTree);
          System.out.println("FOUND " + typeNameQualified + "." + methodJsfName + ".*=" + qualifiedGenericTypeName);
          // Unqualified name:
View Full Code Here

   */
  public static Tree enclosingOfKind(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 leaf;
      }
      p = p.getParentPath();
    }

View Full Code Here

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

    while (p != null) {
      Tree leaf = p.getLeaf();
      assert leaf != null; /* nninvariant */
      if (clz.isAssignableFrom(leaf.getClass())) {
        return p;
      }
      p = p.getParentPath();
    }

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.