1313import { prepareExecutable } from './javaServerStarter' ;
1414import { LanguageClientOptions , RevealOutputChannelOn , LanguageClient , DidChangeConfigurationNotification , RequestType , TextDocumentPositionParams , ReferencesRequest } from 'vscode-languageclient' ;
1515import * 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" ;
1717import * as path from 'path' ;
1818import * as os from 'os' ;
1919import { activateTagClosing , AutoCloseResult } from './tagClosing' ;
2020import { Commands } from './commands' ;
2121import { onConfigurationChange , subscribeJDKChangeConfiguration } from './settings' ;
2222import { collectXmlJavaExtensions , onExtensionChange } from './plugin' ;
23- import { activateMirrorCursor } from './mirrorCursor' ;
2423
2524export interface ScopeInfo {
26- scope : "default" | "global" | "workspace" | "folder" ;
25+ scope : "default" | "global" | "workspace" | "folder" ;
2726 configurationTarget : boolean ;
2827}
2928
3029namespace TagCloseRequest {
3130 export const type : RequestType < TextDocumentPositionParams , AutoCloseResult , any , any > = new RequestType ( 'xml/closeTag' ) ;
3231}
3332
34- namespace MatchingTagPositionRequest {
35- export const type : RequestType < TextDocumentPositionParams , Position | null , any , any > = new RequestType ( 'xml/matchingTagPosition' ) ;
36- }
33+
3734
3835export function activate ( context : ExtensionContext ) {
3936 let storagePath = context . storagePath ;
@@ -73,7 +70,7 @@ export function activate(context: ExtensionContext) {
7370 }
7471 }
7572 }
76- } ,
73+ } ,
7774 synchronize : {
7875 //preferences starting with these will trigger didChangeConfiguration
7976 configurationSection : [ 'xml' , '[xml]' ]
@@ -117,38 +114,14 @@ export function activate(context: ExtensionContext) {
117114 return text ;
118115 } ;
119116
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-
147117 if ( extensions . onDidChange ) { // Theia doesn't support this API yet
148118 extensions . onDidChange ( ( ) => {
149119 onExtensionChange ( extensions . all ) ;
150120 } ) ;
151121 }
122+
123+ disposable = activateTagClosing ( tagProvider , { xml : true , xsl : true } , Commands . AUTO_CLOSE_TAGS ) ;
124+ toDispose . push ( disposable ) ;
152125 } ) ;
153126 languages . setLanguageConfiguration ( 'xml' , getIndentationRules ( ) ) ;
154127 languages . setLanguageConfiguration ( 'xsl' , getIndentationRules ( ) ) ;
@@ -166,7 +139,7 @@ export function activate(context: ExtensionContext) {
166139 let configXML = workspace . getConfiguration ( ) . get ( 'xml' ) ;
167140 let xml ;
168141 if ( ! configXML ) { //Set default preferences if not provided
169- const defaultValue =
142+ const defaultValue =
170143 {
171144 xml : {
172145 trace : {
@@ -187,7 +160,7 @@ export function activate(context: ExtensionContext) {
187160 xml = defaultValue ;
188161 } else {
189162 let x = JSON . stringify ( configXML ) ; //configXML is not a JSON type
190- xml = { "xml" : JSON . parse ( x ) } ;
163+ xml = { "xml" : JSON . parse ( x ) } ;
191164 }
192165 xml [ 'xml' ] [ 'logs' ] [ 'file' ] = logfile ;
193166 xml [ 'xml' ] [ 'useCache' ] = true ;
@@ -198,7 +171,7 @@ export function activate(context: ExtensionContext) {
198171
199172function getIndentationRules ( ) : LanguageConfiguration {
200173 return {
201-
174+
202175 // indentationRules referenced from:
203176 // https://github.com/microsoft/vscode/blob/d00558037359acceea329e718036c19625f91a1a/extensions/html-language-features/client/src/htmlMain.ts#L114-L115
204177 indentationRules : {
@@ -219,24 +192,3 @@ function getIndentationRules(): LanguageConfiguration {
219192 } ;
220193}
221194
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