Skip to content

Commit b0be54c

Browse files
author
Alexander Chen
committed
combined grammar association wrappers
1 parent 5c5d151 commit b0be54c

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,10 @@
526526
"category": "XML"
527527
},
528528
{
529-
"command": "xml.command.bind.grammar",
529+
"command": "xml.open.binding.wizard",
530530
"title": "Bind to grammar/schema file",
531-
"category": "XML"
531+
"category": "XML",
532+
"when": "editorLangId == xml && editorIsOpen"
532533
}
533534
],
534535
"menus": {

src/commands/commandConstants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ export namespace ClientCommandConstants {
6262
* Client command to execute an XML command on XML Language Server side.
6363
*/
6464
export const EXECUTE_WORKSPACE_COMMAND = 'xml.workspace.executeCommand';
65-
66-
export const COMMAND_PALETTE_BINDING_WIZARD = 'xml.command.bind.grammar';
6765
}
6866

6967
/**

src/commands/registerCommands.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export async function registerClientServerCommands(context: ExtensionContext, la
2525

2626
registerCodeLensReferencesCommands(context, languageClient);
2727
registerValidationCommands(context);
28-
registerCodeLensAssociationCommands(context, languageClient);
2928
registerAssociationCommands(context, languageClient);
3029

3130
// Register client command to execute custom XML Language Server command
@@ -186,30 +185,14 @@ async function grammarAssociationCommand (uriString: string, languageClient: Lan
186185
}
187186

188187
/**
189-
* Register commands used for associating grammar file (XSD,DTD) to a given XML file with CodeLens
190-
*
191-
* @param context the extension context
192-
* @param languageClient the language server client
193-
*/
194-
function registerCodeLensAssociationCommands(context: ExtensionContext, languageClient: LanguageClient) {
195-
context.subscriptions.push(commands.registerCommand(ClientCommandConstants.OPEN_BINDING_WIZARD, async (uriString: string) => {
196-
grammarAssociationCommand(uriString, languageClient)
197-
}));
198-
}
199-
200-
/**
201-
* Register commands used for associating grammar file (XSD,DTD) to a given XML file
188+
* Register commands used for associating grammar file (XSD,DTD) to a given XML file for command menu and CodeLens.
202189
*
203190
* @param context the extension context
204191
* @param languageClient the language server client
205192
*/
206193
function registerAssociationCommands(context: ExtensionContext, languageClient: LanguageClient) {
207-
context.subscriptions.push(commands.registerCommand(ClientCommandConstants.COMMAND_PALETTE_BINDING_WIZARD, async () => {
208-
// const uriFolder = workspace.workspaceFolders[0].uri.path;
209-
// const uriFile = workspace.workspaceFolders[0].uri.fsPath;
194+
context.subscriptions.push(commands.registerCommand(ClientCommandConstants.OPEN_BINDING_WIZARD, async () => {
210195
const uriString = window.activeTextEditor.document.fileName;
211-
// const uriString = uriFolder + uriFile;
212-
// const uriString = workspace.workspaceFile.toString();
213196
grammarAssociationCommand(uriString, languageClient)
214197
}));
215198
}

0 commit comments

Comments
 (0)