Skip to content

Commit 24a43ca

Browse files
authored
Unify Go to Definition(F12) and Ctrl+Click through CCS API resolution (#20)
* revert: remove cross-workspace definition lookup (45b7b82) * feat: add API-based Go to Definition command and integrate with keybinding - Introduced DefinitionResolverClient for REST API resolution - Implemented definitionLookup feature (extractQuery + lookup) for robust query handling - Added `PrioritizedDefinitionProvider` to prefer CCS resolver before fallback - Implemented new command vscode-objectscript.ccs.goToDefinition with API-first fallback - Updated package.json to bind F12 and menus to the new command for ObjectScript files - Registered new command in extension.ts and integrated telemetry - New goToDefinitionLocalFirst command integrates CCS API before native definition * feat: support cross-namespace definition lookup and request logging * feat: implement full Ctrl+Click support with `CCS API` resolution * feat: remove visual underline from `DocumentLinks` in `DefinitionDocumentLinkProvider`
1 parent 4b35e13 commit 24a43ca

File tree

20 files changed

+947
-223
lines changed

20 files changed

+947
-223
lines changed

README.md

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,51 +48,29 @@ Open VS Code. Go to Extensions view (<kbd>⌘</kbd>/<kbd>Ctrl</kbd>+<kbd>Shift</
4848
This extension is able to to take advantage of some VS Code APIs that have not yet been finalized.
4949

5050
The additional features (and the APIs used) are:
51-
5251
- Server-side [searching across files](https://code.visualstudio.com/docs/editor/codebasics#_search-across-files) being accessed using isfs (_TextSearchProvider_)
5352
- [Quick Open](https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_quick-open) of isfs files (_FileSearchProvider_).
5453

5554
To unlock these features (optional):
5655

5756
1. Download and install a beta version from GitHub. This is necessary because Marketplace does not allow publication of extensions that use proposed APIs.
58-
59-
- Go to https://github.com/intersystems-community/vscode-objectscript/releases
60-
- Locate the beta immediately above the release you installed from Marketplace. For instance, if you installed `3.0.6`, look for `3.0.7-beta.1`. This will be functionally identical to the Marketplace version apart from being able to use proposed APIs.
61-
- Download the VSIX file (for example `vscode-objectscript-3.0.7-beta.1.vsix`) and install it. One way to install a VSIX is to drag it from your download folder and drop it onto the list of extensions in the Extensions view of VS Code.
57+
- Go to https://github.com/intersystems-community/vscode-objectscript/releases
58+
- Locate the beta immediately above the release you installed from Marketplace. For instance, if you installed `3.0.6`, look for `3.0.7-beta.1`. This will be functionally identical to the Marketplace version apart from being able to use proposed APIs.
59+
- Download the VSIX file (for example `vscode-objectscript-3.0.7-beta.1.vsix`) and install it. One way to install a VSIX is to drag it from your download folder and drop it onto the list of extensions in the Extensions view of VS Code.
6260

6361
2. From [Command Palette](https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_command-palette) choose `Preferences: Configure Runtime Arguments`.
6462
3. In the argv.json file that opens, add this line (required for both Stable and Insiders versions of VS Code):
65-
6663
```json
6764
"enable-proposed-api": ["intersystems-community.vscode-objectscript"]
6865
```
69-
7066
4. Exit VS Code and relaunch it.
7167
5. Verify that the ObjectScript channel of the Output panel reports this:
72-
7368
```
7469
intersystems-community.vscode-objectscript version X.Y.Z-beta.1 activating with proposed APIs available.
7570
```
7671

7772
After a subsequent update of the extension from Marketplace you will only have to download and install the new `vscode-objectscript-X.Y.Z-beta.1` VSIX. None of the other steps above are needed again.
7873

79-
## Cross-workspace Go to Definition
80-
81-
> **Implementation developed and maintained by Consistem Sistemas**
82-
83-
When working in a multi-root workspace, the extension normally searches the current workspace folder (and any sibling folders connected to the same namespace) for local copies of ObjectScript code before requesting the server version. If you keep shared source code in other workspace folders with different connection settings, set the `objectscript.export.searchOtherWorkspaceFolders` array in the consuming folder's settings so those folders are considered first. Use workspace-folder names, or specify `"*"` to search every non-`isfs` folder.
84-
85-
```json
86-
{
87-
"objectscript.export": {
88-
"folder": "src",
89-
"searchOtherWorkspaceFolders": ["shared"]
90-
}
91-
}
92-
```
93-
94-
With this setting enabled, features such as Go to Definition resolve to the first matching local file across the configured workspace folders before falling back to the server copy.
95-
9674
## Notes
9775

9876
- Connection-related output appears in the 'Output' view while switched to the 'ObjectScript' channel using the drop-down menu on the view titlebar.

package.json

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,15 @@
478478
}
479479
],
480480
"editor/context": [
481+
{
482+
"command": "vscode-objectscript.ccs.goToDefinition",
483+
"group": "navigation@0",
484+
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
485+
},
486+
{
487+
"command": "-editor.action.revealDefinition",
488+
"when": "editorLangId =~ /^objectscript/"
489+
},
481490
{
482491
"command": "vscode-objectscript.viewOthers",
483492
"when": "vscode-objectscript.connectActive",
@@ -525,6 +534,16 @@
525534
}
526535
],
527536
"editor/title": [
537+
{
538+
"command": "vscode-objectscript.ccs.goToDefinition",
539+
"group": "navigation@0",
540+
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
541+
},
542+
{
543+
"command": "-editor.action.revealDefinition",
544+
"group": "navigation@0",
545+
"when": "editorLangId =~ /^objectscript/"
546+
},
528547
{
529548
"command": "vscode-objectscript.serverCommands.sourceControl",
530549
"group": "navigation@1",
@@ -850,6 +869,16 @@
850869
"title": "Show Global Documentation",
851870
"enablement": "vscode-objectscript.connectActive"
852871
},
872+
{
873+
"category": "ObjectScript",
874+
"command": "vscode-objectscript.ccs.goToDefinition",
875+
"title": "Go to Definition"
876+
},
877+
{
878+
"category": "ObjectScript",
879+
"command": "vscode-objectscript.ccs.followDefinitionLink",
880+
"title": "Follow Definition Link"
881+
},
853882
{
854883
"category": "ObjectScript",
855884
"command": "vscode-objectscript.compile",
@@ -1218,6 +1247,11 @@
12181247
}
12191248
],
12201249
"keybindings": [
1250+
{
1251+
"command": "vscode-objectscript.ccs.goToDefinition",
1252+
"key": "F12",
1253+
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
1254+
},
12211255
{
12221256
"command": "vscode-objectscript.compile",
12231257
"key": "Ctrl+F7",
@@ -1429,14 +1463,6 @@
14291463
},
14301464
"additionalProperties": false
14311465
},
1432-
"searchOtherWorkspaceFolders": {
1433-
"markdownDescription": "Additional workspace folders to search for client-side sources when resolving ObjectScript documents. Specify `\"*\"` to search all non-isfs workspace folders in the current multi-root workspace before falling back to the server.",
1434-
"type": "array",
1435-
"items": {
1436-
"type": "string"
1437-
},
1438-
"default": []
1439-
},
14401466
"atelier": {
14411467
"description": "Export source code as Atelier did it, with packages as subfolders. This setting only affects classes, routines, include files and DFI files.",
14421468
"type": "boolean"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as vscode from "vscode";
2+
3+
import { lookupCcsDefinition } from "../features/definitionLookup/lookup";
4+
5+
export async function goToDefinitionLocalFirst(): Promise<void> {
6+
const editor = vscode.window.activeTextEditor;
7+
if (!editor) {
8+
return;
9+
}
10+
11+
const { document, selection } = editor;
12+
const position = selection.active;
13+
const tokenSource = new vscode.CancellationTokenSource();
14+
15+
try {
16+
const location = await lookupCcsDefinition(document, position, tokenSource.token);
17+
if (location) {
18+
await vscode.window.showTextDocument(location.uri, { selection: location.range });
19+
return;
20+
}
21+
} finally {
22+
tokenSource.dispose();
23+
}
24+
25+
await vscode.commands.executeCommand("editor.action.revealDefinition");
26+
}

src/ccs/core/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
export interface LocationJSON {
2+
uri?: string;
3+
line?: number;
4+
}
5+
6+
export type ResolveDefinitionResponse = LocationJSON;
7+
18
export interface ResolveContextExpressionResponse {
29
status?: string;
310
textExpression?: string;

0 commit comments

Comments
 (0)