Skip to content

Commit 67a2fef

Browse files
committed
Fix and simplify getLocationForImport
Signed-off-by: Juan Manuel Leflet Estrada <[email protected]>
1 parent 4d2ae79 commit 67a2fef

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SampleDelegateCommandHandler.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,10 @@ private static List<SymbolInformation> search(String projectName, ArrayList<Stri
415415
}
416416

417417
public static Location getLocationForImport(ICompilationUnit icu, ImportDeclaration imp, CompilationUnit cuAst) {
418-
int start = imp.getStartPosition();
419-
int length = imp.getLength();
420-
int end = start + length;
421-
422-
int startLine = cuAst.getLineNumber(start) - 1; // LSP is 0-based
423-
int startCol = cuAst.getColumnNumber(start) - 1;
424-
int endLine = cuAst.getLineNumber(end) - 1;
425-
int endCol = cuAst.getColumnNumber(end) - 1;
426-
427-
}
428-
}
418+
try {
419+
return JDTUtils.toLocation(icu, imp.getStartPosition(), imp.getLength());
420+
} catch (Exception e) {
421+
logInfo("Unable to get location for import: " + e);
422+
return null;
423+
}
424+
}

0 commit comments

Comments
 (0)