Java Code Examples for com.sun.tools.javac.tree.TreeInfo#getStartPos()

The following examples show how to use com.sun.tools.javac.tree.TreeInfo#getStartPos() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VeryPretty.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void printIndentedStat(JCTree tree, BracesGenerationStyle redundantBraces, boolean spaceBeforeLeftBrace, WrapStyle wrapStat) {
       if (fromOffset >= 0 && toOffset >= 0 && (TreeInfo.getStartPos(tree) < fromOffset || TreeInfo.getEndPos(tree, diffContext.origUnit.endPositions) > toOffset))
           redundantBraces = BracesGenerationStyle.LEAVE_ALONE;
switch(redundantBraces) {
       case GENERATE:
           printBlock(tree, cs.getOtherBracePlacement(), spaceBeforeLeftBrace);
           return;
       case ELIMINATE:
    while(tree instanceof JCBlock) {
	List<JCStatement> t = ((JCBlock) tree).stats;
	if(t.isEmpty() || t.tail.nonEmpty()) break;
	if (t.head instanceof JCVariableDecl)
	    // bogus code has a variable declaration -- leave alone.
	    break;
	printPrecedingComments(tree, true);
	tree = t.head;
    }
       case LEAVE_ALONE:
           if (tree instanceof JCBlock) {
               printBlock(tree, cs.getOtherBracePlacement(), spaceBeforeLeftBrace);
               return;
           }
           final int old = indent();
           final JCTree toPrint = tree;
           wrapTree(wrapStat, spaceBeforeLeftBrace, out.leftMargin, new Runnable() {
               @Override public void run() {
                   printStat(toPrint);
                   undent(old);
               }
           });
}
   }
 
Example 2
Source File: TreePosTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 3
Source File: CheckAttributedTree.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 4
Source File: TreePosTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 5
Source File: CheckAttributedTree.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 6
Source File: TreePosTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 7
Source File: CheckAttributedTree.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 8
Source File: TreePosTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 9
Source File: CheckAttributedTree.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 10
Source File: TreePosTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 11
Source File: TreePosTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 12
Source File: VeryPretty.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
   public void visitTypeCast(JCTypeCast tree) {
print(cs.spaceWithinTypeCastParens() ? "( " : "(");
print(tree.clazz);
print(cs.spaceWithinTypeCastParens() ? " )" : ")");
       if (cs.spaceAfterTypeCast())
           needSpace();
       if (diffContext.origUnit != null && TreePath.getPath(diffContext.origUnit, tree.expr) != null) {
           int a = TreeInfo.getStartPos(tree.expr);
           int b = TreeInfo.getEndPos(tree.expr, diffContext.origUnit.endPositions);
           print(diffContext.origText.substring(a, b));
           return;
       }
printExpr(tree.expr, TreeInfo.prefixPrec);
   }
 
Example 13
Source File: VeryPretty.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private int getOldPos(JCTree oldT) {
    if (overrideStartPositions != null) {
        Integer i = overrideStartPositions.get(oldT);
        if (i != null) {
            return i;
        }
    }
    return TreeInfo.getStartPos(oldT);
}
 
Example 14
Source File: CheckAttributedTree.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 15
Source File: TreePosTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 16
Source File: CheckAttributedTree.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 17
Source File: TreePosTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 18
Source File: CheckAttributedTree.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example 19
Source File: FieldGroupTree.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private FieldGroupTree(List<JCVariableDecl> vars, boolean enumeration, boolean moreElementsFollowEnum) {
    this.vars = vars;
    pos = TreeInfo.getStartPos(vars.get(0));
    this.enumeration = enumeration;
    this.moreElementsFollowEnum = moreElementsFollowEnum;
}
 
Example 20
Source File: CRTable.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/** The start position of given tree.
 */
public int startPos(JCTree tree) {
    if (tree == null) return Position.NOPOS;
    return TreeInfo.getStartPos(tree);
}