本文整理汇总了Java中com.sun.tools.javac.tree.TreeInfo.getStartPos方法的典型用法代码示例。如果您正苦于以下问题:Java TreeInfo.getStartPos方法的具体用法?Java TreeInfo.getStartPos怎么用?Java TreeInfo.getStartPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.tree.TreeInfo
的用法示例。
在下文中一共展示了TreeInfo.getStartPos方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOldPos
import com.sun.tools.javac.tree.TreeInfo; //导入方法依赖的package包/类
private int getOldPos(JCTree oldT) {
if (overrideStartPositions != null) {
Integer i = overrideStartPositions.get(oldT);
if (i != null) {
return i;
}
}
return TreeInfo.getStartPos(oldT);
}
示例2: visitTypeCast
import com.sun.tools.javac.tree.TreeInfo; //导入方法依赖的package包/类
@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);
}
示例3: printIndentedStat
import com.sun.tools.javac.tree.TreeInfo; //导入方法依赖的package包/类
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);
}
});
}
}
示例4: Info
import com.sun.tools.javac.tree.TreeInfo; //导入方法依赖的package包/类
Info(JCTree tree, EndPosTable endPosTable) {
this.tree = tree;
tag = tree.getTag();
start = TreeInfo.getStartPos(tree);
pos = tree.pos;
end = TreeInfo.getEndPos(tree, endPosTable);
}
示例5: Info
import com.sun.tools.javac.tree.TreeInfo; //导入方法依赖的package包/类
Info(JCTree tree, Map<JCTree, Integer> endPosTable) {
this.tree = tree;
tag = tree.getTag();
start = TreeInfo.getStartPos(tree);
pos = tree.pos;
end = TreeInfo.getEndPos(tree, endPosTable);
}
示例6: replace
import com.sun.tools.javac.tree.TreeInfo; //导入方法依赖的package包/类
@Override
public void replace(Tree source, String newSource) {
changed();
finish();
final EndPosTable endPosTable = ((JCCompilationUnit) cup).endPositions;
final int endPos = TreeInfo.getEndPos((JCTree) source, endPosTable);
final int startPos = TreeInfo.getStartPos((JCTree) source);
sources.requestOverwrite(cup, startPos, endPos, newSource);
}
示例7: FieldGroupTree
import com.sun.tools.javac.tree.TreeInfo; //导入方法依赖的package包/类
private FieldGroupTree(List<JCVariableDecl> vars, boolean enumeration, boolean moreElementsFollowEnum) {
this.vars = vars;
pos = TreeInfo.getStartPos(vars.get(0));
this.enumeration = enumeration;
this.moreElementsFollowEnum = moreElementsFollowEnum;
}
示例8: getOldPos
import com.sun.tools.javac.tree.TreeInfo; //导入方法依赖的package包/类
private static int getOldPos(JCTree oldT) {
return TreeInfo.getStartPos(oldT);
}
示例9: getStartPos
import com.sun.tools.javac.tree.TreeInfo; //导入方法依赖的package包/类
/** Get the start position for a tree node. The start position is
* defined to be the position of the first character of the first
* token of the node's source text.
* @param tree The tree node
*/
public int getStartPos(JCTree tree) {
return TreeInfo.getStartPos(tree);
}