aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package-lock.json20
-rw-r--r--editors/code/package.json9
-rw-r--r--editors/code/src/client.ts7
-rw-r--r--editors/code/src/installation/download_file.ts33
-rw-r--r--editors/code/src/installation/language_server.ts2
5 files changed, 43 insertions, 28 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json
index 5c056463e..c74078735 100644
--- a/editors/code/package-lock.json
+++ b/editors/code/package-lock.json
@@ -1,6 +1,6 @@
1{ 1{
2 "name": "rust-analyzer", 2 "name": "rust-analyzer",
3 "version": "0.1.0", 3 "version": "0.2.0-dev",
4 "lockfileVersion": 1, 4 "lockfileVersion": 1,
5 "requires": true, 5 "requires": true,
6 "dependencies": { 6 "dependencies": {
@@ -107,9 +107,9 @@
107 "dev": true 107 "dev": true
108 }, 108 },
109 "@types/vscode": { 109 "@types/vscode": {
110 "version": "1.41.0", 110 "version": "1.42.0",
111 "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.41.0.tgz", 111 "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.42.0.tgz",
112 "integrity": "sha512-7SfeY5u9jgiELwxyLB3z7l6l/GbN9CqpCQGkcRlB7tKRFBxzbz2PoBfGrLxI1vRfUCIq5+hg5vtDHExwq5j3+A==", 112 "integrity": "sha512-ds6TceMsh77Fs0Mq0Vap6Y72JbGWB8Bay4DrnJlf5d9ui2RSe1wis13oQm+XhguOeH1HUfLGzaDAoupTUtgabw==",
113 "dev": true 113 "dev": true
114 }, 114 },
115 "acorn": { 115 "acorn": {
@@ -662,9 +662,9 @@
662 } 662 }
663 }, 663 },
664 "readable-stream": { 664 "readable-stream": {
665 "version": "3.4.0", 665 "version": "3.6.0",
666 "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", 666 "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
667 "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", 667 "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
668 "dev": true, 668 "dev": true,
669 "requires": { 669 "requires": {
670 "inherits": "^2.0.3", 670 "inherits": "^2.0.3",
@@ -860,9 +860,9 @@
860 "dev": true 860 "dev": true
861 }, 861 },
862 "vsce": { 862 "vsce": {
863 "version": "1.71.0", 863 "version": "1.73.0",
864 "resolved": "https://registry.npmjs.org/vsce/-/vsce-1.71.0.tgz", 864 "resolved": "https://registry.npmjs.org/vsce/-/vsce-1.73.0.tgz",
865 "integrity": "sha512-7k+LPC4oJYPyyxs0a5nh4A8CleQ6+2EMPiAiX/bDyN+PmwJFm2FFPqLRxdIsIWfFnkW4ZMQBf10+W62dCRd9kQ==", 865 "integrity": "sha512-6W37Ebbkj3uF3WhT+SCfRtsneRQEFcGvf/XYz+b6OAgDCj4gPurWyDVrqw/HLsbP1WflGIyUfVZ8t5M7kQp6Uw==",
866 "dev": true, 866 "dev": true,
867 "requires": { 867 "requires": {
868 "azure-devops-node-api": "^7.2.0", 868 "azure-devops-node-api": "^7.2.0",
diff --git a/editors/code/package.json b/editors/code/package.json
index 12d32cef7..a607c2148 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -5,7 +5,8 @@
5 "preview": true, 5 "preview": true,
6 "private": true, 6 "private": true,
7 "icon": "icon.png", 7 "icon": "icon.png",
8 "version": "0.1.0", 8 "//": "The real version is in release.yaml, this one just needs to be bigger",
9 "version": "0.2.0-dev",
9 "publisher": "matklad", 10 "publisher": "matklad",
10 "repository": { 11 "repository": {
11 "url": "https://github.com/rust-analyzer/rust-analyzer.git", 12 "url": "https://github.com/rust-analyzer/rust-analyzer.git",
@@ -15,7 +16,7 @@
15 "Other" 16 "Other"
16 ], 17 ],
17 "engines": { 18 "engines": {
18 "vscode": "^1.41.0" 19 "vscode": "^1.42.0"
19 }, 20 },
20 "scripts": { 21 "scripts": {
21 "vscode:prepublish": "tsc && rollup -c", 22 "vscode:prepublish": "tsc && rollup -c",
@@ -35,13 +36,13 @@
35 "@types/node": "^12.12.25", 36 "@types/node": "^12.12.25",
36 "@types/node-fetch": "^2.5.4", 37 "@types/node-fetch": "^2.5.4",
37 "@types/throttle-debounce": "^2.1.0", 38 "@types/throttle-debounce": "^2.1.0",
38 "@types/vscode": "^1.41.0", 39 "@types/vscode": "^1.42.0",
39 "rollup": "^1.31.0", 40 "rollup": "^1.31.0",
40 "tslib": "^1.10.0", 41 "tslib": "^1.10.0",
41 "tslint": "^5.20.1", 42 "tslint": "^5.20.1",
42 "typescript": "^3.7.5", 43 "typescript": "^3.7.5",
43 "typescript-formatter": "^7.2.2", 44 "typescript-formatter": "^7.2.2",
44 "vsce": "^1.71.0" 45 "vsce": "^1.73.0"
45 }, 46 },
46 "activationEvents": [ 47 "activationEvents": [
47 "onLanguage:rust", 48 "onLanguage:rust",
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 4484b2167..dcf9d0c06 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -3,6 +3,7 @@ import * as vscode from 'vscode';
3 3
4import { Config } from './config'; 4import { Config } from './config';
5import { ensureLanguageServerBinary } from './installation/language_server'; 5import { ensureLanguageServerBinary } from './installation/language_server';
6import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
6 7
7export async function createClient(config: Config): Promise<null | lc.LanguageClient> { 8export async function createClient(config: Config): Promise<null | lc.LanguageClient> {
8 // '.' Is the fallback if no folder is open 9 // '.' Is the fallback if no folder is open
@@ -80,6 +81,10 @@ export async function createClient(config: Config): Promise<null | lc.LanguageCl
80 } 81 }
81 }, 82 },
82 }; 83 };
83 res.registerProposedFeatures(); 84
85 // To turn on all proposed features use: res.registerProposedFeatures();
86 // Here we want to just enable CallHierarchyFeature since it is available on stable.
87 // Note that while the CallHierarchyFeature is stable the LSP protocol is not.
88 res.registerFeature(new CallHierarchyFeature(res));
84 return res; 89 return res;
85} 90}
diff --git a/editors/code/src/installation/download_file.ts b/editors/code/src/installation/download_file.ts
index f1f9f4a25..d154f4816 100644
--- a/editors/code/src/installation/download_file.ts
+++ b/editors/code/src/installation/download_file.ts
@@ -1,7 +1,11 @@
1import fetch from "node-fetch"; 1import fetch from "node-fetch";
2import * as fs from "fs"; 2import * as fs from "fs";
3import * as stream from "stream";
4import * as util from "util";
3import { strict as assert } from "assert"; 5import { strict as assert } from "assert";
4 6
7const pipeline = util.promisify(stream.pipeline);
8
5/** 9/**
6 * Downloads file from `url` and stores it at `destFilePath` with `destFilePermissions`. 10 * Downloads file from `url` and stores it at `destFilePath` with `destFilePermissions`.
7 * `onProgress` callback is called on recieveing each chunk of bytes 11 * `onProgress` callback is called on recieveing each chunk of bytes
@@ -20,25 +24,28 @@ export async function downloadFile(
20 console.log("Error", res.status, "while downloading file from", url); 24 console.log("Error", res.status, "while downloading file from", url);
21 console.dir({ body: await res.text(), headers: res.headers }, { depth: 3 }); 25 console.dir({ body: await res.text(), headers: res.headers }, { depth: 3 });
22 26
23 throw new Error(`Got response ${res.status} when trying to download a file`); 27 throw new Error(`Got response ${res.status} when trying to download a file.`);
24 } 28 }
25 29
26 const totalBytes = Number(res.headers.get('content-length')); 30 const totalBytes = Number(res.headers.get('content-length'));
27 assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); 31 assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol");
28 32
33 console.log("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath);
34
29 let readBytes = 0; 35 let readBytes = 0;
36 res.body.on("data", (chunk: Buffer) => {
37 readBytes += chunk.length;
38 onProgress(readBytes, totalBytes);
39 });
30 40
31 console.log("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath); 41 const destFileStream = fs.createWriteStream(destFilePath, { mode: destFilePermissions });
42
43 await pipeline(res.body, destFileStream);
44 return new Promise<void>(resolve => {
45 destFileStream.on("close", resolve);
46 destFileStream.destroy();
32 47
33 return new Promise<void>((resolve, reject) => res.body 48 // Details on workaround: https://github.com/rust-analyzer/rust-analyzer/pull/3092#discussion_r378191131
34 .on("data", (chunk: Buffer) => { 49 // Issue at nodejs repo: https://github.com/nodejs/node/issues/31776
35 readBytes += chunk.length; 50 });
36 onProgress(readBytes, totalBytes);
37 })
38 .on("error", reject)
39 .pipe(fs
40 .createWriteStream(destFilePath, { mode: destFilePermissions })
41 .on("close", resolve)
42 )
43 );
44} 51}
diff --git a/editors/code/src/installation/language_server.ts b/editors/code/src/installation/language_server.ts
index 52c5cbe7d..4797c3f01 100644
--- a/editors/code/src/installation/language_server.ts
+++ b/editors/code/src/installation/language_server.ts
@@ -104,6 +104,8 @@ export async function ensureLanguageServerBinary(
104 `GitHub repository: ${err.message}` 104 `GitHub repository: ${err.message}`
105 ); 105 );
106 106
107 console.error(err);
108
107 dns.resolve('example.com').then( 109 dns.resolve('example.com').then(
108 addrs => console.log("DNS resolution for example.com was successful", addrs), 110 addrs => console.log("DNS resolution for example.com was successful", addrs),
109 err => { 111 err => {