本文整理汇总了Java中com.sun.tools.javac.tree.EndPosTable类的典型用法代码示例。如果您正苦于以下问题:Java EndPosTable类的具体用法?Java EndPosTable怎么用?Java EndPosTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EndPosTable类属于com.sun.tools.javac.tree包,在下文中一共展示了EndPosTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyzePackageName
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
private static void analyzePackageName(
CompilationUnitTree cut, Source src, EndPosTable endPosTable) {
ExpressionTree packageExpr = cut.getPackageName();
if (isNull(packageExpr)) {
src.setPackageName("");
} else {
src.setPackageName(packageExpr.toString());
}
if (packageExpr instanceof JCTree.JCIdent) {
JCTree.JCIdent ident = (JCTree.JCIdent) packageExpr;
int startPos = ident.getPreferredPosition();
int endPos = ident.getEndPosition(endPosTable);
Range range = Range.create(src, startPos + 1, endPos);
long pkgLine = range.begin.line;
src.setPackageStartLine(pkgLine);
}
}
示例2: TranslatePositionsVisitor
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
public TranslatePositionsVisitor (final MethodTree changedMethod, final EndPosTable endPos, final int delta) {
assert changedMethod != null;
assert endPos != null;
this.changedMethod = changedMethod;
this.endPos = endPos;
this.delta = delta;
}
示例3: Info
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
Info(JCTree tree, EndPosTable endPosTable) {
this.tree = tree;
tag = tree.getTag();
start = TreeInfo.getStartPos(tree);
pos = tree.pos;
end = TreeInfo.getEndPos(tree, endPosTable);
}
示例4: analyzeCompilationUnitTree
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
private static void analyzeCompilationUnitTree(SourceContext context, CompilationUnitTree cut) {
Source src = context.getSource();
log.trace("file={}", src.getFile());
EndPosTable endPosTable = ((JCTree.JCCompilationUnit) cut).endPositions;
context.setEndPosTable(endPosTable);
analyzePackageName(cut, src, endPosTable);
analyzeImports(cut, src, endPosTable);
try {
for (Tree td : cut.getTypeDecls()) {
// start class
if (td instanceof JCTree.JCClassDecl) {
analyzeTopLevelClass(context, (JCTree.JCClassDecl) td);
} else if (td instanceof JCTree.JCSkip) {
// skip
} else if (td instanceof JCTree.JCErroneous) {
// skip erroneous
} else {
log.warn("unknown td={} {}", td, td.getClass());
}
}
} catch (IOException e) {
log.catching(e);
throw new UncheckedIOException(e);
}
}
示例5: getReplacements
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
@Override
public Set<Replacement> getReplacements(EndPosTable endPositions) {
if (endPositions == null) {
throw new IllegalArgumentException(
"Cannot produce correct replacements without endPositions.");
}
Replacements replacements = new Replacements();
for (FixOperation fix : fixes) {
replacements.add(fix.getReplacement(endPositions));
}
return replacements.descending();
}
示例6: JavacErrorDescriptionListener
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
private JavacErrorDescriptionListener(
Log log, EndPosTable endPositions, JavaFileObject sourceFile, boolean dontUseErrors) {
this.log = log;
this.sourceFile = sourceFile;
this.dontUseErrors = dontUseErrors;
checkNotNull(endPositions);
try {
CharSequence sourceFileContent = sourceFile.getCharContent(true);
fixToAppliedFix = fix -> AppliedFix.fromSource(sourceFileContent, endPositions).apply(fix);
} catch (IOException e) {
throw new IOError(e);
}
}
示例7: stubPackage
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
/**
* A helper method to create a stubbed package JCExpression.
*
* @param endPos the end position of the package JCExpression
* @return a new package JCExpression stub
*/
private static JCExpression stubPackage(int endPos) {
// TODO(b/67738557): consolidate helpers for creating fake trees
return new JCExpression() {
@Override
public Tag getTag() {
throw new UnsupportedOperationException();
}
@Override
public void accept(Visitor visitor) {
throw new UnsupportedOperationException();
}
@Override
public Kind getKind() {
throw new UnsupportedOperationException();
}
@Override
public <R, D> R accept(TreeVisitor<R, D> treeVisitor, D d) {
throw new UnsupportedOperationException();
}
@Override
public int getStartPosition() {
return endPos;
}
@Override
public int getEndPosition(EndPosTable endPosTable) {
return endPos;
}
};
}
示例8: getMap
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static Map<JCTree, Integer> getMap(EndPosTable table) {
try {
return (Map<JCTree, Integer>) END_POS_MAP_FIELD.get(table);
} catch (Exception e) {
throw new LinkageError(e.getMessage());
}
}
示例9: fromCompilationUnit
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
public static EndPosMap8 fromCompilationUnit(JCCompilationUnit compilationUnit) {
EndPosTable table = compilationUnit.endPositions;
if (Util.isEmptyEndPosTable(table)) {
return null;
}
if (Util.isSimpleEndPosTable(table)) {
return new EndPosMap8(table, Util.getMap(table));
}
throw new IllegalStateException();
}
示例10: replace
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的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);
}
示例11: CRTable
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
/** Constructor
*/
public CRTable(JCTree.JCMethodDecl tree, EndPosTable endPosTable) {
this.methodTree = tree;
this.endPosTable = endPosTable;
}
示例12: getEndPosition
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
@Override
public int getEndPosition(EndPosTable endPosTable) {
Assert.error();
return -1;
}
示例13: getEndPosition
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
public int getEndPosition(EndPosTable endPosTable) {
return pos;
}
示例14: getEndPosTable
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
public EndPosTable getEndPosTable() {
return endPosTable;
}
示例15: setEndPosTable
import com.sun.tools.javac.tree.EndPosTable; //导入依赖的package包/类
public void setEndPosTable(EndPosTable t) {
if (endPosTable != null && endPosTable != t)
throw new IllegalStateException("endPosTable already set");
endPosTable = t;
}