Skip to content

Commit e145bc0

Browse files
Merge pull request #301 from intersystems-community/theia
Theia support
2 parents 6bb8b62 + 641ff88 commit e145bc0

File tree

7 files changed

+44
-24
lines changed

7 files changed

+44
-24
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"tasks": [
1313
{
1414
"type": "npm",
15-
"script": "watch",
15+
"script": "webpack-dev",
1616
"presentation": {
1717
"reveal": "never"
1818
},

.vscodeignore

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
.github/**
2-
.vscode/**
3-
.vscode-test/**
4-
out/
5-
src/
6-
**/*.ts
7-
**/*.map
8-
**/*.cls
9-
.gitignore
10-
tsconfig*.json
11-
**/tslint.json
12-
**/.eslintrc.json
13-
node_modules/
14-
webpack.config.js
1+
**
2+
!dist/
3+
!snippets/
4+
!images/
5+
!syntaxes/
6+
!README.md
7+
!CHANGELOG.md
8+
!*.json
9+
!*.jsonc

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@
942942
},
943943
"dependencies": {
944944
"await-notify": "^1.0.1",
945+
"core-js": "^3.6.5",
945946
"glob": "^7.1.6",
946947
"iconv-lite": "^0.6.0",
947948
"mkdirp": "^1.0.4",

src/extension.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ async function serverManager(): Promise<any> {
328328
if (ignore) {
329329
return;
330330
}
331+
try {
332+
await vscode.commands.executeCommand("extension.open", extId);
333+
} catch (ex) {
334+
// Such command do not exists, suppose we are under Theia, it's not possible to install this extension this way
335+
return;
336+
}
331337
await vscode.window
332338
.showInformationMessage(
333339
"The InterSystems® Server Manager extension is recommended to help you define connections and store passwords securely in your keychain.",
@@ -338,8 +344,7 @@ async function serverManager(): Promise<any> {
338344
.then(async (action) => {
339345
switch (action) {
340346
case "Install":
341-
await vscode.commands.executeCommand("workbench.extensions.search", `@tag:"intersystems"`);
342-
await vscode.commands.executeCommand("extension.open", extId);
347+
await vscode.commands.executeCommand("workbench.extensions.search", `@tag:"intersystems"`).then(null, null);
343348
await vscode.commands.executeCommand("workbench.extensions.installExtension", extId);
344349
extension = vscode.extensions.getExtension(extId);
345350
break;
@@ -361,13 +366,22 @@ async function serverManager(): Promise<any> {
361366

362367
export async function activate(context: vscode.ExtensionContext): Promise<any> {
363368
if (!packageJson.version.includes("SNAPSHOT")) {
364-
reporter = new TelemetryReporter(extensionId, extensionVersion, aiKey);
369+
try {
370+
reporter = new TelemetryReporter(extensionId, extensionVersion, aiKey);
371+
} catch (_error) {
372+
reporter = null;
373+
}
365374
}
366375

367376
const languages = packageJson.contributes.languages.map((lang) => lang.id);
368-
workspaceState = context.workspaceState;
377+
// workaround for Theia, issue https://github.com/eclipse-theia/theia/issues/8435
378+
workspaceState = {
379+
get: <T>(key: string, defaultValue?: T): T | undefined =>
380+
context.workspaceState.get(key, defaultValue) || defaultValue,
381+
update: (key: string, value: any): Thenable<void> => context.workspaceState.update(key, value),
382+
};
369383
extensionContext = context;
370-
workspaceState.update("workspaceFolder", "");
384+
workspaceState.update("workspaceFolder", undefined);
371385

372386
// Get api for servermanager extension, perhaps offering to install it
373387
serverManagerApi = await serverManager();
@@ -436,7 +450,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
436450
vscode.window.onDidChangeActiveTextEditor((textEditor: vscode.TextEditor) => {
437451
checkConnection();
438452
posPanel.text = "";
439-
if (textEditor.document.fileName.endsWith(".xml") && config("autoPreviewXML")) {
453+
if (textEditor?.document.fileName.endsWith(".xml") && config("autoPreviewXML")) {
440454
return xml2doc(context, textEditor);
441455
}
442456
});

src/providers/FileSystemPovider/FileSystemProvider.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { File } from "./File";
77
import { fireOtherStudioAction, OtherStudioAction } from "../../commands/studio";
88
import { StudioOpenDialog } from "../../queries";
99

10+
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
11+
1012
export type Entry = File | Directory;
1113

1214
export class FileSystemProvider implements vscode.FileSystemProvider {
@@ -40,6 +42,9 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
4042
public async readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> {
4143
const parent = await this._lookupAsDirectory(uri);
4244
const api = new AtelierAPI(uri);
45+
if (!api.active) {
46+
return;
47+
}
4348
const sql = `CALL %Library.RoutineMgr_StudioOpenDialog(?,?,?,?,?,?,?)`;
4449
const { query } = url.parse(decodeURIComponent(uri.toString()), true);
4550
const type = query.type && query.type != "" ? query.type.toString() : "all";
@@ -80,7 +85,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
8085
})
8186
)
8287
.catch((error) => {
83-
console.error(error);
88+
error && console.error(error);
8489
});
8590
}
8691

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require("path");
44
const config = {
55
target: "node", // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
66

7-
entry: "./src/extension.ts", // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
7+
entry: ["core-js/features/array/flat-map", "./src/extension.ts"], // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
88
output: {
99
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
1010
path: path.resolve(__dirname, "dist"),

0 commit comments

Comments
 (0)