@atlaspack/reporter-lsp 2.12.1-dev.3365 → 2.12.1-dev.3398
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/LspReporter.js +8 -8
- package/lib/utils.js +3 -3
- package/package.json +6 -6
- package/src/LspReporter.js +12 -12
- package/src/utils.js +4 -4
package/lib/LspReporter.js
CHANGED
|
@@ -87,9 +87,9 @@ const ignoreFail = func => {
|
|
|
87
87
|
/**/
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
const BASEDIR = _fs().default.realpathSync(_path().default.join(_os().default.tmpdir(), '
|
|
91
|
-
const SOCKET_FILE = _path().default.join(BASEDIR, `
|
|
92
|
-
const META_FILE = _path().default.join(BASEDIR, `
|
|
90
|
+
const BASEDIR = _fs().default.realpathSync(_path().default.join(_os().default.tmpdir(), 'parcel-lsp'));
|
|
91
|
+
const SOCKET_FILE = _path().default.join(BASEDIR, `parcel-${process.pid}`);
|
|
92
|
+
const META_FILE = _path().default.join(BASEDIR, `parcel-${process.pid}.json`);
|
|
93
93
|
let workspaceDiagnostics = new (_utils().DefaultMap)(() => []);
|
|
94
94
|
const getWorkspaceDiagnostics = () => [...workspaceDiagnostics].map(([uri, diagnostics]) => ({
|
|
95
95
|
uri,
|
|
@@ -137,7 +137,7 @@ async function doWatchStart(options) {
|
|
|
137
137
|
// by a process that quit unexpectedly.
|
|
138
138
|
for (let filename of _fs().default.readdirSync(BASEDIR)) {
|
|
139
139
|
if (filename.endsWith('.json')) continue;
|
|
140
|
-
let pid = parseInt(filename.slice('
|
|
140
|
+
let pid = parseInt(filename.slice('parcel-'.length), 10);
|
|
141
141
|
let resultList = await lookupPid({
|
|
142
142
|
pid
|
|
143
143
|
});
|
|
@@ -241,8 +241,8 @@ function sendDiagnostics() {
|
|
|
241
241
|
// console.log('send', getWorkspaceDiagnostics());
|
|
242
242
|
connections.forEach(c => c.sendNotification(_lspProtocol().NotificationWorkspaceDiagnostics, getWorkspaceDiagnostics()));
|
|
243
243
|
}
|
|
244
|
-
function updateDiagnostics(
|
|
245
|
-
for (let diagnostic of
|
|
244
|
+
function updateDiagnostics(parcelDiagnostics, parcelSeverity, projectRoot) {
|
|
245
|
+
for (let diagnostic of parcelDiagnostics) {
|
|
246
246
|
const codeFrames = diagnostic.codeFrames;
|
|
247
247
|
if (codeFrames == null) {
|
|
248
248
|
continue;
|
|
@@ -254,7 +254,7 @@ function updateDiagnostics(atlaspackDiagnostics, atlaspackSeverity, projectRoot)
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
// We use the first highlight of the first codeFrame as the main Diagnostic,
|
|
257
|
-
// and we place everything else in the current
|
|
257
|
+
// and we place everything else in the current Parcel diagnostic
|
|
258
258
|
// in relatedInformation
|
|
259
259
|
// https://code.visualstudio.com/api/references/vscode-api#DiagnosticRelatedInformation
|
|
260
260
|
const firstFrameHighlight = codeFrames[0].codeHighlights[0];
|
|
@@ -298,7 +298,7 @@ function updateDiagnostics(atlaspackDiagnostics, atlaspackSeverity, projectRoot)
|
|
|
298
298
|
}
|
|
299
299
|
},
|
|
300
300
|
source: diagnostic.origin,
|
|
301
|
-
severity: (0, _utils2.
|
|
301
|
+
severity: (0, _utils2.parcelSeverityToLspSeverity)(parcelSeverity),
|
|
302
302
|
message: diagnostic.message + (firstFrameHighlight.message == null ? '' : ' ' + firstFrameHighlight.message),
|
|
303
303
|
relatedInformation
|
|
304
304
|
});
|
package/lib/utils.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DiagnosticTag = exports.DiagnosticSeverity = void 0;
|
|
7
|
-
exports.atlaspackSeverityToLspSeverity = atlaspackSeverityToLspSeverity;
|
|
8
7
|
exports.normalizeFilePath = normalizeFilePath;
|
|
8
|
+
exports.parcelSeverityToLspSeverity = parcelSeverityToLspSeverity;
|
|
9
9
|
function _path() {
|
|
10
10
|
const data = _interopRequireDefault(require("path"));
|
|
11
11
|
_path = function () {
|
|
@@ -14,8 +14,8 @@ function _path() {
|
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
function
|
|
18
|
-
switch (
|
|
17
|
+
function parcelSeverityToLspSeverity(parcelSeverity) {
|
|
18
|
+
switch (parcelSeverity) {
|
|
19
19
|
case 'error':
|
|
20
20
|
return DiagnosticSeverity.Error;
|
|
21
21
|
case 'warn':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/reporter-lsp",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
3
|
+
"version": "2.12.1-dev.3398+81c73b3cd",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
"source": "src/LspReporter.js",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">= 16.0.0",
|
|
16
|
-
"
|
|
16
|
+
"parcel": "^2.12.1-dev.3398+81c73b3cd"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/lsp-protocol": "2.12.1-dev.
|
|
20
|
-
"@atlaspack/plugin": "2.12.1-dev.
|
|
21
|
-
"@atlaspack/utils": "2.12.1-dev.
|
|
19
|
+
"@atlaspack/lsp-protocol": "2.12.1-dev.3398+81c73b3cd",
|
|
20
|
+
"@atlaspack/plugin": "2.12.1-dev.3398+81c73b3cd",
|
|
21
|
+
"@atlaspack/utils": "2.12.1-dev.3398+81c73b3cd",
|
|
22
22
|
"node-ipc": "^9.1.4",
|
|
23
23
|
"nullthrows": "^1.1.1",
|
|
24
24
|
"ps-node": "^0.1.6",
|
|
25
25
|
"vscode-jsonrpc": "^8.0.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "81c73b3cdf93adf8b0013be9fed5422579bd5910"
|
|
28
28
|
}
|
package/src/LspReporter.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
|
|
3
|
-
import type {Diagnostic as
|
|
3
|
+
import type {Diagnostic as ParcelDiagnostic} from '@atlaspack/diagnostic';
|
|
4
4
|
import type {BundleGraph, FilePath, PackagedBundle} from '@atlaspack/types';
|
|
5
5
|
import type {Program, Query} from 'ps-node';
|
|
6
6
|
import type {Diagnostic, DocumentUri} from 'vscode-languageserver';
|
|
7
7
|
import type {MessageConnection} from 'vscode-jsonrpc/node';
|
|
8
|
-
import type {
|
|
8
|
+
import type {ParcelSeverity} from './utils';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
DefaultMap,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
DiagnosticSeverity,
|
|
35
35
|
DiagnosticTag,
|
|
36
36
|
normalizeFilePath,
|
|
37
|
-
|
|
37
|
+
parcelSeverityToLspSeverity,
|
|
38
38
|
} from './utils';
|
|
39
39
|
import type {FSWatcher} from 'fs';
|
|
40
40
|
|
|
@@ -48,9 +48,9 @@ const ignoreFail = func => {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const BASEDIR = fs.realpathSync(path.join(os.tmpdir(), '
|
|
52
|
-
const SOCKET_FILE = path.join(BASEDIR, `
|
|
53
|
-
const META_FILE = path.join(BASEDIR, `
|
|
51
|
+
const BASEDIR = fs.realpathSync(path.join(os.tmpdir(), 'parcel-lsp'));
|
|
52
|
+
const SOCKET_FILE = path.join(BASEDIR, `parcel-${process.pid}`);
|
|
53
|
+
const META_FILE = path.join(BASEDIR, `parcel-${process.pid}.json`);
|
|
54
54
|
|
|
55
55
|
let workspaceDiagnostics: DefaultMap<
|
|
56
56
|
string,
|
|
@@ -108,7 +108,7 @@ async function doWatchStart(options) {
|
|
|
108
108
|
// by a process that quit unexpectedly.
|
|
109
109
|
for (let filename of fs.readdirSync(BASEDIR)) {
|
|
110
110
|
if (filename.endsWith('.json')) continue;
|
|
111
|
-
let pid = parseInt(filename.slice('
|
|
111
|
+
let pid = parseInt(filename.slice('parcel-'.length), 10);
|
|
112
112
|
let resultList = await lookupPid({pid});
|
|
113
113
|
if (resultList.length > 0) continue;
|
|
114
114
|
fs.unlinkSync(path.join(BASEDIR, filename));
|
|
@@ -241,11 +241,11 @@ function sendDiagnostics() {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
function updateDiagnostics(
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
parcelDiagnostics: Array<ParcelDiagnostic>,
|
|
245
|
+
parcelSeverity: ParcelSeverity,
|
|
246
246
|
projectRoot: FilePath,
|
|
247
247
|
): void {
|
|
248
|
-
for (let diagnostic of
|
|
248
|
+
for (let diagnostic of parcelDiagnostics) {
|
|
249
249
|
const codeFrames = diagnostic.codeFrames;
|
|
250
250
|
if (codeFrames == null) {
|
|
251
251
|
continue;
|
|
@@ -258,7 +258,7 @@ function updateDiagnostics(
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
// We use the first highlight of the first codeFrame as the main Diagnostic,
|
|
261
|
-
// and we place everything else in the current
|
|
261
|
+
// and we place everything else in the current Parcel diagnostic
|
|
262
262
|
// in relatedInformation
|
|
263
263
|
// https://code.visualstudio.com/api/references/vscode-api#DiagnosticRelatedInformation
|
|
264
264
|
const firstFrameHighlight = codeFrames[0].codeHighlights[0];
|
|
@@ -307,7 +307,7 @@ function updateDiagnostics(
|
|
|
307
307
|
},
|
|
308
308
|
},
|
|
309
309
|
source: diagnostic.origin,
|
|
310
|
-
severity:
|
|
310
|
+
severity: parcelSeverityToLspSeverity(parcelSeverity),
|
|
311
311
|
message:
|
|
312
312
|
diagnostic.message +
|
|
313
313
|
(firstFrameHighlight.message == null
|
package/src/utils.js
CHANGED
|
@@ -4,12 +4,12 @@ import type {ODiagnosticSeverity} from 'vscode-languageserver';
|
|
|
4
4
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type ParcelSeverity = DiagnosticLogEvent['level'];
|
|
8
8
|
|
|
9
|
-
export function
|
|
10
|
-
|
|
9
|
+
export function parcelSeverityToLspSeverity(
|
|
10
|
+
parcelSeverity: ParcelSeverity,
|
|
11
11
|
): ODiagnosticSeverity {
|
|
12
|
-
switch (
|
|
12
|
+
switch (parcelSeverity) {
|
|
13
13
|
case 'error':
|
|
14
14
|
return DiagnosticSeverity.Error;
|
|
15
15
|
case 'warn':
|