@angular/language-server 14.1.0 → 14.2.0
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/index.js +120 -27
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -5,9 +5,9 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
5
5
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
// dist/
|
|
8
|
+
// dist/server/src/cmdline_utils.js
|
|
9
9
|
var require_cmdline_utils = __commonJS({
|
|
10
|
-
"dist/
|
|
10
|
+
"dist/server/src/cmdline_utils.js"(exports2) {
|
|
11
11
|
"use strict";
|
|
12
12
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13
13
|
exports2.generateHelpMessage = exports2.parseCommandLine = void 0;
|
|
@@ -171,9 +171,9 @@ var require_resolver = __commonJS({
|
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
|
|
174
|
-
// dist/
|
|
174
|
+
// dist/server/src/version_provider.js
|
|
175
175
|
var require_version_provider = __commonJS({
|
|
176
|
-
"dist/
|
|
176
|
+
"dist/server/src/version_provider.js"(exports2) {
|
|
177
177
|
"use strict";
|
|
178
178
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
179
179
|
if (k2 === void 0)
|
|
@@ -294,7 +294,7 @@ var require_version_provider = __commonJS({
|
|
|
294
294
|
}
|
|
295
295
|
});
|
|
296
296
|
|
|
297
|
-
// dist/
|
|
297
|
+
// dist/server/src/banner.js
|
|
298
298
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
299
299
|
exports.requireOverride = void 0;
|
|
300
300
|
var cmdline_utils_1 = require_cmdline_utils();
|
|
@@ -327,9 +327,9 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
327
327
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
328
328
|
};
|
|
329
329
|
|
|
330
|
-
// dist/server/cmdline_utils.js
|
|
330
|
+
// dist/server/src/cmdline_utils.js
|
|
331
331
|
var require_cmdline_utils = __commonJS({
|
|
332
|
-
"dist/server/cmdline_utils.js"(exports2) {
|
|
332
|
+
"dist/server/src/cmdline_utils.js"(exports2) {
|
|
333
333
|
"use strict";
|
|
334
334
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
335
335
|
exports2.generateHelpMessage = exports2.parseCommandLine = void 0;
|
|
@@ -392,9 +392,9 @@ var require_cmdline_utils = __commonJS({
|
|
|
392
392
|
}
|
|
393
393
|
});
|
|
394
394
|
|
|
395
|
-
// dist/server/logger.js
|
|
395
|
+
// dist/server/src/logger.js
|
|
396
396
|
var require_logger = __commonJS({
|
|
397
|
-
"dist/server/logger.js"(exports2) {
|
|
397
|
+
"dist/server/src/logger.js"(exports2) {
|
|
398
398
|
"use strict";
|
|
399
399
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
400
400
|
if (k2 === void 0)
|
|
@@ -524,9 +524,9 @@ var require_logger = __commonJS({
|
|
|
524
524
|
}
|
|
525
525
|
});
|
|
526
526
|
|
|
527
|
-
// dist/server/server_host.js
|
|
527
|
+
// dist/server/src/server_host.js
|
|
528
528
|
var require_server_host = __commonJS({
|
|
529
|
-
"dist/server/server_host.js"(exports2) {
|
|
529
|
+
"dist/server/src/server_host.js"(exports2) {
|
|
530
530
|
"use strict";
|
|
531
531
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
532
532
|
if (k2 === void 0)
|
|
@@ -3068,9 +3068,9 @@ var require_requests = __commonJS({
|
|
|
3068
3068
|
}
|
|
3069
3069
|
});
|
|
3070
3070
|
|
|
3071
|
-
// dist/server/utils.js
|
|
3071
|
+
// dist/server/src/utils.js
|
|
3072
3072
|
var require_utils = __commonJS({
|
|
3073
|
-
"dist/server/utils.js"(exports2) {
|
|
3073
|
+
"dist/server/src/utils.js"(exports2) {
|
|
3074
3074
|
"use strict";
|
|
3075
3075
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3076
3076
|
if (k2 === void 0)
|
|
@@ -3105,7 +3105,7 @@ var require_utils = __commonJS({
|
|
|
3105
3105
|
return result;
|
|
3106
3106
|
};
|
|
3107
3107
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3108
|
-
exports2.getMappedDefinitionInfo = exports2.tsDisplayPartsToText = exports2.MruTracker = exports2.isConfiguredProject = exports2.tsRelatedInformationToLspRelatedInformation = exports2.lspRangeToTsPositions = exports2.lspPositionToTsPosition = exports2.tsTextSpanToLspRange = exports2.filePathToUri = exports2.uriToFilePath = exports2.isDebugMode = void 0;
|
|
3108
|
+
exports2.getMappedDefinitionInfo = exports2.tsDisplayPartsToText = exports2.MruTracker = exports2.isConfiguredProject = exports2.tsRelatedInformationToLspRelatedInformation = exports2.lspRangeToTsPositions = exports2.lspPositionToTsPosition = exports2.tsTextSpanToLspRange = exports2.tsFileTextChangesToLspWorkspaceEdit = exports2.filePathToUri = exports2.uriToFilePath = exports2.isDebugMode = void 0;
|
|
3109
3109
|
var ts = __importStar(require("typescript/lib/tsserverlibrary"));
|
|
3110
3110
|
var lsp = __importStar(require("vscode-languageserver"));
|
|
3111
3111
|
var vscode_uri_1 = require("vscode-uri");
|
|
@@ -3126,6 +3126,30 @@ var require_utils = __commonJS({
|
|
|
3126
3126
|
return vscode_uri_1.URI.file(filePath).toString();
|
|
3127
3127
|
}
|
|
3128
3128
|
exports2.filePathToUri = filePathToUri;
|
|
3129
|
+
function tsFileTextChangesToLspWorkspaceEdit(changes, getScriptInfo) {
|
|
3130
|
+
const workspaceChanges = {};
|
|
3131
|
+
for (const change of changes) {
|
|
3132
|
+
const scriptInfo = getScriptInfo(change.fileName);
|
|
3133
|
+
const uri = filePathToUri(change.fileName);
|
|
3134
|
+
if (scriptInfo === void 0) {
|
|
3135
|
+
continue;
|
|
3136
|
+
}
|
|
3137
|
+
if (!workspaceChanges[uri]) {
|
|
3138
|
+
workspaceChanges[uri] = [];
|
|
3139
|
+
}
|
|
3140
|
+
for (const textChange of change.textChanges) {
|
|
3141
|
+
const textEdit = {
|
|
3142
|
+
newText: textChange.newText,
|
|
3143
|
+
range: tsTextSpanToLspRange(scriptInfo, textChange.span)
|
|
3144
|
+
};
|
|
3145
|
+
workspaceChanges[uri].push(textEdit);
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
return {
|
|
3149
|
+
changes: workspaceChanges
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
3152
|
+
exports2.tsFileTextChangesToLspWorkspaceEdit = tsFileTextChangesToLspWorkspaceEdit;
|
|
3129
3153
|
function tsTextSpanToLspRange(scriptInfo, textSpan) {
|
|
3130
3154
|
const start = scriptInfo.positionToLineOffset(textSpan.start);
|
|
3131
3155
|
const end = scriptInfo.positionToLineOffset(textSpan.start + textSpan.length);
|
|
@@ -3226,9 +3250,9 @@ var require_utils = __commonJS({
|
|
|
3226
3250
|
}
|
|
3227
3251
|
});
|
|
3228
3252
|
|
|
3229
|
-
// dist/server/completion.js
|
|
3253
|
+
// dist/server/src/completion.js
|
|
3230
3254
|
var require_completion = __commonJS({
|
|
3231
|
-
"dist/server/completion.js"(exports2) {
|
|
3255
|
+
"dist/server/src/completion.js"(exports2) {
|
|
3232
3256
|
"use strict";
|
|
3233
3257
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3234
3258
|
if (k2 === void 0)
|
|
@@ -3358,9 +3382,9 @@ var require_completion = __commonJS({
|
|
|
3358
3382
|
}
|
|
3359
3383
|
});
|
|
3360
3384
|
|
|
3361
|
-
// dist/server/diagnostic.js
|
|
3385
|
+
// dist/server/src/diagnostic.js
|
|
3362
3386
|
var require_diagnostic = __commonJS({
|
|
3363
|
-
"dist/server/diagnostic.js"(exports2) {
|
|
3387
|
+
"dist/server/src/diagnostic.js"(exports2) {
|
|
3364
3388
|
"use strict";
|
|
3365
3389
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3366
3390
|
if (k2 === void 0)
|
|
@@ -3524,9 +3548,9 @@ var require_resolver = __commonJS({
|
|
|
3524
3548
|
}
|
|
3525
3549
|
});
|
|
3526
3550
|
|
|
3527
|
-
// dist/server/version_provider.js
|
|
3551
|
+
// dist/server/src/version_provider.js
|
|
3528
3552
|
var require_version_provider = __commonJS({
|
|
3529
|
-
"dist/server/version_provider.js"(exports2) {
|
|
3553
|
+
"dist/server/src/version_provider.js"(exports2) {
|
|
3530
3554
|
"use strict";
|
|
3531
3555
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3532
3556
|
if (k2 === void 0)
|
|
@@ -3647,9 +3671,9 @@ var require_version_provider = __commonJS({
|
|
|
3647
3671
|
}
|
|
3648
3672
|
});
|
|
3649
3673
|
|
|
3650
|
-
// dist/server/ngcc.js
|
|
3674
|
+
// dist/server/src/ngcc.js
|
|
3651
3675
|
var require_ngcc = __commonJS({
|
|
3652
|
-
"dist/server/ngcc.js"(exports2) {
|
|
3676
|
+
"dist/server/src/ngcc.js"(exports2) {
|
|
3653
3677
|
"use strict";
|
|
3654
3678
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3655
3679
|
exports2.resolveAndRunNgcc = void 0;
|
|
@@ -3664,7 +3688,7 @@ var require_ngcc = __commonJS({
|
|
|
3664
3688
|
if (!ngcc) {
|
|
3665
3689
|
throw new Error(`Failed to resolve ngcc from ${directory}`);
|
|
3666
3690
|
}
|
|
3667
|
-
const index = ngcc.resolvedPath.
|
|
3691
|
+
const index = ngcc.resolvedPath.indexOf("node_modules");
|
|
3668
3692
|
const cwd = index > 0 ? ngcc.resolvedPath.slice(0, index) : process.cwd();
|
|
3669
3693
|
const args = [
|
|
3670
3694
|
"--tsconfig",
|
|
@@ -3707,9 +3731,9 @@ var require_ngcc = __commonJS({
|
|
|
3707
3731
|
}
|
|
3708
3732
|
});
|
|
3709
3733
|
|
|
3710
|
-
// dist/server/session.js
|
|
3734
|
+
// dist/server/src/session.js
|
|
3711
3735
|
var require_session = __commonJS({
|
|
3712
|
-
"dist/server/session.js"(exports2) {
|
|
3736
|
+
"dist/server/src/session.js"(exports2) {
|
|
3713
3737
|
"use strict";
|
|
3714
3738
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3715
3739
|
if (k2 === void 0)
|
|
@@ -3766,6 +3790,8 @@ var require_session = __commonJS({
|
|
|
3766
3790
|
(function(NgccErrorMessageAction2) {
|
|
3767
3791
|
NgccErrorMessageAction2[NgccErrorMessageAction2["showOutput"] = 0] = "showOutput";
|
|
3768
3792
|
})(NgccErrorMessageAction || (NgccErrorMessageAction = {}));
|
|
3793
|
+
var defaultFormatOptions = {};
|
|
3794
|
+
var defaultPreferences = {};
|
|
3769
3795
|
var Session = class {
|
|
3770
3796
|
constructor(options) {
|
|
3771
3797
|
this.openFiles = new utils_1.MruTracker();
|
|
@@ -3863,6 +3889,49 @@ var require_session = __commonJS({
|
|
|
3863
3889
|
conn.onCodeLens((p) => this.onCodeLens(p));
|
|
3864
3890
|
conn.onCodeLensResolve((p) => this.onCodeLensResolve(p));
|
|
3865
3891
|
conn.onSignatureHelp((p) => this.onSignatureHelp(p));
|
|
3892
|
+
conn.onCodeAction((p) => this.onCodeAction(p));
|
|
3893
|
+
conn.onCodeActionResolve((p) => this.onCodeActionResolve(p));
|
|
3894
|
+
}
|
|
3895
|
+
onCodeAction(params) {
|
|
3896
|
+
const filePath = (0, utils_1.uriToFilePath)(params.textDocument.uri);
|
|
3897
|
+
const lsInfo = this.getLSAndScriptInfo(params.textDocument);
|
|
3898
|
+
if (!lsInfo) {
|
|
3899
|
+
return null;
|
|
3900
|
+
}
|
|
3901
|
+
const start = (0, utils_1.lspPositionToTsPosition)(lsInfo.scriptInfo, params.range.start);
|
|
3902
|
+
const end = (0, utils_1.lspPositionToTsPosition)(lsInfo.scriptInfo, params.range.end);
|
|
3903
|
+
const errorCodes = params.context.diagnostics.map((diag) => diag.code).filter((code) => typeof code === "number");
|
|
3904
|
+
const codeActions = lsInfo.languageService.getCodeFixesAtPosition(filePath, start, end, errorCodes, defaultFormatOptions, defaultPreferences);
|
|
3905
|
+
const individualCodeFixes = codeActions.map((codeAction) => {
|
|
3906
|
+
return {
|
|
3907
|
+
title: codeAction.description,
|
|
3908
|
+
kind: lsp.CodeActionKind.QuickFix,
|
|
3909
|
+
diagnostics: params.context.diagnostics,
|
|
3910
|
+
edit: (0, utils_1.tsFileTextChangesToLspWorkspaceEdit)(codeAction.changes, (path) => this.projectService.getScriptInfo(path))
|
|
3911
|
+
};
|
|
3912
|
+
});
|
|
3913
|
+
const codeFixesAll = getCodeFixesAll(codeActions, params.textDocument);
|
|
3914
|
+
return [...individualCodeFixes, ...codeFixesAll];
|
|
3915
|
+
}
|
|
3916
|
+
onCodeActionResolve(param) {
|
|
3917
|
+
const codeActionResolve = param.data;
|
|
3918
|
+
const isCodeFixesAll = codeActionResolve.fixId !== void 0;
|
|
3919
|
+
if (!isCodeFixesAll) {
|
|
3920
|
+
return param;
|
|
3921
|
+
}
|
|
3922
|
+
const filePath = (0, utils_1.uriToFilePath)(codeActionResolve.document.uri);
|
|
3923
|
+
const lsInfo = this.getLSAndScriptInfo(codeActionResolve.document);
|
|
3924
|
+
if (!lsInfo) {
|
|
3925
|
+
return param;
|
|
3926
|
+
}
|
|
3927
|
+
const fixesAllChanges = lsInfo.languageService.getCombinedCodeFix({
|
|
3928
|
+
type: "file",
|
|
3929
|
+
fileName: filePath
|
|
3930
|
+
}, codeActionResolve.fixId, defaultFormatOptions, defaultPreferences);
|
|
3931
|
+
return {
|
|
3932
|
+
title: param.title,
|
|
3933
|
+
edit: (0, utils_1.tsFileTextChangesToLspWorkspaceEdit)(fixesAllChanges.changes, (path) => this.projectService.getScriptInfo(path))
|
|
3934
|
+
};
|
|
3866
3935
|
}
|
|
3867
3936
|
isInAngularProject(params) {
|
|
3868
3937
|
const filePath = (0, utils_1.uriToFilePath)(params.textDocument.uri);
|
|
@@ -4198,7 +4267,10 @@ var require_session = __commonJS({
|
|
|
4198
4267
|
} : void 0,
|
|
4199
4268
|
workspace: {
|
|
4200
4269
|
workspaceFolders: { supported: true }
|
|
4201
|
-
}
|
|
4270
|
+
},
|
|
4271
|
+
codeActionProvider: this.ivy ? {
|
|
4272
|
+
resolveProvider: true
|
|
4273
|
+
} : void 0
|
|
4202
4274
|
},
|
|
4203
4275
|
serverOptions
|
|
4204
4276
|
};
|
|
@@ -4619,10 +4691,31 @@ var require_session = __commonJS({
|
|
|
4619
4691
|
function isExternalTemplate(path) {
|
|
4620
4692
|
return !isTypeScriptFile(path);
|
|
4621
4693
|
}
|
|
4694
|
+
function getCodeFixesAll(codeActions, document) {
|
|
4695
|
+
const seenFixId = /* @__PURE__ */ new Set();
|
|
4696
|
+
const lspCodeActions = [];
|
|
4697
|
+
for (const codeAction of codeActions) {
|
|
4698
|
+
const fixId = codeAction.fixId;
|
|
4699
|
+
if (fixId === void 0 || codeAction.fixAllDescription === void 0 || seenFixId.has(fixId)) {
|
|
4700
|
+
continue;
|
|
4701
|
+
}
|
|
4702
|
+
seenFixId.add(fixId);
|
|
4703
|
+
const codeActionResolveData = {
|
|
4704
|
+
fixId,
|
|
4705
|
+
document
|
|
4706
|
+
};
|
|
4707
|
+
lspCodeActions.push({
|
|
4708
|
+
title: codeAction.fixAllDescription,
|
|
4709
|
+
kind: lsp.CodeActionKind.QuickFix,
|
|
4710
|
+
data: codeActionResolveData
|
|
4711
|
+
});
|
|
4712
|
+
}
|
|
4713
|
+
return lspCodeActions;
|
|
4714
|
+
}
|
|
4622
4715
|
}
|
|
4623
4716
|
});
|
|
4624
4717
|
|
|
4625
|
-
// dist/server/server.js
|
|
4718
|
+
// dist/server/src/server.js
|
|
4626
4719
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4627
4720
|
var cmdline_utils_1 = require_cmdline_utils();
|
|
4628
4721
|
var logger_1 = require_logger();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/language-server",
|
|
3
3
|
"description": "LSP server for Angular Language Service",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/angular/vscode-ng-language-service.git"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"ngserver": "./bin/ngserver"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@angular/language-service": "14.
|
|
18
|
+
"@angular/language-service": "14.2.0",
|
|
19
19
|
"vscode-jsonrpc": "6.0.0",
|
|
20
20
|
"vscode-languageserver": "7.0.0",
|
|
21
21
|
"vscode-uri": "3.0.3"
|