Skip to content

Commit 953d240

Browse files
committed
support new commands for codeLens
- vala.showBaseSymbol - vala.showHiddenSymbol
1 parent 8f825e9 commit 953d240

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vala",
33
"displayName": "Vala",
44
"description": "Syntax highlighting and language support for the Vala / Genie languages",
5-
"version": "1.0.4",
5+
"version": "1.0.5",
66
"publisher": "prince781",
77
"author": {
88
"name": "Princeton Ferro",

src/client.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@ import {
33
LanguageClientOptions,
44
ServerOptions,
55
TransportKind,
6-
RevealOutputChannelOn
6+
RevealOutputChannelOn,
77
} from 'vscode-languageclient';
88

9+
// import LSP types
10+
import * as lsp from 'vscode-languageclient';
11+
912
import {
1013
ExtensionContext,
1114
workspace,
1215
window,
16+
commands,
17+
TextEditor,
18+
TextEditorEdit,
19+
Uri,
20+
Location,
21+
Position,
22+
Range
1323
} from 'vscode'
1424

1525
import * as which from 'which'
@@ -67,6 +77,9 @@ export class ValaLanguageClient {
6777

6878
this.ls = new LanguageClient('Vala Language Server', serverOptions, clientOptions)
6979

80+
commands.registerTextEditorCommand('vala.showBaseSymbol', this.peekSymbol);
81+
commands.registerTextEditorCommand('vala.showHiddenSymbol', this.peekSymbol);
82+
7083
this.ls.start()
7184
}
7285

@@ -83,6 +96,32 @@ export class ValaLanguageClient {
8396
|| which.sync('gvls', { nothrow: true }) // for legacy GVLS
8497
}
8598

99+
peekSymbol(editor: TextEditor, edit: TextEditorEdit, lspCurrentLocation: lsp.Location, lspTargetLocation: lsp.Location): void {
100+
let currentLocation = new Location(
101+
Uri.parse(lspCurrentLocation.uri),
102+
new Range(
103+
new Position(lspCurrentLocation.range.start.line, lspCurrentLocation.range.start.character),
104+
new Position(lspCurrentLocation.range.end.line, lspCurrentLocation.range.end.character)
105+
)
106+
);
107+
let targetLocation = new Location(
108+
Uri.parse(lspTargetLocation.uri),
109+
new Range(
110+
new Position(lspTargetLocation.range.start.line, lspTargetLocation.range.start.character),
111+
new Position(lspTargetLocation.range.end.line, lspTargetLocation.range.end.character)
112+
)
113+
);
114+
115+
commands.executeCommand(
116+
'editor.action.peekLocations',
117+
currentLocation.uri, // anchor uri and position
118+
currentLocation.range.end,
119+
[targetLocation], // results (vscode.Location[])
120+
'peek', // mode ('peek' | 'gotoAndPeek' | 'goto')
121+
'Nothing found' // <- message
122+
);
123+
}
124+
86125
dispose() {
87126
if (this.ls) {
88127
this.ls!.stop()

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path'
22
import { spawn } from 'child_process'
33

4-
import { ExtensionContext, languages, IndentAction } from 'vscode'
4+
import { ExtensionContext, languages, IndentAction, commands } from 'vscode'
55

66
import { ValaLanguageClient } from './client'
77

0 commit comments

Comments
 (0)