1313import { prepareExecutable } from './javaServerStarter' ;
1414import { LanguageClientOptions , RevealOutputChannelOn , LanguageClient , DidChangeConfigurationNotification , RequestType , TextDocumentPositionParams } from 'vscode-languageclient' ;
1515import * as requirements from './requirements' ;
16- import { languages , IndentAction , workspace , window , commands , ExtensionContext , TextDocument , Position , WorkspaceConfiguration } from "vscode" ;
16+ import { languages , IndentAction , workspace , window , commands , ExtensionContext , TextDocument , Position , WorkspaceConfiguration , LanguageConfiguration } from "vscode" ;
1717import * as path from 'path' ;
1818import * as os from 'os' ;
1919import { activateTagClosing } from './tagClosing' ;
@@ -40,8 +40,8 @@ export function activate(context: ExtensionContext) {
4040 throw error ;
4141 } ) . then ( requirements => {
4242 let clientOptions : LanguageClientOptions = {
43- // Register the server for java
44- documentSelector : [ 'xml' ] ,
43+ // Register the server for xml and xsl
44+ documentSelector : [ 'xml' , 'xsl' ] ,
4545 revealOutputChannelOn : RevealOutputChannelOn . Never ,
4646 initializationOptions : { settings : getSettings ( ) } ,
4747 synchronize : {
@@ -66,24 +66,11 @@ export function activate(context: ExtensionContext) {
6666 return languageClient . sendRequest ( TagCloseRequest . type , param ) ;
6767 } ;
6868
69- disposable = activateTagClosing ( tagRequestor , { xml : true } , 'xml.completion.autoCloseTags' ) ;
69+ disposable = activateTagClosing ( tagRequestor , { xml : true , xsl : true } , 'xml.completion.autoCloseTags' ) ;
7070 toDispose . push ( disposable ) ;
7171 } ) ;
72- languages . setLanguageConfiguration ( 'xml' , {
73- onEnterRules : [
74- {
75- beforeText : new RegExp ( `<([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$` , 'i' ) ,
76- afterText : / ^ < \/ ( [ _ : \w ] [ _ : \w - . \d ] * ) \s * > / i,
77- action : { indentAction : IndentAction . IndentOutdent }
78- } ,
79- {
80- beforeText : new RegExp ( `<(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$` , 'i' ) ,
81- action : { indentAction : IndentAction . Indent }
82- }
83- ] ,
84- } ) ;
85-
86-
72+ languages . setLanguageConfiguration ( 'xml' , getIndentationRules ( ) ) ;
73+ languages . setLanguageConfiguration ( 'xsl' , getIndentationRules ( ) ) ;
8774 } ) ;
8875
8976 function getSettings ( ) : JSON {
@@ -100,3 +87,19 @@ export function activate(context: ExtensionContext) {
10087
10188
10289}
90+ function getIndentationRules ( ) : LanguageConfiguration {
91+ return {
92+ onEnterRules : [
93+ {
94+ beforeText : new RegExp ( `<([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$` , 'i' ) ,
95+ afterText : / ^ < \/ ( [ _ : \w ] [ _ : \w - . \d ] * ) \s * > / i,
96+ action : { indentAction : IndentAction . IndentOutdent }
97+ } ,
98+ {
99+ beforeText : new RegExp ( `<(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$` , 'i' ) ,
100+ action : { indentAction : IndentAction . Indent }
101+ }
102+ ] ,
103+ } ;
104+ }
105+
0 commit comments