@@ -13,6 +13,7 @@ import { ClientCommandConstants, ServerCommandConstants } from "./commandConstan
1313export function registerClientOnlyCommands ( context : ExtensionContext ) {
1414 registerDocsCommands ( context ) ;
1515 registerOpenSettingsCommand ( context ) ;
16+ registerOpenUriCommand ( context ) ;
1617}
1718
1819/**
@@ -41,7 +42,8 @@ export async function registerClientServerCommands(context: ExtensionContext, la
4142 } ;
4243 if ( token ) {
4344 return languageClient . sendRequest ( ExecuteCommandRequest . type , params , token ) ;
44- } else {
45+ }
46+ else {
4547 return languageClient . sendRequest ( ExecuteCommandRequest . type , params ) ;
4648 }
4749 } ) ) ;
@@ -81,6 +83,17 @@ function registerOpenSettingsCommand(context: ExtensionContext) {
8183 } ) ) ;
8284}
8385
86+ /**
87+ * Registers a command that opens the settings page to a given setting
88+ *
89+ * @param context the extension context
90+ */
91+ function registerOpenUriCommand ( context : ExtensionContext ) {
92+ context . subscriptions . push ( commands . registerCommand ( ClientCommandConstants . OPEN_URI , async ( uri ?: string ) => {
93+ commands . executeCommand ( 'vscode.open' , Uri . parse ( uri ) ) ;
94+ } ) ) ;
95+ }
96+
8497/**
8598 * Register commands used for code lens "references"
8699 *
@@ -144,12 +157,12 @@ for (const label of bindingTypes.keys()) {
144157 * @param uri the uri of the XML file path
145158 * @param languageClient the language server client
146159 */
147- async function grammarAssociationCommand ( documentURI : Uri , languageClient : LanguageClient ) {
160+ async function grammarAssociationCommand ( documentURI : Uri , languageClient : LanguageClient ) {
148161 // A click on Bind to grammar/schema... has been processed in the XML document which is not bound to a grammar
149162
150163 // Step 1 : open a combo to select the binding type ("standard", "xml-model")
151164 const pickedBindingTypeOption = await window . showQuickPick ( bindingTypeOptions , { placeHolder : "Binding type" } ) ;
152- if ( ! pickedBindingTypeOption ) {
165+ if ( ! pickedBindingTypeOption ) {
153166 return ;
154167 }
155168 const bindingType = bindingTypes . get ( pickedBindingTypeOption . label ) ;
@@ -190,7 +203,7 @@ async function grammarAssociationCommand (documentURI: Uri, languageClient: Lang
190203 * @param context the extension context
191204 * @param languageClient the language server client
192205 */
193- function registerAssociationCommands ( context : ExtensionContext , languageClient : LanguageClient ) {
206+ function registerAssociationCommands ( context : ExtensionContext , languageClient : LanguageClient ) {
194207 // For CodeLens
195208 context . subscriptions . push ( commands . registerCommand ( ClientCommandConstants . OPEN_BINDING_WIZARD , async ( uriString : string ) => {
196209 const uri = Uri . parse ( uriString ) ;
@@ -208,25 +221,25 @@ async function grammarAssociationCommand (documentURI: Uri, languageClient: Lang
208221 }
209222 } ) ) ;
210223
211- }
212-
213- /**
214- * Change value of 'canBindGrammar' to determine if grammar/schema can be bound
215- *
216- * @param document the text document
217- * @returns the `hasGrammar` check result from server
218- */
219- async function checkCanBindGrammar ( documentURI : Uri ) {
220- // Retrieve the document uri and identifier
221- const identifier = TextDocumentIdentifier . create ( documentURI . toString ( ) ) ;
222-
223- // Set the custom condition to watch if file already has bound grammar
224- var result = false ;
225- try {
226- result = await commands . executeCommand ( ServerCommandConstants . CHECK_BOUND_GRAMMAR , identifier ) ;
227- } catch ( error ) {
228- console . log ( `Error while checking bound grammar : ${ error } ` ) ;
229- }
230-
231- return result
232- }
224+ }
225+
226+ /**
227+ * Change value of 'canBindGrammar' to determine if grammar/schema can be bound
228+ *
229+ * @param document the text document
230+ * @returns the `hasGrammar` check result from server
231+ */
232+ async function checkCanBindGrammar ( documentURI : Uri ) {
233+ // Retrieve the document uri and identifier
234+ const identifier = TextDocumentIdentifier . create ( documentURI . toString ( ) ) ;
235+
236+ // Set the custom condition to watch if file already has bound grammar
237+ var result = false ;
238+ try {
239+ result = await commands . executeCommand ( ServerCommandConstants . CHECK_BOUND_GRAMMAR , identifier ) ;
240+ } catch ( error ) {
241+ console . log ( `Error while checking bound grammar : ${ error } ` ) ;
242+ }
243+
244+ return result
245+ }
0 commit comments