8383920: Clean up calls to deprecated getStartPosition and getEndPosition methods

Reviewed-by: liach, vromero
This commit is contained in:
Liam Miller-Cushon 2026-07-27 20:31:21 +00:00
parent 79d629abf6
commit b4d1d7e40c
6 changed files with 12 additions and 16 deletions

View File

@ -12,14 +12,10 @@ import com.sun.tools.javac.util.DefinedBy.Api;
public class Test implements SourcePositions, TaskListener {
@Override @DefinedBy(Api.COMPILER_TREE)
public long getStartPosition(CompilationUnitTree file, Tree tree) {
public long getStartPosition(Tree tree) {
return 0;
}
@Override
public long getEndPosition(CompilationUnitTree file, Tree tree) {
return 0;
}
@DefinedBy(Api.COMPILER_TREE)
@Override @DefinedBy(Api.COMPILER_TREE)
public long getEndPosition(Tree tree) {
return 0;
}

View File

@ -225,8 +225,8 @@ public class Test {
}
void checkEndPos(CompilationUnitTree unit, Tree tree) {
long sp = srcPosns.getStartPosition(unit, tree);
long ep = srcPosns.getEndPosition(unit, tree);
long sp = srcPosns.getStartPosition(tree);
long ep = srcPosns.getEndPosition(tree);
if (sp >= 0 && ep == Position.NOPOS) {
error("endpos not set for " + tree.getKind()
+ " " + Pretty.toSimpleString(((JCTree) tree))

View File

@ -81,8 +81,8 @@ public class T6412669 extends AbstractProcessor {
for (Element e: roundEnv.getElementsAnnotatedWith(anno)) {
m.printNote(" processing element " + e);
TreePath p = trees.getPath(e);
long start = sp.getStartPosition(p.getCompilationUnit(), p.getLeaf());
long end = sp.getEndPosition(p.getCompilationUnit(), p.getLeaf());
long start = sp.getStartPosition(p.getLeaf());
long end = sp.getEndPosition(p.getLeaf());
Diagnostic.Kind k = (start > 0 && end > 0 && start < end
? Diagnostic.Kind.NOTE : Diagnostic.Kind.ERROR);
m.printMessage(k, "test [" + start + "," + end + "]", e);

View File

@ -78,8 +78,8 @@ public class TestPosition extends AbstractProcessor {
@Override public Void scan(DocTree node, Void p) {
if (node != null) {
DocSourcePositions sp = trees.getSourcePositions();
int start = (int) sp.getStartPosition(testElement.getCompilationUnit(), docCommentTree, node);
int end = (int) sp.getEndPosition(testElement.getCompilationUnit(), docCommentTree, node);
int start = (int) sp.getStartPosition(docCommentTree, node);
int end = (int) sp.getEndPosition(docCommentTree, node);
String snippet = code.substring(start, end).replace(" \n", "!trailing-whitespace!\n");
if (snippet.endsWith(" ")) {

View File

@ -83,8 +83,8 @@ public class PatternMatchPosTest extends AbstractProcessor {
if (tree == null)
return null;
if (print) {
int start = (int) sp.getStartPosition(dataPath.getCompilationUnit(), tree);
int end = (int) sp.getEndPosition(dataPath.getCompilationUnit(), tree);
int start = (int) sp.getStartPosition(tree);
int end = (int) sp.getEndPosition(tree);
if (start != (-1) || end != (-1)) {
processingEnv.getMessager().printNote(text.substring(start, end));
}

View File

@ -159,13 +159,13 @@ public class TreePosRoundsTest extends AbstractProcessor {
}
//System.err.println("expect: " + expect);
int start = (int)sourcePositions.getStartPosition(unit, tree);
int start = (int)sourcePositions.getStartPosition(tree);
if (start == Diagnostic.NOPOS) {
messager.printError("start pos not set for " + trim(tree));
return;
}
int end = (int)sourcePositions.getEndPosition(unit, tree);
int end = (int)sourcePositions.getEndPosition(tree);
if (end == Diagnostic.NOPOS) {
messager.printError("end pos not set for " + trim(tree));
return;