Skip to content

Commit 5c5d151

Browse files
author
Alexander Chen
committed
added wrapper for command xml.command.bind.gramma
1 parent 389f6e7 commit 5c5d151

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@
526526
"category": "XML"
527527
},
528528
{
529-
"command": "xml.open.binding.wizard",
529+
"command": "xml.command.bind.grammar",
530530
"title": "Bind to grammar/schema file",
531531
"category": "XML"
532532
}

src/commands/commandConstants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ 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';
6567
}
6668

6769
/**

src/commands/registerCommands.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export async function registerClientServerCommands(context: ExtensionContext, la
2626
registerCodeLensReferencesCommands(context, languageClient);
2727
registerValidationCommands(context);
2828
registerCodeLensAssociationCommands(context, languageClient);
29+
registerAssociationCommands(context, languageClient);
2930

3031
// Register client command to execute custom XML Language Server command
3132
context.subscriptions.push(commands.registerCommand(ClientCommandConstants.EXECUTE_WORKSPACE_COMMAND, (command, ...rest) => {
@@ -195,3 +196,20 @@ function registerCodeLensAssociationCommands(context: ExtensionContext, language
195196
grammarAssociationCommand(uriString, languageClient)
196197
}));
197198
}
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) {
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;
210+
const uriString = window.activeTextEditor.document.fileName;
211+
// const uriString = uriFolder + uriFile;
212+
// const uriString = workspace.workspaceFile.toString();
213+
grammarAssociationCommand(uriString, languageClient)
214+
}));
215+
}

0 commit comments

Comments
 (0)