@@ -40,6 +40,10 @@ public class ProblemTypeScriptHover extends AbstractAnnotationHover {
40
40
41
41
protected static class ProblemInfo extends AnnotationInfo {
42
42
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
+
43
47
private static final ICompletionProposal [] NO_PROPOSALS = new ICompletionProposal [0 ];
44
48
45
49
public ProblemInfo (Annotation annotation , Position position , ITextViewer textViewer ) {
@@ -77,8 +81,10 @@ public ICompletionProposal[] getCompletionProposals() {
77
81
private List <Integer > createErrorCodes (ITypeScriptProject tsProject ) {
78
82
List <Integer > errorCodes = null ;
79
83
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 );
82
88
Integer tsCode = (Integer ) getAttributes .get ("tsCode" );
83
89
if (tsCode != null ) {
84
90
Integer errorCode = tsCode ;
@@ -89,11 +95,14 @@ private List<Integer> createErrorCodes(ITypeScriptProject tsProject) {
89
95
errorCodes .add (errorCode );
90
96
}
91
97
}
98
+ } catch (NoSuchMethodException e ) {
99
+ // The annotation is not a
100
+ // org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation
101
+ // ignore the error.
92
102
} catch (Throwable e ) {
93
103
TypeScriptUIPlugin .log ("Error while getting TypeScript error code" , e );
94
104
}
95
105
return errorCodes ;
96
-
97
106
}
98
107
}
99
108
0 commit comments