@parcel/lsp 2.12.1-dev.3138 → 2.12.1-nightly.3134

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