5
5
import java .io .InputStreamReader ;
6
6
import java .net .URL ;
7
7
8
+ import org .eclipse .core .resources .IFile ;
8
9
import org .eclipse .core .runtime .Platform ;
9
10
import org .eclipse .jface .internal .text .html .HTMLPrinter ;
10
11
import org .eclipse .jface .resource .ImageDescriptor ;
11
12
import org .eclipse .jface .resource .JFaceResources ;
12
13
import org .eclipse .swt .graphics .FontData ;
13
14
import org .eclipse .swt .graphics .RGB ;
15
+ import org .eclipse .tm4e .markdown .TMHTMLRenderer ;
16
+ import org .eclipse .tm4e .markdown .marked .HTMLRenderer ;
17
+ import org .eclipse .tm4e .markdown .marked .IRenderer ;
18
+ import org .eclipse .tm4e .markdown .marked .Marked ;
19
+ import org .eclipse .tm4e .ui .TMUIPlugin ;
20
+ import org .eclipse .tm4e .ui .themes .ITheme ;
14
21
import org .osgi .framework .Bundle ;
15
22
16
23
import ts .eclipse .ide .internal .ui .TypeScriptUIMessages ;
@@ -37,23 +44,34 @@ public static void setColorInfoForeground(RGB colorInfoForeground) {
37
44
HTMLTypeScriptPrinter .colorInfoForeground = colorInfoForeground ;
38
45
}
39
46
40
- public static String getQuickInfo (String kind , String kindModifiers , String displayString , String documentation ) {
47
+ public static String getQuickInfo (String kind , String kindModifiers , String displayString , String documentation ,
48
+ IFile tsFile ) {
41
49
StringBuffer info = new StringBuffer ();
42
50
ImageDescriptor descriptor = null ; // TypeScriptImagesRegistry.getTypeScriptImageDescriptor(kind,
43
51
// kindModifiers, null);
44
52
startPage (info , null , descriptor );
45
53
if (!StringUtils .isEmpty (displayString )) {
46
- info .append ("<pre class=\" displayString\" >" );
47
- info .append (displayString );
48
- info .append ("</pre>" );
54
+ if (tsFile == null ) {
55
+ info .append ("<pre class=\" displayString\" >" );
56
+ info .append (displayString );
57
+ info .append ("</pre>" );
58
+ } else {
59
+ IRenderer renderer = createMarkdownRenderer (tsFile );
60
+ info .append (Marked .parse ("```ts\n " + displayString + "```" , renderer ));
61
+ }
49
62
}
50
63
if (!StringUtils .isEmpty (documentation )) {
51
- HTMLPrinter .addParagraph (info , documentation );
64
+ IRenderer renderer = createMarkdownRenderer (tsFile );
65
+ info .append (Marked .parse (documentation , renderer ));
52
66
}
53
67
endPage (info );
54
68
return info .toString ();
55
69
}
56
70
71
+ private static IRenderer createMarkdownRenderer (IFile file ) {
72
+ return file != null ? new TMHTMLRenderer (file .getFileExtension ()) : new HTMLRenderer ();
73
+ }
74
+
57
75
public static String getError (String message ) {
58
76
StringBuffer info = new StringBuffer ();
59
77
ImageDescriptor descriptor = null ;
@@ -66,8 +84,9 @@ public static String getError(String message) {
66
84
}
67
85
68
86
public static void endPage (StringBuffer buffer ) {
87
+ ITheme theme = TMUIPlugin .getThemeManager ().getDefaultTheme ();
69
88
HTMLPrinter .insertPageProlog (buffer , 0 , colorInfoForeground , colorInfoBackround ,
70
- HTMLTypeScriptPrinter .getStyleSheet ());
89
+ HTMLTypeScriptPrinter .getStyleSheet () + theme . toCSSStyleSheet () );
71
90
HTMLPrinter .addPageEpilog (buffer );
72
91
}
73
92
@@ -171,7 +190,8 @@ public static void startPage(StringBuffer buf, String title, ImageDescriptor des
171
190
// $NON-NLS-1$
172
191
// $NON-NLS-1$
173
192
// $NON-NLS-1$
174
- //$NON-NLS-1$ //$NON-NLS-3$
193
+ // $NON-NLS-1$
194
+ // //$NON-NLS-3$
175
195
buf .append ("<span " ).append (tooltip ).append ("style=\" " ).append (imageStyle ). //$NON-NLS-1$ //$NON-NLS-2$
176
196
append ("filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" ).append (imageSrcPath ) //$NON-NLS-1$
177
197
.append ("')\" ></span>\n " ); //$NON-NLS-1$
0 commit comments