10
10
*/
11
11
package ts .eclipse .ide .ui .hover ;
12
12
13
+ import org .eclipse .core .resources .IFile ;
14
+ import org .eclipse .jface .text .IDocument ;
13
15
import org .eclipse .jface .text .ITextViewer ;
14
16
import org .eclipse .jface .text .Position ;
15
17
import org .eclipse .jface .text .contentassist .ICompletionProposal ;
16
18
import org .eclipse .jface .text .source .Annotation ;
17
19
20
+ import ts .client .CommandNames ;
21
+ import ts .client .codefixes .ITypeScriptGetCodeFixesCollector ;
22
+ import ts .eclipse .ide .core .resources .IIDETypeScriptProject ;
23
+ import ts .eclipse .ide .core .utils .TypeScriptResourceUtil ;
24
+ import ts .resources .ITypeScriptFile ;
25
+
18
26
/**
19
27
* Problem Hover used to display errors when mouse over a JS content which have
20
28
* a tern error.
@@ -29,6 +37,26 @@ protected static class ProblemInfo extends AnnotationInfo {
29
37
public ProblemInfo (Annotation annotation , Position position , ITextViewer textViewer ) {
30
38
super (annotation , position , textViewer );
31
39
}
40
+
41
+ @ Override
42
+ public ICompletionProposal [] getCompletionProposals () {
43
+ IDocument document = viewer .getDocument ();
44
+ IFile file = TypeScriptResourceUtil .getFile (document );
45
+ try {
46
+ IIDETypeScriptProject tsProject = TypeScriptResourceUtil .getTypeScriptProject (file .getProject ());
47
+ if (tsProject .canSupport (CommandNames .GetCodeFixes )) {
48
+ // Get code fixes with TypeScript 2.1.1
49
+ ITypeScriptFile tsFile = tsProject .openFile (file , document );
50
+ tsFile .getCodeFixes (position .getOffset (), position .getOffset () + position .getLength (),
51
+ new ITypeScriptGetCodeFixesCollector () {
52
+ });
53
+ }
54
+ } catch (Exception e ) {
55
+ e .printStackTrace ();
56
+ }
57
+ return NO_PROPOSALS ;
58
+ }
59
+
32
60
}
33
61
34
62
public ProblemTypeScriptHover () {
0 commit comments