Skip to content

Commit f3548ba

Browse files
committed
Check if annotation is a SSE TemporaryAnnotation.
1 parent 3804165 commit f3548ba

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/hover/ProblemTypeScriptHover.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public class ProblemTypeScriptHover extends AbstractAnnotationHover {
4040

4141
protected static class ProblemInfo extends AnnotationInfo {
4242

43+
private static final Class<?>[] EMPTY_CLASS = new Class[0];
44+
private static final Object[] EMPTY_OBJECT = new Object[0];
45+
private static final String GET_ATTRIBUTES_METHOD_NAME = "getAttributes";
46+
4347
private static final ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0];
4448

4549
public ProblemInfo(Annotation annotation, Position position, ITextViewer textViewer) {
@@ -77,8 +81,10 @@ public ICompletionProposal[] getCompletionProposals() {
7781
private List<Integer> createErrorCodes(ITypeScriptProject tsProject) {
7882
List<Integer> errorCodes = null;
7983
try {
80-
Method getAttributesMethod = annotation.getClass().getMethod("getAttributes", new Class[0]);
81-
Map getAttributes = (Map) getAttributesMethod.invoke(annotation, new Object[0]);
84+
// Try to retrieve the TypeScript error code from the SSE
85+
// TemporaryAnnotation.
86+
Method getAttributesMethod = annotation.getClass().getMethod(GET_ATTRIBUTES_METHOD_NAME, EMPTY_CLASS);
87+
Map getAttributes = (Map) getAttributesMethod.invoke(annotation, EMPTY_OBJECT);
8288
Integer tsCode = (Integer) getAttributes.get("tsCode");
8389
if (tsCode != null) {
8490
Integer errorCode = tsCode;
@@ -89,11 +95,14 @@ private List<Integer> createErrorCodes(ITypeScriptProject tsProject) {
8995
errorCodes.add(errorCode);
9096
}
9197
}
98+
} catch (NoSuchMethodException e) {
99+
// The annotation is not a
100+
// org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation
101+
// ignore the error.
92102
} catch (Throwable e) {
93103
TypeScriptUIPlugin.log("Error while getting TypeScript error code", e);
94104
}
95105
return errorCodes;
96-
97106
}
98107
}
99108

0 commit comments

Comments
 (0)