Skip to content

Commit 10f72c4

Browse files
committed
Couple of fixes
Signed-off-by: Juan Manuel Leflet Estrada <[email protected]>
1 parent aae9aae commit 10f72c4

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,32 @@ public List<SymbolInformation> get(SearchMatch match) throws CoreException {
5656
unit = cls.getWorkingCopy(new WorkingCopyOwnerImpl(), null);
5757
}
5858
}
59-
IType t = unit.getType(annotationElement.getElementName());
60-
String fqdn = "";
61-
if (!t.isResolved()) {
62-
var elements = unit.codeSelect(match.getOffset(), match.getLength());
63-
for (IJavaElement e: Arrays.asList(elements)) {
64-
if (e instanceof IType) {
65-
var newT = (IType) e;
66-
if (newT.isResolved()) {
67-
fqdn = newT.getFullyQualifiedName('.');
68-
logInfo("FQDN from code select: " + fqdn);
59+
if (unit != null) {
60+
IType t = unit.getType(annotationElement.getElementName());
61+
String fqdn = "";
62+
if (!t.isResolved()) {
63+
var elements = unit.codeSelect(match.getOffset(), match.getLength());
64+
for (IJavaElement e: Arrays.asList(elements)) {
65+
if (e instanceof IType) {
66+
var newT = (IType) e;
67+
if (newT.isResolved()) {
68+
fqdn = newT.getFullyQualifiedName('.');
69+
logInfo("FQDN from code select: " + fqdn);
70+
}
6971
}
7072
}
73+
} else {
74+
fqdn = t.getFullyQualifiedName('.');
75+
logInfo("resolved type: " + fqdn);
76+
}
77+
if (query.matches(fqdn) || fqdn.matches(query)) {
78+
if (unit.isWorkingCopy()) {
79+
unit.discardWorkingCopy();
80+
unit.close();
81+
}
82+
symbols.add(symbol);
83+
return symbols;
7184
}
72-
} else {
73-
fqdn = t.getFullyQualifiedName('.');
74-
logInfo("resolved type: " + fqdn);
75-
}
76-
if (query.matches(fqdn)) {
77-
symbols.add(symbol);
78-
return symbols;
79-
}
80-
if (fqdn.matches(query)) {
81-
symbols.add(symbol);
82-
return symbols;
8385
}
8486

8587
logInfo("falling back to resolving via AST");

0 commit comments

Comments
 (0)