Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,51 +48,29 @@ Open VS Code. Go to Extensions view (<kbd>⌘</kbd>/<kbd>Ctrl</kbd>+<kbd>Shift</
This extension is able to to take advantage of some VS Code APIs that have not yet been finalized.

The additional features (and the APIs used) are:

- Server-side [searching across files](https://code.visualstudio.com/docs/editor/codebasics#_search-across-files) being accessed using isfs (_TextSearchProvider_)
- [Quick Open](https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_quick-open) of isfs files (_FileSearchProvider_).

To unlock these features (optional):

1. Download and install a beta version from GitHub. This is necessary because Marketplace does not allow publication of extensions that use proposed APIs.

- Go to https://github.com/intersystems-community/vscode-objectscript/releases
- 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.
- 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.
- Go to https://github.com/intersystems-community/vscode-objectscript/releases
- 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.
- 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.

2. From [Command Palette](https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_command-palette) choose `Preferences: Configure Runtime Arguments`.
3. In the argv.json file that opens, add this line (required for both Stable and Insiders versions of VS Code):

```json
"enable-proposed-api": ["intersystems-community.vscode-objectscript"]
```

4. Exit VS Code and relaunch it.
5. Verify that the ObjectScript channel of the Output panel reports this:

```
intersystems-community.vscode-objectscript version X.Y.Z-beta.1 activating with proposed APIs available.
```

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.

## Cross-workspace Go to Definition

> **Implementation developed and maintained by Consistem Sistemas**

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.

```json
{
"objectscript.export": {
"folder": "src",
"searchOtherWorkspaceFolders": ["shared"]
}
}
```

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.

## Notes

- Connection-related output appears in the 'Output' view while switched to the 'ObjectScript' channel using the drop-down menu on the view titlebar.
Expand Down
42 changes: 34 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,15 @@
}
],
"editor/context": [
{
"command": "vscode-objectscript.ccs.goToDefinition",
"group": "navigation@0",
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
},
{
"command": "-editor.action.revealDefinition",
"when": "editorLangId =~ /^objectscript/"
},
{
"command": "vscode-objectscript.viewOthers",
"when": "vscode-objectscript.connectActive",
Expand Down Expand Up @@ -525,6 +534,16 @@
}
],
"editor/title": [
{
"command": "vscode-objectscript.ccs.goToDefinition",
"group": "navigation@0",
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
},
{
"command": "-editor.action.revealDefinition",
"group": "navigation@0",
"when": "editorLangId =~ /^objectscript/"
},
{
"command": "vscode-objectscript.serverCommands.sourceControl",
"group": "navigation@1",
Expand Down Expand Up @@ -850,6 +869,16 @@
"title": "Show Global Documentation",
"enablement": "vscode-objectscript.connectActive"
},
{
"category": "ObjectScript",
"command": "vscode-objectscript.ccs.goToDefinition",
"title": "Go to Definition"
},
{
"category": "ObjectScript",
"command": "vscode-objectscript.ccs.followDefinitionLink",
"title": "Follow Definition Link"
},
{
"category": "ObjectScript",
"command": "vscode-objectscript.compile",
Expand Down Expand Up @@ -1218,6 +1247,11 @@
}
],
"keybindings": [
{
"command": "vscode-objectscript.ccs.goToDefinition",
"key": "F12",
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
},
{
"command": "vscode-objectscript.compile",
"key": "Ctrl+F7",
Expand Down Expand Up @@ -1429,14 +1463,6 @@
},
"additionalProperties": false
},
"searchOtherWorkspaceFolders": {
"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.",
"type": "array",
"items": {
"type": "string"
},
"default": []
},
"atelier": {
"description": "Export source code as Atelier did it, with packages as subfolders. This setting only affects classes, routines, include files and DFI files.",
"type": "boolean"
Expand Down
26 changes: 26 additions & 0 deletions src/ccs/commands/goToDefinitionLocalFirst.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as vscode from "vscode";

import { lookupCcsDefinition } from "../features/definitionLookup/lookup";

export async function goToDefinitionLocalFirst(): Promise<void> {
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}

const { document, selection } = editor;
const position = selection.active;
const tokenSource = new vscode.CancellationTokenSource();

try {
const location = await lookupCcsDefinition(document, position, tokenSource.token);
if (location) {
await vscode.window.showTextDocument(location.uri, { selection: location.range });
return;
}
} finally {
tokenSource.dispose();
}

await vscode.commands.executeCommand("editor.action.revealDefinition");
}
7 changes: 7 additions & 0 deletions src/ccs/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export interface LocationJSON {
uri?: string;
line?: number;
}

export type ResolveDefinitionResponse = LocationJSON;

export interface ResolveContextExpressionResponse {
status?: string;
textExpression?: string;
Expand Down
Loading