@parcel/lsp 2.8.3-nightly.2863 → 2.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/LspServer.js +72 -72
- package/package.json +4 -4
package/lib/LspServer.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
5
|
-
var $
|
|
6
|
-
var $
|
|
7
|
-
var $
|
|
8
|
-
var $
|
|
9
|
-
var $
|
|
10
|
-
var $
|
|
1
|
+
var $7GXw8$path = require("path");
|
|
2
|
+
var $7GXw8$fs = require("fs");
|
|
3
|
+
var $7GXw8$os = require("os");
|
|
4
|
+
var $7GXw8$vscodelanguageservernode = require("vscode-languageserver/node");
|
|
5
|
+
var $7GXw8$vscodejsonrpcnode = require("vscode-jsonrpc/node");
|
|
6
|
+
var $7GXw8$assert = require("assert");
|
|
7
|
+
var $7GXw8$url = require("url");
|
|
8
|
+
var $7GXw8$commonpathprefix = require("common-path-prefix");
|
|
9
|
+
var $7GXw8$parcelwatcher = require("@parcel/watcher");
|
|
10
|
+
var $7GXw8$parcellspprotocol = require("@parcel/lsp-protocol");
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -19,25 +19,25 @@ var $bcB9s$parcellspprotocol = require("@parcel/lsp-protocol");
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
const $
|
|
22
|
+
const $f26b521ea1c81a56$var$connection = (0, $7GXw8$vscodelanguageservernode.createConnection)((0, $7GXw8$vscodelanguageservernode.ProposedFeatures).all); // Create a simple text document manager.
|
|
23
23
|
// const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
|
|
24
|
-
let $
|
|
25
|
-
let $
|
|
26
|
-
let $
|
|
27
|
-
$
|
|
24
|
+
let $f26b521ea1c81a56$var$hasConfigurationCapability = false;
|
|
25
|
+
let $f26b521ea1c81a56$var$hasWorkspaceFolderCapability = false; // let hasDiagnosticRelatedInformationCapability = false;
|
|
26
|
+
let $f26b521ea1c81a56$var$hasDiagnosticsRefreshSupport = false;
|
|
27
|
+
$f26b521ea1c81a56$var$connection.onInitialize((params)=>{
|
|
28
28
|
var _capabilities_workspace, _capabilities_workspace_diagnostics;
|
|
29
29
|
const capabilities = params.capabilities; // Does the client support the `workspace/configuration` request?
|
|
30
30
|
// If not, we fall back using global settings.
|
|
31
|
-
$
|
|
32
|
-
$
|
|
31
|
+
$f26b521ea1c81a56$var$hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
|
|
32
|
+
$f26b521ea1c81a56$var$hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders); // hasDiagnosticRelatedInformationCapability = !!(
|
|
33
33
|
// capabilities.textDocument &&
|
|
34
34
|
// capabilities.textDocument.publishDiagnostics &&
|
|
35
35
|
// capabilities.textDocument.publishDiagnostics.relatedInformation
|
|
36
36
|
// );
|
|
37
|
-
$
|
|
37
|
+
$f26b521ea1c81a56$var$hasDiagnosticsRefreshSupport = Boolean((_capabilities_workspace = capabilities.workspace) === null || _capabilities_workspace === void 0 ? void 0 : (_capabilities_workspace_diagnostics = _capabilities_workspace.diagnostics) === null || _capabilities_workspace_diagnostics === void 0 ? void 0 : _capabilities_workspace_diagnostics.refreshSupport);
|
|
38
38
|
const result = {
|
|
39
39
|
capabilities: {
|
|
40
|
-
textDocumentSync: (0, $
|
|
40
|
+
textDocumentSync: (0, $7GXw8$vscodelanguageservernode.TextDocumentSyncKind).Incremental,
|
|
41
41
|
// Tell the client that this server supports code completion.
|
|
42
42
|
diagnosticProvider: {
|
|
43
43
|
workspaceDiagnostics: false,
|
|
@@ -45,30 +45,30 @@ $64cb18ab06d94a18$var$connection.onInitialize((params)=>{
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
if ($
|
|
48
|
+
if ($f26b521ea1c81a56$var$hasWorkspaceFolderCapability) result.capabilities.workspace = {
|
|
49
49
|
workspaceFolders: {
|
|
50
50
|
supported: true
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
return result;
|
|
54
54
|
});
|
|
55
|
-
$
|
|
56
|
-
if ($
|
|
57
|
-
$
|
|
58
|
-
if ($
|
|
59
|
-
$
|
|
55
|
+
$f26b521ea1c81a56$var$connection.onInitialized(()=>{
|
|
56
|
+
if ($f26b521ea1c81a56$var$hasConfigurationCapability) // Register for all configuration changes.
|
|
57
|
+
$f26b521ea1c81a56$var$connection.client.register((0, $7GXw8$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
|
|
58
|
+
if ($f26b521ea1c81a56$var$hasWorkspaceFolderCapability) $f26b521ea1c81a56$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
|
|
59
|
+
$f26b521ea1c81a56$var$connection.console.log("Workspace folder change event received.");
|
|
60
60
|
});
|
|
61
61
|
}); // Proxy
|
|
62
|
-
$
|
|
63
|
-
let client = $
|
|
62
|
+
$f26b521ea1c81a56$var$connection.onRequest((0, $7GXw8$parcellspprotocol.RequestImporters), async (params)=>{
|
|
63
|
+
let client = $f26b521ea1c81a56$var$findClient(params);
|
|
64
64
|
if (client) {
|
|
65
|
-
let result = await client.connection.sendRequest((0, $
|
|
65
|
+
let result = await client.connection.sendRequest((0, $7GXw8$parcellspprotocol.RequestImporters), params);
|
|
66
66
|
return result;
|
|
67
67
|
}
|
|
68
68
|
return null;
|
|
69
69
|
});
|
|
70
|
-
$
|
|
71
|
-
let client = $
|
|
70
|
+
$f26b521ea1c81a56$var$connection.onRequest((0, $7GXw8$vscodelanguageservernode.DocumentDiagnosticRequest).type, async (params)=>{
|
|
71
|
+
let client = $f26b521ea1c81a56$var$findClient(params.textDocument.uri);
|
|
72
72
|
let result;
|
|
73
73
|
if (client) {
|
|
74
74
|
// console.log(
|
|
@@ -77,23 +77,23 @@ $64cb18ab06d94a18$var$connection.onRequest((0, $bcB9s$vscodelanguageservernode.D
|
|
|
77
77
|
// params.previousResultId === client.lastBuild,
|
|
78
78
|
// );
|
|
79
79
|
if (params.previousResultId === client.lastBuild) return {
|
|
80
|
-
kind: (0, $
|
|
80
|
+
kind: (0, $7GXw8$vscodelanguageservernode.DocumentDiagnosticReportKind).Unchanged,
|
|
81
81
|
resultId: client.lastBuild
|
|
82
82
|
};
|
|
83
|
-
result = await client.connection.sendRequest((0, $
|
|
83
|
+
result = await client.connection.sendRequest((0, $7GXw8$parcellspprotocol.RequestDocumentDiagnostics), params.textDocument.uri);
|
|
84
84
|
if (result) client.uris.add(params.textDocument.uri);
|
|
85
85
|
}
|
|
86
86
|
return {
|
|
87
|
-
kind: (0, $
|
|
87
|
+
kind: (0, $7GXw8$vscodelanguageservernode.DocumentDiagnosticReportKind).Full,
|
|
88
88
|
resultId: client === null || client === void 0 ? void 0 : client.lastBuild,
|
|
89
89
|
items: result !== null && result !== void 0 ? result : []
|
|
90
90
|
};
|
|
91
91
|
});
|
|
92
|
-
$
|
|
93
|
-
class $
|
|
92
|
+
$f26b521ea1c81a56$var$connection.listen();
|
|
93
|
+
class $f26b521ea1c81a56$var$ProgressReporter {
|
|
94
94
|
begin() {
|
|
95
95
|
this.progressReporterPromise = (async ()=>{
|
|
96
|
-
let reporter = await $
|
|
96
|
+
let reporter = await $f26b521ea1c81a56$var$connection.window.createWorkDoneProgress();
|
|
97
97
|
reporter.begin("Parcel");
|
|
98
98
|
return reporter;
|
|
99
99
|
})();
|
|
@@ -103,7 +103,7 @@ class $64cb18ab06d94a18$var$ProgressReporter {
|
|
|
103
103
|
}
|
|
104
104
|
async done() {
|
|
105
105
|
if (this.progressReporterPromise == null) this.begin();
|
|
106
|
-
$
|
|
106
|
+
$7GXw8$assert(this.progressReporterPromise != null);
|
|
107
107
|
(await this.progressReporterPromise).done();
|
|
108
108
|
this.progressReporterPromise = null;
|
|
109
109
|
}
|
|
@@ -117,17 +117,17 @@ class $64cb18ab06d94a18$var$ProgressReporter {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
function $
|
|
121
|
-
if ($
|
|
120
|
+
function $f26b521ea1c81a56$var$sendDiagnosticsRefresh() {
|
|
121
|
+
if ($f26b521ea1c81a56$var$hasDiagnosticsRefreshSupport) $f26b521ea1c81a56$var$connection.sendRequest((0, $7GXw8$vscodelanguageservernode.DiagnosticRefreshRequest).type);
|
|
122
122
|
}
|
|
123
|
-
let $
|
|
124
|
-
let $
|
|
125
|
-
function $
|
|
126
|
-
let filepath = $
|
|
123
|
+
let $f26b521ea1c81a56$var$progressReporter = new $f26b521ea1c81a56$var$ProgressReporter();
|
|
124
|
+
let $f26b521ea1c81a56$var$clients = new Map();
|
|
125
|
+
function $f26b521ea1c81a56$var$findClient(document) {
|
|
126
|
+
let filepath = $7GXw8$url.fileURLToPath(document);
|
|
127
127
|
let longestPrefix = 0;
|
|
128
128
|
let bestClient;
|
|
129
|
-
for (let [, client] of $
|
|
130
|
-
let prefix = $
|
|
129
|
+
for (let [, client] of $f26b521ea1c81a56$var$clients){
|
|
130
|
+
let prefix = $7GXw8$commonpathprefix([
|
|
131
131
|
client.projectRoot,
|
|
132
132
|
filepath
|
|
133
133
|
]).length;
|
|
@@ -138,11 +138,11 @@ function $64cb18ab06d94a18$var$findClient(document) {
|
|
|
138
138
|
}
|
|
139
139
|
return bestClient;
|
|
140
140
|
}
|
|
141
|
-
function $
|
|
142
|
-
let metafile = JSON.parse($
|
|
141
|
+
function $f26b521ea1c81a56$var$createClient(metafilepath) {
|
|
142
|
+
let metafile = JSON.parse($7GXw8$fs.readFileSync(metafilepath, "utf8"));
|
|
143
143
|
let socketfilepath = metafilepath.slice(0, -5);
|
|
144
|
-
let [reader, writer] = (0, $
|
|
145
|
-
let client = (0, $
|
|
144
|
+
let [reader, writer] = (0, $7GXw8$vscodejsonrpcnode.createServerPipeTransport)(socketfilepath);
|
|
145
|
+
let client = (0, $7GXw8$vscodejsonrpcnode.createMessageConnection)(reader, writer);
|
|
146
146
|
client.listen();
|
|
147
147
|
let uris = new Set();
|
|
148
148
|
let result = {
|
|
@@ -151,61 +151,61 @@ function $64cb18ab06d94a18$var$createClient(metafilepath) {
|
|
|
151
151
|
projectRoot: metafile.projectRoot,
|
|
152
152
|
lastBuild: "0"
|
|
153
153
|
};
|
|
154
|
-
client.onNotification((0, $
|
|
154
|
+
client.onNotification((0, $7GXw8$parcellspprotocol.NotificationBuildStatus), (state, message)=>{
|
|
155
155
|
// console.log('got NotificationBuildStatus', state, message);
|
|
156
156
|
if (state === "start") {
|
|
157
|
-
$
|
|
158
|
-
for (let uri of uris)$
|
|
157
|
+
$f26b521ea1c81a56$var$progressReporter.begin();
|
|
158
|
+
for (let uri of uris)$f26b521ea1c81a56$var$connection.sendDiagnostics({
|
|
159
159
|
uri: uri,
|
|
160
160
|
diagnostics: []
|
|
161
161
|
});
|
|
162
|
-
} else if (state === "progress" && message != null) $
|
|
162
|
+
} else if (state === "progress" && message != null) $f26b521ea1c81a56$var$progressReporter.report(message);
|
|
163
163
|
else if (state === "end") {
|
|
164
164
|
result.lastBuild = String(Date.now());
|
|
165
|
-
$
|
|
166
|
-
$
|
|
167
|
-
$
|
|
165
|
+
$f26b521ea1c81a56$var$sendDiagnosticsRefresh();
|
|
166
|
+
$f26b521ea1c81a56$var$progressReporter.done();
|
|
167
|
+
$f26b521ea1c81a56$var$connection.sendNotification((0, $7GXw8$parcellspprotocol.NotificationBuild));
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
|
-
client.onNotification((0, $
|
|
170
|
+
client.onNotification((0, $7GXw8$parcellspprotocol.NotificationWorkspaceDiagnostics), (diagnostics)=>{
|
|
171
171
|
// console.log('got NotificationWorkspaceDiagnostics', diagnostics);
|
|
172
172
|
for (let d of diagnostics){
|
|
173
173
|
uris.add(d.uri);
|
|
174
|
-
$
|
|
174
|
+
$f26b521ea1c81a56$var$connection.sendDiagnostics(d);
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
177
|
client.onClose(()=>{
|
|
178
|
-
$
|
|
179
|
-
$
|
|
178
|
+
$f26b521ea1c81a56$var$clients.delete(metafile);
|
|
179
|
+
$f26b521ea1c81a56$var$sendDiagnosticsRefresh();
|
|
180
180
|
return Promise.all([
|
|
181
181
|
...uris
|
|
182
|
-
].map((uri)=>$
|
|
182
|
+
].map((uri)=>$f26b521ea1c81a56$var$connection.sendDiagnostics({
|
|
183
183
|
uri: uri,
|
|
184
184
|
diagnostics: []
|
|
185
185
|
})));
|
|
186
186
|
});
|
|
187
|
-
$
|
|
188
|
-
$
|
|
187
|
+
$f26b521ea1c81a56$var$sendDiagnosticsRefresh();
|
|
188
|
+
$f26b521ea1c81a56$var$clients.set(metafile, result);
|
|
189
189
|
} // Take realpath because to have consistent cache keys on macOS (/var -> /private/var)
|
|
190
|
-
const $
|
|
191
|
-
$
|
|
190
|
+
const $f26b521ea1c81a56$var$BASEDIR = $7GXw8$path.join($7GXw8$fs.realpathSync($7GXw8$os.tmpdir()), "parcel-lsp");
|
|
191
|
+
$7GXw8$fs.mkdirSync($f26b521ea1c81a56$var$BASEDIR, {
|
|
192
192
|
recursive: true
|
|
193
193
|
}); // Search for currently running Parcel processes in the parcel-lsp dir.
|
|
194
194
|
// Create an IPC client connection for each running process.
|
|
195
|
-
for (let filename of $
|
|
195
|
+
for (let filename of $7GXw8$fs.readdirSync($f26b521ea1c81a56$var$BASEDIR)){
|
|
196
196
|
if (!filename.endsWith(".json")) continue;
|
|
197
|
-
let filepath = $
|
|
198
|
-
$
|
|
197
|
+
let filepath = $7GXw8$path.join($f26b521ea1c81a56$var$BASEDIR, filename);
|
|
198
|
+
$f26b521ea1c81a56$var$createClient(filepath); // console.log('connected initial', filepath);
|
|
199
199
|
} // Watch for new Parcel processes in the parcel-lsp dir, and disconnect the
|
|
200
200
|
// client for each corresponding connection when a Parcel process ends
|
|
201
|
-
$
|
|
201
|
+
$7GXw8$parcelwatcher.subscribe($f26b521ea1c81a56$var$BASEDIR, async (err, events)=>{
|
|
202
202
|
if (err) throw err;
|
|
203
203
|
for (let event of events){
|
|
204
|
-
if (event.type === "create" && event.path.endsWith(".json")) $
|
|
204
|
+
if (event.type === "create" && event.path.endsWith(".json")) $f26b521ea1c81a56$var$createClient(event.path); // console.log('connected watched', event.path);
|
|
205
205
|
else if (event.type === "delete" && event.path.endsWith(".json")) {
|
|
206
|
-
let existing = $
|
|
206
|
+
let existing = $f26b521ea1c81a56$var$clients.get(event.path); // console.log('existing', event.path, existing);
|
|
207
207
|
if (existing) {
|
|
208
|
-
$
|
|
208
|
+
$f26b521ea1c81a56$var$clients.delete(event.path);
|
|
209
209
|
existing.connection.end(); // console.log('disconnected watched', event.path);
|
|
210
210
|
}
|
|
211
211
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/lsp",
|
|
3
|
-
"version": "2.8.3
|
|
3
|
+
"version": "2.8.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">= 12.0.0",
|
|
25
|
-
"parcel": "2.
|
|
25
|
+
"parcel": "^2.8.3"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@parcel/lsp-protocol": "2.8.3
|
|
28
|
+
"@parcel/lsp-protocol": "2.8.3",
|
|
29
29
|
"@parcel/watcher": "^2.0.7",
|
|
30
30
|
"common-path-prefix": "^3.0.0",
|
|
31
31
|
"nullthrows": "^1.1.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"targets": {
|
|
45
45
|
"types": false
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "349a6caf40ec8abb6a49fcae0765f8f8deb2073d"
|
|
48
48
|
}
|