-
-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently we have factory code for building commands in the following code, but it only works for VSCode (seems to work for coc too). We should judge the IDE of the language client to return the command format actually supported by the current IDE.
volar.js/packages/language-service/src/baseLanguageService.ts
Lines 129 to 197 in dfddd60
| commands: { | |
| rename: { | |
| create(uri, position) { | |
| const source = toSourceLocation(uri, position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename); | |
| if (!source) { | |
| return; | |
| } | |
| return vscode.Command.create( | |
| '', | |
| 'editor.action.rename', | |
| source.uri, | |
| source.position, | |
| ); | |
| }, | |
| is(command) { | |
| return command.command === 'editor.action.rename'; | |
| }, | |
| }, | |
| showReferences: { | |
| create(uri, position, locations) { | |
| const source = toSourceLocation(uri, position); | |
| if (!source) { | |
| return; | |
| } | |
| const sourceReferences: vscode.Location[] = []; | |
| for (const reference of locations) { | |
| if (context.documents.isVirtualFileUri(reference.uri)) { | |
| for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) { | |
| const range = map.toSourceRange(reference.range); | |
| if (range) { | |
| sourceReferences.push({ uri: map.sourceFileDocument.uri, range }); | |
| } | |
| } | |
| } | |
| else { | |
| sourceReferences.push(reference); | |
| } | |
| } | |
| return vscode.Command.create( | |
| locations.length === 1 ? '1 reference' : `${locations.length} references`, | |
| 'editor.action.showReferences', | |
| source.uri, | |
| source.position, | |
| sourceReferences, | |
| ); | |
| }, | |
| is(command) { | |
| return command.command === 'editor.action.showReferences'; | |
| }, | |
| }, | |
| setSelection: { | |
| create(position: vscode.Position) { | |
| return vscode.Command.create( | |
| '', | |
| 'setSelection', | |
| { | |
| selection: { | |
| selectionStartLineNumber: position.line + 1, | |
| positionLineNumber: position.line + 1, | |
| selectionStartColumn: position.character + 1, | |
| positionColumn: position.character + 1, | |
| }, | |
| }, | |
| ); | |
| }, | |
| is(command) { | |
| return command.command === 'setSelection'; | |
| } | |
| }, |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request