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