|
1 | 1 | import * as vscode from 'vscode'; |
2 | 2 | import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node'; |
3 | 3 |
|
4 | | -import { type ResolvedReference, Resolver, findReferenceNode, parse } from '@authzed/spicedb-parser-js'; |
| 4 | +import { type ResolvedReference, Resolver, parse } from '@authzed/spicedb-parser-js'; |
5 | 5 |
|
6 | 6 | import { getInstallCommand, languageServerBinaryPath } from './binary'; |
7 | 7 | import { CheckWatchProvider } from './checkwatchprovider'; |
@@ -43,79 +43,6 @@ export function activate(context: vscode.ExtensionContext) { |
43 | 43 | }), |
44 | 44 | ); |
45 | 45 |
|
46 | | - // TODO: Move this into the language server. |
47 | | - vscode.languages.registerDefinitionProvider('spicedb', { |
48 | | - provideDefinition: function ( |
49 | | - document: vscode.TextDocument, |
50 | | - position: vscode.Position, |
51 | | - _token: vscode.CancellationToken, |
52 | | - ): vscode.ProviderResult<vscode.Definition> { |
53 | | - const text = document.getText(); |
54 | | - const parserResult = parse(text); |
55 | | - if (parserResult.error) { |
56 | | - return; |
57 | | - } |
58 | | - |
59 | | - // NOTE: the indexes from VSCode are 0-based, but the parser is 1-based. |
60 | | - const found = findReferenceNode(parserResult.schema!, position.line + 1, position.character + 1); |
61 | | - if (!found) { |
62 | | - return; |
63 | | - } |
64 | | - |
65 | | - const resolution = new Resolver(parserResult.schema!); |
66 | | - switch (found.node?.kind) { |
67 | | - case 'typeref': { |
68 | | - const def = resolution.lookupDefinition(found.node.path); |
69 | | - if (def) { |
70 | | - if (found.node.relationName) { |
71 | | - const relation = def.lookupRelationOrPermission(found.node.relationName); |
72 | | - if (relation) { |
73 | | - return { |
74 | | - uri: document.uri, |
75 | | - range: new vscode.Range( |
76 | | - relation.range.startIndex.line - 1, |
77 | | - relation.range.startIndex.column - 1, |
78 | | - relation.range.startIndex.line - 1, |
79 | | - relation.range.startIndex.column - 1, |
80 | | - ), |
81 | | - }; |
82 | | - } |
83 | | - } else { |
84 | | - return { |
85 | | - uri: document.uri, |
86 | | - range: new vscode.Range( |
87 | | - def.definition.range.startIndex.line - 1, |
88 | | - def.definition.range.startIndex.column - 1, |
89 | | - def.definition.range.startIndex.line - 1, |
90 | | - def.definition.range.startIndex.column - 1, |
91 | | - ), |
92 | | - }; |
93 | | - } |
94 | | - } |
95 | | - break; |
96 | | - } |
97 | | - |
98 | | - case 'relationref': { |
99 | | - const relation = resolution.resolveRelationOrPermission(found.node, found.def); |
100 | | - if (relation) { |
101 | | - return { |
102 | | - uri: document.uri, |
103 | | - range: new vscode.Range( |
104 | | - relation.range.startIndex.line - 1, |
105 | | - relation.range.startIndex.column - 1, |
106 | | - relation.range.startIndex.line - 1, |
107 | | - relation.range.startIndex.column - 1, |
108 | | - ), |
109 | | - }; |
110 | | - } |
111 | | - break; |
112 | | - } |
113 | | - } |
114 | | - |
115 | | - return undefined; |
116 | | - }, |
117 | | - }); |
118 | | - |
119 | 46 | // TODO: Move this into the language server. |
120 | 47 | vscode.languages.registerDocumentSemanticTokensProvider( |
121 | 48 | 'spicedb', |
|
0 commit comments