@@ -19,33 +19,33 @@ export class TastyDecompilerProvider implements Disposable {
19
19
readonly documentSelector : vscode . DocumentSelector ,
20
20
readonly provider : DecompiledDocumentProvider ) {
21
21
this . disposables . push (
22
- vscode . workspace . onDidOpenTextDocument ( textDocument => {
22
+ vscode . workspace . onDidOpenTextDocument ( textDocument => {
23
23
if ( this . isTasty ( textDocument ) ) {
24
- this . requestDecompile ( textDocument ) . then ( decompileResult => {
25
- switch ( decompileResult . error ) {
24
+ this . requestDecompile ( textDocument ) . then ( decompileResult => {
25
+ switch ( decompileResult . error ) {
26
26
case RESULT_OK :
27
27
let scalaDocument = provider . makeScalaDocument ( textDocument , decompileResult . scala )
28
28
29
29
vscode . workspace . openTextDocument ( scalaDocument ) . then ( doc => {
30
30
vscode . window . showTextDocument ( doc , 1 )
31
- } ) ;
31
+ } )
32
32
33
33
let fileName = textDocument . fileName . substring ( textDocument . fileName . lastIndexOf ( path . sep ) + 1 )
34
34
35
35
TastyTreeView . create ( fileName , decompileResult . tastyTree )
36
- break ;
36
+ break
37
37
case ERROR_TASTY_VERSION :
38
38
vscode . window . showErrorMessage ( "Tasty file has unexpected signature." )
39
- break ;
39
+ break
40
40
case ERROR_CLASS_NOT_FOUND :
41
41
vscode . window . showErrorMessage ( "The class file related to this TASTy file could not be found." )
42
- break ;
42
+ break
43
43
case ERROR_OTHER :
44
44
vscode . window . showErrorMessage ( "A decompilation error has occurred." )
45
- break ;
45
+ break
46
46
default :
47
47
vscode . window . showErrorMessage ( "Unknown Error." )
48
- break ;
48
+ break
49
49
}
50
50
} )
51
51
}
@@ -54,8 +54,8 @@ export class TastyDecompilerProvider implements Disposable {
54
54
}
55
55
56
56
dispose ( ) : void {
57
- this . disposables . forEach ( d => d . dispose ( ) )
58
- this . disposables = [ ]
57
+ this . disposables . forEach ( d => d . dispose ( ) )
58
+ this . disposables = [ ]
59
59
}
60
60
61
61
/**
@@ -72,44 +72,43 @@ export class TastyDecompilerProvider implements Disposable {
72
72
title : "Decompiling"
73
73
} , ( ) => this . client . sendRequest ( TastyDecompileRequest . type , requestParams , token )
74
74
) )
75
- } ) . then ( decompileResult => {
76
- canceller . dispose ( )
77
- return decompileResult
78
- } ) ;
75
+ } ) . then ( decompileResult => {
76
+ canceller . dispose ( )
77
+ return decompileResult
78
+ } )
79
79
}
80
80
81
- /** Is this document a tasty file? */
82
- private isTasty ( document : vscode . TextDocument ) : boolean {
83
- return vscode . languages . match ( this . documentSelector , document ) > 0
84
- }
85
-
81
+ /** Is this document a tasty file? */
82
+ private isTasty ( document : vscode . TextDocument ) : boolean {
83
+ return vscode . languages . match ( this . documentSelector , document ) > 0
84
+ }
86
85
}
87
86
88
87
/**
89
88
* Provider of virtual, read-only, scala documents
90
89
*/
91
90
export class DecompiledDocumentProvider implements vscode . TextDocumentContentProvider {
92
- static scheme = 'decompiled' ;
91
+ static scheme = 'decompiled'
93
92
94
- private _documents = new Map < string , string > ( ) ;
95
- private _subscriptions : vscode . Disposable ;
93
+ private _documents = new Map < string , string > ( )
94
+ private _subscriptions : vscode . Disposable
96
95
97
96
constructor ( ) {
98
97
// Don't keep closed documents in memory
99
- this . _subscriptions = vscode . workspace . onDidCloseTextDocument ( doc => this . _documents . delete ( doc . uri . toString ( ) ) ) ;
98
+ this . _subscriptions = vscode . workspace . onDidCloseTextDocument ( doc => this . _documents . delete ( doc . uri . toString ( ) ) )
100
99
}
101
100
102
101
dispose ( ) {
103
- this . _subscriptions . dispose ( ) ;
104
- this . _documents . clear ( ) ;
102
+ this . _subscriptions . dispose ( )
103
+ this . _documents . clear ( )
105
104
}
106
105
107
- provideTextDocumentContent ( uri : vscode . Uri ) : string {
108
- let document = this . _documents . get ( uri . toString ( ) ) ;
109
- if ( document ) {
110
- return document ;
106
+ provideTextDocumentContent ( uri : vscode . Uri ) : string {
107
+ let document = this . _documents . get ( uri . toString ( ) )
108
+ if ( document ) {
109
+ return document
111
110
} else {
112
- return 'Failed to load result.' ;
111
+ return 'Failed to load result.'
113
112
}
114
113
}
115
114
@@ -119,70 +118,70 @@ export class DecompiledDocumentProvider implements vscode.TextDocumentContentPro
119
118
* @param textDocument The document containing the TASTy that was decompiled
120
119
* @param content The source code provided by the language server
121
120
*/
122
- makeScalaDocument ( textDocument : vscode . TextDocument , content : string ) : vscode . Uri {
121
+ makeScalaDocument ( textDocument : vscode . TextDocument , content : string ) : vscode . Uri {
123
122
let scalaDocument = textDocument . uri . with ( {
124
123
scheme : DecompiledDocumentProvider . scheme ,
125
- path : textDocument . uri . path . replace ( ".tasty" , ".scala" )
124
+ path : textDocument . uri . path . replace ( ".tasty" , ".scala" )
126
125
} )
127
- this . _documents . set ( scalaDocument . toString ( ) , content ) ;
128
- return scalaDocument ;
126
+ this . _documents . set ( scalaDocument . toString ( ) , content )
127
+ return scalaDocument
129
128
}
130
129
}
131
130
132
131
/**
133
132
* WebView used as container for preformatted TASTy trees
134
133
*/
135
134
class TastyTreeView {
136
- public static readonly viewType = 'tastyTree' ;
135
+ public static readonly viewType = 'tastyTree'
137
136
138
- private readonly _panel : vscode . WebviewPanel ;
139
- private _disposables : vscode . Disposable [ ] = [ ] ;
137
+ private readonly _panel : vscode . WebviewPanel
138
+ private _disposables : vscode . Disposable [ ] = [ ]
140
139
141
- /**
142
- * Create new panel for a TASTy tree in a new column or column 2 if none is currently open
143
- *
144
- * @param title The panel's title
145
- * @param content The panel's preformatted content
146
- */
147
- public static create ( title : string , content : string ) {
148
- const column = vscode . window . activeTextEditor ? vscode . window . activeTextEditor . viewColumn : undefined ;
140
+ /**
141
+ * Create new panel for a TASTy tree in a new column or column 2 if none is currently open
142
+ *
143
+ * @param title The panel's title
144
+ * @param content The panel's preformatted content
145
+ */
146
+ public static create ( title : string , content : string ) {
147
+ const column = vscode . window . activeTextEditor ? vscode . window . activeTextEditor . viewColumn : undefined
149
148
150
- const panel = vscode . window . createWebviewPanel ( TastyTreeView . viewType , "Tasty Tree" , ( column || vscode . ViewColumn . One ) + 1 , { } ) ;
149
+ const panel = vscode . window . createWebviewPanel ( TastyTreeView . viewType , "Tasty Tree" , ( column || vscode . ViewColumn . One ) + 1 , { } )
151
150
152
- new TastyTreeView ( panel , title , content ) ;
153
- }
151
+ new TastyTreeView ( panel , title , content )
152
+ }
154
153
155
- private constructor (
156
- panel : vscode . WebviewPanel ,
157
- title : string ,
158
- content : string
159
- ) {
160
- this . _panel = panel ;
161
- this . setContent ( title , content )
162
-
163
- // Listen for when the panel is disposed
164
- // This happens when the user closes the panel or when the panel is closed programmatically
165
- this . _panel . onDidDispose ( ( ) => this . dispose ( ) , null , this . _disposables ) ;
166
- }
154
+ private constructor (
155
+ panel : vscode . WebviewPanel ,
156
+ title : string ,
157
+ content : string
158
+ ) {
159
+ this . _panel = panel
160
+ this . setContent ( title , content )
161
+
162
+ // Listen for when the panel is disposed
163
+ // This happens when the user closes the panel or when the panel is closed programmatically
164
+ this . _panel . onDidDispose ( ( ) => this . dispose ( ) , null , this . _disposables )
165
+ }
167
166
168
- public dispose ( ) {
169
- this . _panel . dispose ( ) ;
167
+ public dispose ( ) {
168
+ this . _panel . dispose ( )
170
169
171
- while ( this . _disposables . length ) {
172
- const x = this . _disposables . pop ( ) ;
173
- if ( x ) {
174
- x . dispose ( ) ;
175
- }
176
- }
170
+ while ( this . _disposables . length ) {
171
+ const x = this . _disposables . pop ( )
172
+ if ( x ) {
173
+ x . dispose ( )
174
+ }
177
175
}
176
+ }
178
177
179
- private setContent ( name : string , content : string ) {
180
- this . _panel . title = name ;
181
- this . _panel . webview . html = this . _getHtmlForWebview ( content ) ;
182
- }
178
+ private setContent ( name : string , content : string ) {
179
+ this . _panel . title = name
180
+ this . _panel . webview . html = this . _getHtmlForWebview ( content )
181
+ }
183
182
184
- private _getHtmlForWebview ( content : string ) {
185
- return `<!DOCTYPE html>
183
+ private _getHtmlForWebview ( content : string ) {
184
+ return `<!DOCTYPE html>
186
185
<html lang="en">
187
186
<head>
188
187
<style>
@@ -207,6 +206,6 @@ class TastyTreeView {
207
206
<pre>
208
207
${ content } </pre>
209
208
</body>
210
- </html>` ;
211
- }
209
+ </html>`
210
+ }
212
211
}
0 commit comments