Skip to content

Commit 5b170fd

Browse files
committed
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 4e750b2 commit 5b170fd

File tree

20 files changed

+943
-215
lines changed

20 files changed

+943
-215
lines changed

README.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,6 @@ intersystems-community.vscode-objectscript version X.Y.Z-beta.1 activating with
7676

7777
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.
7878

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-
9679
## Notes
9780

9881
- 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
@@ -482,6 +482,15 @@
482482
}
483483
],
484484
"editor/context": [
485+
{
486+
"command": "vscode-objectscript.ccs.goToDefinition",
487+
"group": "navigation@0",
488+
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
489+
},
490+
{
491+
"command": "-editor.action.revealDefinition",
492+
"when": "editorLangId =~ /^objectscript/"
493+
},
485494
{
486495
"command": "vscode-objectscript.viewOthers",
487496
"when": "vscode-objectscript.connectActive",
@@ -529,6 +538,16 @@
529538
}
530539
],
531540
"editor/title": [
541+
{
542+
"command": "vscode-objectscript.ccs.goToDefinition",
543+
"group": "navigation@0",
544+
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
545+
},
546+
{
547+
"command": "-editor.action.revealDefinition",
548+
"group": "navigation@0",
549+
"when": "editorLangId =~ /^objectscript/"
550+
},
532551
{
533552
"command": "vscode-objectscript.serverCommands.sourceControl",
534553
"group": "navigation@1",
@@ -854,6 +873,16 @@
854873
"title": "Show Global Documentation",
855874
"enablement": "vscode-objectscript.connectActive"
856875
},
876+
{
877+
"category": "ObjectScript",
878+
"command": "vscode-objectscript.ccs.goToDefinition",
879+
"title": "Go to Definition"
880+
},
881+
{
882+
"category": "ObjectScript",
883+
"command": "vscode-objectscript.ccs.followDefinitionLink",
884+
"title": "Follow Definition Link"
885+
},
857886
{
858887
"category": "ObjectScript",
859888
"command": "vscode-objectscript.compile",
@@ -1228,6 +1257,11 @@
12281257
}
12291258
],
12301259
"keybindings": [
1260+
{
1261+
"command": "vscode-objectscript.ccs.goToDefinition",
1262+
"key": "F12",
1263+
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
1264+
},
12311265
{
12321266
"command": "vscode-objectscript.compile",
12331267
"key": "Ctrl+F7",
@@ -1439,14 +1473,6 @@
14391473
},
14401474
"additionalProperties": false
14411475
},
1442-
"searchOtherWorkspaceFolders": {
1443-
"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.",
1444-
"type": "array",
1445-
"items": {
1446-
"type": "string"
1447-
},
1448-
"default": []
1449-
},
14501476
"atelier": {
14511477
"description": "Export source code as Atelier did it, with packages as subfolders. This setting only affects classes, routines, include files and DFI files.",
14521478
"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)