13
13
import { prepareExecutable } from './javaServerStarter' ;
14
14
import { LanguageClientOptions , RevealOutputChannelOn , LanguageClient , DidChangeConfigurationNotification , RequestType , TextDocumentPositionParams , ReferencesRequest } from 'vscode-languageclient' ;
15
15
import * as requirements from './requirements' ;
16
- import { languages , ConfigurationTarget , IndentAction , workspace , window , commands , ExtensionContext , TextDocument , Position , LanguageConfiguration , Uri , WorkspaceConfiguration , extensions } from "vscode" ;
16
+ import { languages , IndentAction , workspace , window , commands , ExtensionContext , TextDocument , Position , LanguageConfiguration , Uri , extensions } from "vscode" ;
17
17
import * as path from 'path' ;
18
18
import * as os from 'os' ;
19
19
import { activateTagClosing , AutoCloseResult } from './tagClosing' ;
20
20
import { Commands } from './commands' ;
21
21
import { onConfigurationChange , subscribeJDKChangeConfiguration } from './settings' ;
22
22
import { collectXmlJavaExtensions , onExtensionChange } from './plugin' ;
23
- import { activateMirrorCursor } from './mirrorCursor' ;
24
23
25
24
export interface ScopeInfo {
26
- scope : "default" | "global" | "workspace" | "folder" ;
25
+ scope : "default" | "global" | "workspace" | "folder" ;
27
26
configurationTarget : boolean ;
28
27
}
29
28
30
29
namespace TagCloseRequest {
31
30
export const type : RequestType < TextDocumentPositionParams , AutoCloseResult , any , any > = new RequestType ( 'xml/closeTag' ) ;
32
31
}
33
32
34
- namespace MatchingTagPositionRequest {
35
- export const type : RequestType < TextDocumentPositionParams , Position | null , any , any > = new RequestType ( 'xml/matchingTagPosition' ) ;
36
- }
33
+
37
34
38
35
export function activate ( context : ExtensionContext ) {
39
36
let storagePath = context . storagePath ;
@@ -73,7 +70,7 @@ export function activate(context: ExtensionContext) {
73
70
}
74
71
}
75
72
}
76
- } ,
73
+ } ,
77
74
synchronize : {
78
75
//preferences starting with these will trigger didChangeConfiguration
79
76
configurationSection : [ 'xml' , '[xml]' ]
@@ -117,38 +114,14 @@ export function activate(context: ExtensionContext) {
117
114
return text ;
118
115
} ;
119
116
120
- disposable = activateTagClosing ( tagProvider , { xml : true , xsl : true } , Commands . AUTO_CLOSE_TAGS ) ;
121
- toDispose . push ( disposable ) ;
122
-
123
- //Setup mirrored tag rename request
124
- const matchingTagPositionRequestor = ( document : TextDocument , position : Position ) => {
125
- let param = languageClient . code2ProtocolConverter . asTextDocumentPositionParams ( document , position ) ;
126
- return languageClient . sendRequest ( MatchingTagPositionRequest . type , param ) ;
127
- } ;
128
-
129
- disposable = activateMirrorCursor ( context , matchingTagPositionRequestor , { xml : true } , 'xml.mirrorCursorOnMatchingTag' ) ;
130
- toDispose . push ( disposable ) ;
131
-
132
- const matchingTagEditCommand = 'xml.toggleMatchingTagEdit' ;
133
-
134
- const matchingTagEditHandler = async ( ) => {
135
- let xmlConfiguration : WorkspaceConfiguration ;
136
- if ( window . activeTextEditor ) {
137
- xmlConfiguration = workspace . getConfiguration ( 'xml' , window . activeTextEditor . document . uri ) ;
138
- } else {
139
- xmlConfiguration = workspace . getConfiguration ( 'xml' ) ;
140
- }
141
- const current = xmlConfiguration . mirrorCursorOnMatchingTag ;
142
- await updateConfig ( xmlConfiguration , 'mirrorCursorOnMatchingTag' , ! current ) ;
143
- }
144
-
145
- toDispose . push ( commands . registerCommand ( matchingTagEditCommand , matchingTagEditHandler ) ) ;
146
-
147
117
if ( extensions . onDidChange ) { // Theia doesn't support this API yet
148
118
extensions . onDidChange ( ( ) => {
149
119
onExtensionChange ( extensions . all ) ;
150
120
} ) ;
151
121
}
122
+
123
+ disposable = activateTagClosing ( tagProvider , { xml : true , xsl : true } , Commands . AUTO_CLOSE_TAGS ) ;
124
+ toDispose . push ( disposable ) ;
152
125
} ) ;
153
126
languages . setLanguageConfiguration ( 'xml' , getIndentationRules ( ) ) ;
154
127
languages . setLanguageConfiguration ( 'xsl' , getIndentationRules ( ) ) ;
@@ -166,7 +139,7 @@ export function activate(context: ExtensionContext) {
166
139
let configXML = workspace . getConfiguration ( ) . get ( 'xml' ) ;
167
140
let xml ;
168
141
if ( ! configXML ) { //Set default preferences if not provided
169
- const defaultValue =
142
+ const defaultValue =
170
143
{
171
144
xml : {
172
145
trace : {
@@ -187,7 +160,7 @@ export function activate(context: ExtensionContext) {
187
160
xml = defaultValue ;
188
161
} else {
189
162
let x = JSON . stringify ( configXML ) ; //configXML is not a JSON type
190
- xml = { "xml" : JSON . parse ( x ) } ;
163
+ xml = { "xml" : JSON . parse ( x ) } ;
191
164
}
192
165
xml [ 'xml' ] [ 'logs' ] [ 'file' ] = logfile ;
193
166
xml [ 'xml' ] [ 'useCache' ] = true ;
@@ -198,7 +171,7 @@ export function activate(context: ExtensionContext) {
198
171
199
172
function getIndentationRules ( ) : LanguageConfiguration {
200
173
return {
201
-
174
+
202
175
// indentationRules referenced from:
203
176
// https://github.com/microsoft/vscode/blob/d00558037359acceea329e718036c19625f91a1a/extensions/html-language-features/client/src/htmlMain.ts#L114-L115
204
177
indentationRules : {
@@ -219,24 +192,3 @@ function getIndentationRules(): LanguageConfiguration {
219
192
} ;
220
193
}
221
194
222
- /**
223
- * Update config with the following precedence: WorkspaceFolder -> Workspace -> Global
224
- * @param config config containing the section to update
225
- * @param section section to update
226
- * @param value new value
227
- */
228
- async function updateConfig ( config : WorkspaceConfiguration , section : string , value : any ) : Promise < void > {
229
- try {
230
- await config . update ( section , value ) ;
231
- return ;
232
- } catch ( e ) {
233
- // try ConfigurationTarget.Global
234
- }
235
-
236
- try {
237
- await config . update ( section , value , ConfigurationTarget . Global ) ;
238
- return ;
239
- } catch ( e ) {
240
- throw 'Failed to update config' ;
241
- }
242
- }
0 commit comments