@parcel/lsp 2.9.4-nightly.2997 → 2.9.4-nightly.3003
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 $7uaT0$path = require("path");
|
|
2
|
+
var $7uaT0$fs = require("fs");
|
|
3
|
+
var $7uaT0$os = require("os");
|
|
4
|
+
var $7uaT0$vscodelanguageservernode = require("vscode-languageserver/node");
|
|
5
|
+
var $7uaT0$vscodejsonrpcnode = require("vscode-jsonrpc/node");
|
|
6
|
+
var $7uaT0$assert = require("assert");
|
|
7
|
+
var $7uaT0$url = require("url");
|
|
8
|
+
var $7uaT0$commonpathprefix = require("common-path-prefix");
|
|
9
|
+
var $7uaT0$parcelwatcher = require("@parcel/watcher");
|
|
10
|
+
var $7uaT0$parcellspprotocol = require("@parcel/lsp-protocol");
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -19,29 +19,29 @@ var $emEq8$parcellspprotocol = require("@parcel/lsp-protocol");
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
const $
|
|
22
|
+
const $6897e3d3c327789d$var$connection = (0, $7uaT0$vscodelanguageservernode.createConnection)((0, $7uaT0$vscodelanguageservernode.ProposedFeatures).all);
|
|
23
23
|
// Create a simple text document manager.
|
|
24
24
|
// const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
|
|
25
|
-
let $
|
|
26
|
-
let $
|
|
25
|
+
let $6897e3d3c327789d$var$hasConfigurationCapability = false;
|
|
26
|
+
let $6897e3d3c327789d$var$hasWorkspaceFolderCapability = false;
|
|
27
27
|
// let hasDiagnosticRelatedInformationCapability = false;
|
|
28
|
-
let $
|
|
29
|
-
$
|
|
28
|
+
let $6897e3d3c327789d$var$hasDiagnosticsRefreshSupport = false;
|
|
29
|
+
$6897e3d3c327789d$var$connection.onInitialize((params)=>{
|
|
30
30
|
var _capabilities_workspace_diagnostics, _capabilities_workspace;
|
|
31
31
|
const capabilities = params.capabilities;
|
|
32
32
|
// Does the client support the `workspace/configuration` request?
|
|
33
33
|
// If not, we fall back using global settings.
|
|
34
|
-
$
|
|
35
|
-
$
|
|
34
|
+
$6897e3d3c327789d$var$hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
|
|
35
|
+
$6897e3d3c327789d$var$hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
|
|
36
36
|
// hasDiagnosticRelatedInformationCapability = !!(
|
|
37
37
|
// capabilities.textDocument &&
|
|
38
38
|
// capabilities.textDocument.publishDiagnostics &&
|
|
39
39
|
// capabilities.textDocument.publishDiagnostics.relatedInformation
|
|
40
40
|
// );
|
|
41
|
-
$
|
|
41
|
+
$6897e3d3c327789d$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);
|
|
42
42
|
const result = {
|
|
43
43
|
capabilities: {
|
|
44
|
-
textDocumentSync: (0, $
|
|
44
|
+
textDocumentSync: (0, $7uaT0$vscodelanguageservernode.TextDocumentSyncKind).Incremental,
|
|
45
45
|
// Tell the client that this server supports code completion.
|
|
46
46
|
diagnosticProvider: {
|
|
47
47
|
workspaceDiagnostics: false,
|
|
@@ -49,32 +49,32 @@ $9c413af73df25601$var$connection.onInitialize((params)=>{
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
if ($
|
|
52
|
+
if ($6897e3d3c327789d$var$hasWorkspaceFolderCapability) result.capabilities.workspace = {
|
|
53
53
|
workspaceFolders: {
|
|
54
54
|
supported: true
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
return result;
|
|
58
58
|
});
|
|
59
|
-
$
|
|
60
|
-
if ($
|
|
61
|
-
$
|
|
62
|
-
if ($
|
|
63
|
-
$
|
|
59
|
+
$6897e3d3c327789d$var$connection.onInitialized(()=>{
|
|
60
|
+
if ($6897e3d3c327789d$var$hasConfigurationCapability) // Register for all configuration changes.
|
|
61
|
+
$6897e3d3c327789d$var$connection.client.register((0, $7uaT0$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
|
|
62
|
+
if ($6897e3d3c327789d$var$hasWorkspaceFolderCapability) $6897e3d3c327789d$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
|
|
63
|
+
$6897e3d3c327789d$var$connection.console.log("Workspace folder change event received.");
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
// Proxy
|
|
67
|
-
$
|
|
68
|
-
let client = $
|
|
67
|
+
$6897e3d3c327789d$var$connection.onRequest((0, $7uaT0$parcellspprotocol.RequestImporters), async (params)=>{
|
|
68
|
+
let client = $6897e3d3c327789d$var$findClient(params);
|
|
69
69
|
if (client) {
|
|
70
|
-
let result = await client.connection.sendRequest((0, $
|
|
70
|
+
let result = await client.connection.sendRequest((0, $7uaT0$parcellspprotocol.RequestImporters), params);
|
|
71
71
|
return result;
|
|
72
72
|
}
|
|
73
73
|
return null;
|
|
74
74
|
});
|
|
75
|
-
$
|
|
75
|
+
$6897e3d3c327789d$var$connection.onRequest((0, $7uaT0$vscodelanguageservernode.DocumentDiagnosticRequest).type, async (params)=>{
|
|
76
76
|
var _client;
|
|
77
|
-
let client = $
|
|
77
|
+
let client = $6897e3d3c327789d$var$findClient(params.textDocument.uri);
|
|
78
78
|
let result;
|
|
79
79
|
if (client) {
|
|
80
80
|
// console.log(
|
|
@@ -83,23 +83,23 @@ $9c413af73df25601$var$connection.onRequest((0, $emEq8$vscodelanguageservernode.D
|
|
|
83
83
|
// params.previousResultId === client.lastBuild,
|
|
84
84
|
// );
|
|
85
85
|
if (params.previousResultId === client.lastBuild) return {
|
|
86
|
-
kind: (0, $
|
|
86
|
+
kind: (0, $7uaT0$vscodelanguageservernode.DocumentDiagnosticReportKind).Unchanged,
|
|
87
87
|
resultId: client.lastBuild
|
|
88
88
|
};
|
|
89
|
-
result = await client.connection.sendRequest((0, $
|
|
89
|
+
result = await client.connection.sendRequest((0, $7uaT0$parcellspprotocol.RequestDocumentDiagnostics), params.textDocument.uri);
|
|
90
90
|
if (result) client.uris.add(params.textDocument.uri);
|
|
91
91
|
}
|
|
92
92
|
return {
|
|
93
|
-
kind: (0, $
|
|
93
|
+
kind: (0, $7uaT0$vscodelanguageservernode.DocumentDiagnosticReportKind).Full,
|
|
94
94
|
resultId: (_client = client) === null || _client === void 0 ? void 0 : _client.lastBuild,
|
|
95
95
|
items: result !== null && result !== void 0 ? result : []
|
|
96
96
|
};
|
|
97
97
|
});
|
|
98
|
-
$
|
|
99
|
-
class $
|
|
98
|
+
$6897e3d3c327789d$var$connection.listen();
|
|
99
|
+
class $6897e3d3c327789d$var$ProgressReporter {
|
|
100
100
|
begin() {
|
|
101
101
|
this.progressReporterPromise = (async ()=>{
|
|
102
|
-
let reporter = await $
|
|
102
|
+
let reporter = await $6897e3d3c327789d$var$connection.window.createWorkDoneProgress();
|
|
103
103
|
reporter.begin("Parcel");
|
|
104
104
|
return reporter;
|
|
105
105
|
})();
|
|
@@ -109,7 +109,7 @@ class $9c413af73df25601$var$ProgressReporter {
|
|
|
109
109
|
}
|
|
110
110
|
async done() {
|
|
111
111
|
if (this.progressReporterPromise == null) this.begin();
|
|
112
|
-
$
|
|
112
|
+
$7uaT0$assert(this.progressReporterPromise != null);
|
|
113
113
|
(await this.progressReporterPromise).done();
|
|
114
114
|
this.progressReporterPromise = null;
|
|
115
115
|
}
|
|
@@ -123,17 +123,17 @@ class $9c413af73df25601$var$ProgressReporter {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function $
|
|
127
|
-
if ($
|
|
126
|
+
function $6897e3d3c327789d$var$sendDiagnosticsRefresh() {
|
|
127
|
+
if ($6897e3d3c327789d$var$hasDiagnosticsRefreshSupport) $6897e3d3c327789d$var$connection.sendRequest((0, $7uaT0$vscodelanguageservernode.DiagnosticRefreshRequest).type);
|
|
128
128
|
}
|
|
129
|
-
let $
|
|
130
|
-
let $
|
|
131
|
-
function $
|
|
132
|
-
let filepath = $
|
|
129
|
+
let $6897e3d3c327789d$var$progressReporter = new $6897e3d3c327789d$var$ProgressReporter();
|
|
130
|
+
let $6897e3d3c327789d$var$clients = new Map();
|
|
131
|
+
function $6897e3d3c327789d$var$findClient(document) {
|
|
132
|
+
let filepath = $7uaT0$url.fileURLToPath(document);
|
|
133
133
|
let longestPrefix = 0;
|
|
134
134
|
let bestClient;
|
|
135
|
-
for (let [, client] of $
|
|
136
|
-
let prefix = $
|
|
135
|
+
for (let [, client] of $6897e3d3c327789d$var$clients){
|
|
136
|
+
let prefix = $7uaT0$commonpathprefix([
|
|
137
137
|
client.projectRoot,
|
|
138
138
|
filepath
|
|
139
139
|
]).length;
|
|
@@ -144,11 +144,11 @@ function $9c413af73df25601$var$findClient(document) {
|
|
|
144
144
|
}
|
|
145
145
|
return bestClient;
|
|
146
146
|
}
|
|
147
|
-
function $
|
|
148
|
-
let metafile = JSON.parse($
|
|
147
|
+
function $6897e3d3c327789d$var$createClient(metafilepath) {
|
|
148
|
+
let metafile = JSON.parse($7uaT0$fs.readFileSync(metafilepath, "utf8"));
|
|
149
149
|
let socketfilepath = metafilepath.slice(0, -5);
|
|
150
|
-
let [reader, writer] = (0, $
|
|
151
|
-
let client = (0, $
|
|
150
|
+
let [reader, writer] = (0, $7uaT0$vscodejsonrpcnode.createServerPipeTransport)(socketfilepath);
|
|
151
|
+
let client = (0, $7uaT0$vscodejsonrpcnode.createMessageConnection)(reader, writer);
|
|
152
152
|
client.listen();
|
|
153
153
|
let uris = new Set();
|
|
154
154
|
let result = {
|
|
@@ -157,66 +157,66 @@ function $9c413af73df25601$var$createClient(metafilepath) {
|
|
|
157
157
|
projectRoot: metafile.projectRoot,
|
|
158
158
|
lastBuild: "0"
|
|
159
159
|
};
|
|
160
|
-
client.onNotification((0, $
|
|
160
|
+
client.onNotification((0, $7uaT0$parcellspprotocol.NotificationBuildStatus), (state, message)=>{
|
|
161
161
|
// console.log('got NotificationBuildStatus', state, message);
|
|
162
162
|
if (state === "start") {
|
|
163
|
-
$
|
|
164
|
-
for (let uri of uris)$
|
|
163
|
+
$6897e3d3c327789d$var$progressReporter.begin();
|
|
164
|
+
for (let uri of uris)$6897e3d3c327789d$var$connection.sendDiagnostics({
|
|
165
165
|
uri: uri,
|
|
166
166
|
diagnostics: []
|
|
167
167
|
});
|
|
168
|
-
} else if (state === "progress" && message != null) $
|
|
168
|
+
} else if (state === "progress" && message != null) $6897e3d3c327789d$var$progressReporter.report(message);
|
|
169
169
|
else if (state === "end") {
|
|
170
170
|
result.lastBuild = String(Date.now());
|
|
171
|
-
$
|
|
172
|
-
$
|
|
173
|
-
$
|
|
171
|
+
$6897e3d3c327789d$var$sendDiagnosticsRefresh();
|
|
172
|
+
$6897e3d3c327789d$var$progressReporter.done();
|
|
173
|
+
$6897e3d3c327789d$var$connection.sendNotification((0, $7uaT0$parcellspprotocol.NotificationBuild));
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
|
-
client.onNotification((0, $
|
|
176
|
+
client.onNotification((0, $7uaT0$parcellspprotocol.NotificationWorkspaceDiagnostics), (diagnostics)=>{
|
|
177
177
|
// console.log('got NotificationWorkspaceDiagnostics', diagnostics);
|
|
178
178
|
for (let d of diagnostics){
|
|
179
179
|
uris.add(d.uri);
|
|
180
|
-
$
|
|
180
|
+
$6897e3d3c327789d$var$connection.sendDiagnostics(d);
|
|
181
181
|
}
|
|
182
182
|
});
|
|
183
183
|
client.onClose(()=>{
|
|
184
|
-
$
|
|
185
|
-
$
|
|
184
|
+
$6897e3d3c327789d$var$clients.delete(metafile);
|
|
185
|
+
$6897e3d3c327789d$var$sendDiagnosticsRefresh();
|
|
186
186
|
return Promise.all([
|
|
187
187
|
...uris
|
|
188
|
-
].map((uri)=>$
|
|
188
|
+
].map((uri)=>$6897e3d3c327789d$var$connection.sendDiagnostics({
|
|
189
189
|
uri: uri,
|
|
190
190
|
diagnostics: []
|
|
191
191
|
})));
|
|
192
192
|
});
|
|
193
|
-
$
|
|
194
|
-
$
|
|
193
|
+
$6897e3d3c327789d$var$sendDiagnosticsRefresh();
|
|
194
|
+
$6897e3d3c327789d$var$clients.set(metafile, result);
|
|
195
195
|
}
|
|
196
196
|
// Take realpath because to have consistent cache keys on macOS (/var -> /private/var)
|
|
197
|
-
const $
|
|
198
|
-
$
|
|
197
|
+
const $6897e3d3c327789d$var$BASEDIR = $7uaT0$path.join($7uaT0$fs.realpathSync($7uaT0$os.tmpdir()), "parcel-lsp");
|
|
198
|
+
$7uaT0$fs.mkdirSync($6897e3d3c327789d$var$BASEDIR, {
|
|
199
199
|
recursive: true
|
|
200
200
|
});
|
|
201
201
|
// Search for currently running Parcel processes in the parcel-lsp dir.
|
|
202
202
|
// Create an IPC client connection for each running process.
|
|
203
|
-
for (let filename of $
|
|
203
|
+
for (let filename of $7uaT0$fs.readdirSync($6897e3d3c327789d$var$BASEDIR)){
|
|
204
204
|
if (!filename.endsWith(".json")) continue;
|
|
205
|
-
let filepath = $
|
|
206
|
-
$
|
|
205
|
+
let filepath = $7uaT0$path.join($6897e3d3c327789d$var$BASEDIR, filename);
|
|
206
|
+
$6897e3d3c327789d$var$createClient(filepath);
|
|
207
207
|
// console.log('connected initial', filepath);
|
|
208
208
|
}
|
|
209
209
|
// Watch for new Parcel processes in the parcel-lsp dir, and disconnect the
|
|
210
210
|
// client for each corresponding connection when a Parcel process ends
|
|
211
|
-
$
|
|
211
|
+
$7uaT0$parcelwatcher.subscribe($6897e3d3c327789d$var$BASEDIR, async (err, events)=>{
|
|
212
212
|
if (err) throw err;
|
|
213
213
|
for (let event of events){
|
|
214
|
-
if (event.type === "create" && event.path.endsWith(".json")) $
|
|
214
|
+
if (event.type === "create" && event.path.endsWith(".json")) $6897e3d3c327789d$var$createClient(event.path);
|
|
215
215
|
else if (event.type === "delete" && event.path.endsWith(".json")) {
|
|
216
|
-
let existing = $
|
|
216
|
+
let existing = $6897e3d3c327789d$var$clients.get(event.path);
|
|
217
217
|
// console.log('existing', event.path, existing);
|
|
218
218
|
if (existing) {
|
|
219
|
-
$
|
|
219
|
+
$6897e3d3c327789d$var$clients.delete(event.path);
|
|
220
220
|
existing.connection.end();
|
|
221
221
|
// console.log('disconnected watched', event.path);
|
|
222
222
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/lsp",
|
|
3
|
-
"version": "2.9.4-nightly.
|
|
3
|
+
"version": "2.9.4-nightly.3003+801de2c60",
|
|
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.0.0-nightly.
|
|
25
|
+
"parcel": "2.0.0-nightly.1378+801de2c60"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@parcel/lsp-protocol": "2.9.4-nightly.
|
|
28
|
+
"@parcel/lsp-protocol": "2.9.4-nightly.3003+801de2c60",
|
|
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": "801de2c60ae0c37df6d798ee3a93f45afe9909c7"
|
|
48
48
|
}
|