Skip to content

Commit 5be19e2

Browse files
author
Alexander Chen
committed
combined grammar association wrappers
1 parent 1b540fe commit 5be19e2

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@
528528
{
529529
"command": "xml.command.bind.grammar",
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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,15 @@ export namespace ClientCommandConstants {
5858
*/
5959
export const OPEN_BINDING_WIZARD = 'xml.open.binding.wizard';
6060

61+
/**
62+
* VSCode client command to open the grammar/schema binding wizard from command menu.
63+
*/
64+
export const COMMAND_PALETTE_BINDING_WIZARD = 'xml.command.bind.grammar';
65+
6166
/**
6267
* Client command to execute an XML command on XML Language Server side.
6368
*/
6469
export const EXECUTE_WORKSPACE_COMMAND = 'xml.workspace.executeCommand';
65-
66-
export const COMMAND_PALETTE_BINDING_WIZARD = 'xml.command.bind.grammar';
6770
}
6871

6972
/**

src/commands/registerCommands.ts

Lines changed: 4 additions & 16 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,19 @@ 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
188+
* Register commands used for associating grammar file (XSD,DTD) to a given XML file for command menu and CodeLens
190189
*
191190
* @param context the extension context
192191
* @param languageClient the language server client
193192
*/
194-
function registerCodeLensAssociationCommands(context: ExtensionContext, languageClient: LanguageClient) {
193+
function registerAssociationCommands(context: ExtensionContext, languageClient: LanguageClient) {
194+
// For CodeLens
195195
context.subscriptions.push(commands.registerCommand(ClientCommandConstants.OPEN_BINDING_WIZARD, async (uriString: string) => {
196196
grammarAssociationCommand(uriString, languageClient)
197197
}));
198-
}
199-
200-
/**
201-
* Register commands used for associating grammar file (XSD,DTD) to a given XML file
202-
*
203-
* @param context the extension context
204-
* @param languageClient the language server client
205-
*/
206-
function registerAssociationCommands(context: ExtensionContext, languageClient: LanguageClient) {
198+
// For command menu
207199
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;
210200
const uriString = window.activeTextEditor.document.fileName;
211-
// const uriString = uriFolder + uriFile;
212-
// const uriString = workspace.workspaceFile.toString();
213201
grammarAssociationCommand(uriString, languageClient)
214202
}));
215203
}

0 commit comments

Comments
 (0)