aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-03-13 14:56:18 +0100
committerDaniel Gavin <danielgavin5@hotmail.com>2022-03-13 14:56:18 +0100
commite2780708f9a590a62882d1316997dc2248b3e9b1 (patch)
tree065b1dc530b49fde280c21116d9489035efad622 /editors
parent3fb29122228c6ee513e81a5be43e6d43442c84e7 (diff)
Fixes
Diffstat (limited to 'editors')
-rw-r--r--editors/vscode/package-lock.json46
-rw-r--r--editors/vscode/package.json14
-rw-r--r--editors/vscode/src/ctx.ts4
-rw-r--r--editors/vscode/src/extension.ts5
-rw-r--r--editors/vscode/src/inlay_hints.ts244
5 files changed, 34 insertions, 279 deletions
diff --git a/editors/vscode/package-lock.json b/editors/vscode/package-lock.json
index fca8d01..93c6671 100644
--- a/editors/vscode/package-lock.json
+++ b/editors/vscode/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "ols",
- "version": "0.1.1",
+ "version": "0.1.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -146,21 +146,21 @@
"dev": true
},
"@types/mocha": {
- "version": "9.0.0",
- "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.0.0.tgz",
- "integrity": "sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA==",
+ "version": "9.1.0",
+ "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz",
+ "integrity": "sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg==",
"dev": true
},
"@types/node": {
- "version": "14.18.7",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.7.tgz",
- "integrity": "sha512-UpLEO1iBG7esNPusSAjoZhWFK5Mfd8QfwWhHRrg5io13POn/stsBgTCba9suQaFflNA4tc0+6AFM3R6BZNng6A==",
+ "version": "14.18.12",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.12.tgz",
+ "integrity": "sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A==",
"dev": true
},
"@types/node-fetch": {
- "version": "2.5.12",
- "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz",
- "integrity": "sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==",
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz",
+ "integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==",
"dev": true,
"requires": {
"@types/node": "*",
@@ -168,9 +168,9 @@
}
},
"@types/vscode": {
- "version": "1.63.1",
- "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.63.1.tgz",
- "integrity": "sha512-Z+ZqjRcnGfHP86dvx/BtSwWyZPKQ/LBdmAVImY82TphyjOw2KgTKcp7Nx92oNwCTsHzlshwexAG/WiY2JuUm3g==",
+ "version": "1.65.0",
+ "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.65.0.tgz",
+ "integrity": "sha512-wQhExnh2nEzpjDMSKhUvnNmz3ucpd3E+R7wJkOhBNK3No6fG3VUdmVmMOKD0A8NDZDDDiQcLNxe3oGmX5SjJ5w==",
"dev": true
},
"@typescript-eslint/eslint-plugin": {
@@ -1267,18 +1267,18 @@
}
},
"mime-db": {
- "version": "1.51.0",
- "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
- "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==",
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"dev": true
},
"mime-types": {
- "version": "2.1.34",
- "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
- "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
+ "version": "2.1.35",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dev": true,
"requires": {
- "mime-db": "1.51.0"
+ "mime-db": "1.52.0"
}
},
"minimatch": {
@@ -1854,9 +1854,9 @@
"dev": true
},
"typescript": {
- "version": "4.5.4",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz",
- "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==",
+ "version": "4.6.2",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz",
+ "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==",
"dev": true
},
"unzipper": {
diff --git a/editors/vscode/package.json b/editors/vscode/package.json
index 6c976cc..661dc2a 100644
--- a/editors/vscode/package.json
+++ b/editors/vscode/package.json
@@ -7,9 +7,9 @@
"type": "git",
"url": "git://github.com/DanielGavin/ols.git"
},
- "version": "0.1.1",
+ "version": "0.1.2",
"engines": {
- "vscode": "^1.63.1"
+ "vscode": "^1.65.0"
},
"categories": [
"Programming Languages"
@@ -155,16 +155,16 @@
},
"devDependencies": {
"@types/glob": "^7.2.0",
- "@types/mocha": "^9.0.0",
- "@types/node": "^14.18.7",
- "@types/node-fetch": "^2.5.12",
- "@types/vscode": "^1.63.1",
+ "@types/mocha": "^9.1.0",
+ "@types/node": "^14.18.12",
+ "@types/node-fetch": "^2.6.1",
+ "@types/vscode": "^1.65.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"glob": "^7.2.0",
"mocha": "^8.4.0",
- "typescript": "^4.5.4",
+ "typescript": "^4.6.2",
"vscode-test": "^1.6.1"
},
"dependencies": {
diff --git a/editors/vscode/src/ctx.ts b/editors/vscode/src/ctx.ts
index a1bf5d4..a9637b2 100644
--- a/editors/vscode/src/ctx.ts
+++ b/editors/vscode/src/ctx.ts
@@ -4,8 +4,6 @@ import * as lc from 'vscode-languageclient/node';
import { Config } from './config';
import { isOdinEditor, OdinEditor } from './util';
-import * as inlayHints from './inlay_hints';
-
//modified from https://github.com/rust-analyzer/rust-analyzer/blob/master/editors/code/src/ctx.ts - 09.05.2021
export class Ctx {
@@ -27,8 +25,6 @@ export class Ctx {
): Promise<Ctx> {
const res = new Ctx(config, extCtx, client, serverPath);
- inlayHints.activate(res);
-
return res;
}
diff --git a/editors/vscode/src/extension.ts b/editors/vscode/src/extension.ts
index 69dcd28..5d288bb 100644
--- a/editors/vscode/src/extension.ts
+++ b/editors/vscode/src/extension.ts
@@ -291,7 +291,6 @@ async function getServer(config: Config, state: PersistentState): Promise<string
url: artifact.browser_download_url,
dest: destZip,
progressTitle: "Downloading ols",
- mode: 0o755,
httpProxy: config.httpProxy,
});
});
@@ -300,6 +299,10 @@ async function getServer(config: Config, state: PersistentState): Promise<string
zip.extractAllTo(destFolder, true);
+ if (ext !== ".exe") {
+ fs.chmod(destExecutable, 0o755);
+ }
+
await state.updateServerVersion(config.package.version);
await state.updateReleaseId(release.id);
await state.updateLastCheck(Date.now());
diff --git a/editors/vscode/src/inlay_hints.ts b/editors/vscode/src/inlay_hints.ts
deleted file mode 100644
index 441cd0c..0000000
--- a/editors/vscode/src/inlay_hints.ts
+++ /dev/null
@@ -1,244 +0,0 @@
-// modification of https://github.com/clangd/vscode-clangd/blob/master/src/inlay-hints.ts
-
-import * as vscode from 'vscode';
-import * as vscodelc from 'vscode-languageclient/node';
-
-import { Ctx } from './ctx';
-
-export function activate(context: Ctx) {
- const feature = new InlayHintsFeature(context);
- context.client.registerFeature(feature);
-}
-
-// Currently, only one hint kind (parameter hints) are supported,
-// but others (e.g. type hints) may be added in the future.
-enum InlayHintKind {
- Parameter = 'parameter',
- Type = 'type'
-}
-
-interface InlayHint {
- range: vscodelc.Range;
- kind: InlayHintKind | string;
- label: string;
-}
-
-interface InlayHintsParams {
- textDocument: vscodelc.TextDocumentIdentifier;
-}
-
-namespace InlayHintsRequest {
- export const type =
- new vscodelc.RequestType<InlayHintsParams, InlayHint[], void>(
- 'odin/inlayHints');
-}
-
-interface InlayDecorations {
- // Hints are grouped based on their InlayHintKind, because different kinds
- // require different decoration types.
- // A future iteration of the API may have free-form hint kinds, and instead
- // specify style-related information (e.g. before vs. after) explicitly.
- // With such an API, we could group hints based on unique presentation styles
- // instead.
- parameterHints: vscode.DecorationOptions[];
- typeHints: vscode.DecorationOptions[];
-}
-
-interface HintStyle {
- decorationType: vscode.TextEditorDecorationType;
-
- toDecoration(hint: InlayHint,
- conv: vscodelc.Protocol2CodeConverter): vscode.DecorationOptions;
-}
-
-const parameterHintStyle = createHintStyle('before');
-const typeHintStyle = createHintStyle('after');
-
-function createHintStyle(position: 'before' | 'after'): HintStyle {
- const fg = new vscode.ThemeColor('odin.inlayHints.foreground');
- const bg = new vscode.ThemeColor('odin.inlayHints.background');
- return {
- decorationType: vscode.window.createTextEditorDecorationType({
- [position]: {
- color: fg,
- backgroundColor: bg,
- fontStyle: 'normal',
- fontWeight: 'normal',
- textDecoration: ';font-size:smaller'
- }
- }),
- toDecoration(hint: InlayHint, conv: vscodelc.Protocol2CodeConverter):
- vscode.DecorationOptions {
- return {
- range: conv.asRange(hint.range),
- renderOptions: { [position]: { contentText: hint.label } }
- };
- }
- };
-}
-
-interface FileEntry {
- document: vscode.TextDocument;
-
- // Last applied decorations.
- cachedDecorations: InlayDecorations | null;
-
- // Source of the token to cancel in-flight inlay hints request if any.
- inlaysRequest: vscode.CancellationTokenSource | null;
-}
-
-class InlayHintsFeature implements vscodelc.StaticFeature {
- private enabled = false;
- private sourceFiles = new Map<string, FileEntry>(); // keys are URIs
- private readonly disposables: vscode.Disposable[] = [];
-
- constructor(private readonly context: Ctx) { }
-
- fillClientCapabilities(_capabilities: vscodelc.ClientCapabilities) { }
- fillInitializeParams(_params: vscodelc.InitializeParams) { }
-
- initialize(capabilities: vscodelc.ServerCapabilities,
- _documentSelector: vscodelc.DocumentSelector | undefined) {
- const serverCapabilities: vscodelc.ServerCapabilities &
- { inlayHintsProvider?: boolean } = capabilities;
- if (serverCapabilities.inlayHintsProvider) {
- this.enabled = true;
- this.startShowingHints();
- }
- }
-
- onDidChangeVisibleTextEditors() {
- if (!this.enabled) {
- return;
- }
-
-
- const newSourceFiles = new Map<string, FileEntry>();
-
- // Rerender all, even up-to-date editors for simplicity
- this.context.visibleOdinEditors.forEach(async editor => {
- const uri = editor.document.uri.toString();
- const file = this.sourceFiles.get(uri) ?? {
- document: editor.document,
- cachedDecorations: null,
- inlaysRequest: null
- };
- newSourceFiles.set(uri, file);
-
- // No text documents changed, so we may try to use the cache
- if (!file.cachedDecorations) {
- const hints = await this.fetchHints(file);
- if (!hints) {
- return;
- }
-
- file.cachedDecorations = this.hintsToDecorations(hints);
- }
-
- this.renderDecorations(editor, file.cachedDecorations);
- });
-
- // Cancel requests for no longer visible (disposed) source files
- this.sourceFiles.forEach((file, uri) => {
- if (!newSourceFiles.has(uri)) {
- file.inlaysRequest?.cancel();
- }
- });
-
- this.sourceFiles = newSourceFiles;
- }
-
- onDidChangeTextDocument({ contentChanges,
- document }: vscode.TextDocumentChangeEvent) {
- if (!this.enabled || contentChanges.length === 0 ||
- !this.context.isOdinDocument(document)) {
- return;
- }
-
- this.syncCacheAndRenderHints();
- }
-
- dispose() { this.stopShowingHints(); }
-
- private startShowingHints() {
- vscode.window.onDidChangeVisibleTextEditors(
- this.onDidChangeVisibleTextEditors, this, this.disposables);
- vscode.workspace.onDidChangeTextDocument(this.onDidChangeTextDocument, this,
- this.disposables);
-
- // Set up initial cache shape
- this.context.visibleOdinEditors.forEach(
- editor => this.sourceFiles.set(editor.document.uri.toString(), {
- document: editor.document,
- inlaysRequest: null,
- cachedDecorations: null
- }));
-
- this.syncCacheAndRenderHints();
- }
-
- private stopShowingHints() {
- this.sourceFiles.forEach(file => file.inlaysRequest?.cancel());
- this.context.visibleOdinEditors.forEach(
- editor => this.renderDecorations(editor,
- { parameterHints: [], typeHints: [] }));
- this.disposables.forEach(d => d.dispose());
- }
-
- private renderDecorations(editor: vscode.TextEditor,
- decorations: InlayDecorations) {
- editor.setDecorations(parameterHintStyle.decorationType,
- decorations.parameterHints);
- editor.setDecorations(typeHintStyle.decorationType, decorations.typeHints);
- }
-
- private syncCacheAndRenderHints() {
- this.sourceFiles.forEach(
- (file, uri) => this.fetchHints(file).then(hints => {
- if (!hints) {
- return;
- }
-
- file.cachedDecorations = this.hintsToDecorations(hints);
-
- for (const editor of this.context.visibleOdinEditors) {
- if (editor.document.uri.toString() == uri) {
- this.renderDecorations(editor, file.cachedDecorations);
- }
- }
- }));
- }
-
- private hintsToDecorations(hints: InlayHint[]): InlayDecorations {
- const decorations: InlayDecorations = { parameterHints: [], typeHints: [] };
- const conv = this.context.client.protocol2CodeConverter;
- for (const hint of hints) {
- switch (hint.kind) {
- case InlayHintKind.Parameter: {
- decorations.parameterHints.push(
- parameterHintStyle.toDecoration(hint, conv));
- continue;
- }
- case InlayHintKind.Type: {
- decorations.typeHints.push(typeHintStyle.toDecoration(hint, conv));
- continue;
- }
- // Don't handle unknown hint kinds because we don't know how to style
- // them. This may change in a future version of the protocol.
- }
- }
- return decorations;
- }
-
- private async fetchHints(file: FileEntry): Promise<InlayHint[] | null> {
- file.inlaysRequest?.cancel();
-
- const tokenSource = new vscode.CancellationTokenSource();
- file.inlaysRequest = tokenSource;
-
- const request = { textDocument: { uri: file.document.uri.toString() } };
-
- return this.context.client.sendRequest(InlayHintsRequest.type, request,
- tokenSource.token);
- }
-} \ No newline at end of file