typescript-language-server 4.3.0 → 4.3.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/CHANGELOG.md +14 -0
- package/lib/cli.mjs +72 -26
- package/lib/cli.mjs.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [4.3.2](https://github.com/typescript-language-server/typescript-language-server/compare/v4.3.1...v4.3.2) (2024-02-02)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* restore handling of zipfile: schema for neovim + yarn berry ([#862](https://github.com/typescript-language-server/typescript-language-server/issues/862)) ([caca007](https://github.com/typescript-language-server/typescript-language-server/commit/caca0071095557ecc43d8695d922a4cf5e38a2ad))
|
|
10
|
+
|
|
11
|
+
## [4.3.1](https://github.com/typescript-language-server/typescript-language-server/compare/v4.3.0...v4.3.1) (2024-01-12)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* out of date diagnostics after closing and re-opening a file ([#851](https://github.com/typescript-language-server/typescript-language-server/issues/851)) ([f395cd6](https://github.com/typescript-language-server/typescript-language-server/commit/f395cd67fc0fefb06e301eecb3b0af492c6672da))
|
|
17
|
+
|
|
4
18
|
## [4.3.0](https://github.com/typescript-language-server/typescript-language-server/compare/v4.2.0...v4.3.0) (2024-01-08)
|
|
5
19
|
|
|
6
20
|
|
package/lib/cli.mjs
CHANGED
|
@@ -17645,14 +17645,24 @@ class LspDocuments {
|
|
|
17645
17645
|
|
|
17646
17646
|
const file = 'file';
|
|
17647
17647
|
|
|
17648
|
+
const untitled = 'untitled';
|
|
17649
|
+
|
|
17648
17650
|
const git = 'git';
|
|
17649
17651
|
|
|
17650
17652
|
const github = 'github';
|
|
17651
17653
|
|
|
17652
17654
|
const azurerepos = 'azurerepos';
|
|
17653
17655
|
|
|
17656
|
+
const buffer = 'buffer';
|
|
17657
|
+
|
|
17658
|
+
const zipfile = 'zipfile';
|
|
17659
|
+
|
|
17654
17660
|
const vsls = 'vsls';
|
|
17655
17661
|
|
|
17662
|
+
function getSemanticSupportedSchemes() {
|
|
17663
|
+
return [ file, untitled, buffer, zipfile ];
|
|
17664
|
+
}
|
|
17665
|
+
|
|
17656
17666
|
const disabledSchemes = new Set([ git, vsls, github, azurerepos ]);
|
|
17657
17667
|
|
|
17658
17668
|
var TypeScriptServerPlugin;
|
|
@@ -18866,6 +18876,20 @@ class Tracer {
|
|
|
18866
18876
|
}
|
|
18867
18877
|
}
|
|
18868
18878
|
|
|
18879
|
+
class ZipfileURI extends URI {
|
|
18880
|
+
constructor(uri, components) {
|
|
18881
|
+
super(components);
|
|
18882
|
+
this._originalUri = uri;
|
|
18883
|
+
}
|
|
18884
|
+
toString(_skipEncoding = false) {
|
|
18885
|
+
return this._originalUri;
|
|
18886
|
+
}
|
|
18887
|
+
static parse(value, _strict = false) {
|
|
18888
|
+
const uri = URI.parse(value, _strict);
|
|
18889
|
+
return new ZipfileURI(value, uri);
|
|
18890
|
+
}
|
|
18891
|
+
}
|
|
18892
|
+
|
|
18869
18893
|
var ServerState;
|
|
18870
18894
|
|
|
18871
18895
|
(function(ServerState) {
|
|
@@ -18937,11 +18961,18 @@ class ServerInitializingIndicator {
|
|
|
18937
18961
|
}
|
|
18938
18962
|
}
|
|
18939
18963
|
|
|
18964
|
+
const emptyAuthority = 'ts-nul-authority';
|
|
18965
|
+
|
|
18966
|
+
const inMemoryResourcePrefix = '^';
|
|
18967
|
+
|
|
18968
|
+
const RE_IN_MEMORY_FILEPATH = /^\^\/([^/]+)\/([^/]*)\/(.+)$/;
|
|
18969
|
+
|
|
18940
18970
|
class TsClient {
|
|
18941
18971
|
constructor(onCaseInsensitiveFileSystem, logger, lspClient) {
|
|
18942
18972
|
this.apiVersion = API.defaultVersion;
|
|
18943
18973
|
this.typescriptVersionSource = 'bundled';
|
|
18944
18974
|
this.serverState = ServerState.None;
|
|
18975
|
+
this.isNeovimHost = false;
|
|
18945
18976
|
this.workspaceFolders = [];
|
|
18946
18977
|
this.useSyntaxServer = 2;
|
|
18947
18978
|
this.pluginManager = new PluginManager;
|
|
@@ -18967,7 +18998,7 @@ class TsClient {
|
|
|
18967
18998
|
return this.documents.files[0] || this.workspaceFolders[0]?.uri.fsPath;
|
|
18968
18999
|
}
|
|
18969
19000
|
toTsFilePath(stringUri) {
|
|
18970
|
-
if (stringUri.startsWith('zipfile:')) {
|
|
19001
|
+
if (this.isNeovimHost && stringUri.startsWith('zipfile:')) {
|
|
18971
19002
|
return stringUri;
|
|
18972
19003
|
}
|
|
18973
19004
|
const resource = URI.parse(stringUri);
|
|
@@ -18977,7 +19008,7 @@ class TsClient {
|
|
|
18977
19008
|
if (resource.scheme === file) {
|
|
18978
19009
|
return resource.fsPath;
|
|
18979
19010
|
}
|
|
18980
|
-
return
|
|
19011
|
+
return inMemoryResourcePrefix + '/' + resource.scheme + '/' + (resource.authority || emptyAuthority) + (resource.path.startsWith('/') ? resource.path : '/' + resource.path) + (resource.fragment ? '#' + resource.fragment : '');
|
|
18981
19012
|
}
|
|
18982
19013
|
toOpenDocument(textDocumentUri, options = {}) {
|
|
18983
19014
|
const filepath = this.toTsFilePath(textDocumentUri);
|
|
@@ -18998,13 +19029,25 @@ class TsClient {
|
|
|
18998
19029
|
return this.documents.hasPendingDiagnostics(resource);
|
|
18999
19030
|
}
|
|
19000
19031
|
toResource(filepath) {
|
|
19001
|
-
if (filepath.startsWith('zipfile:')) {
|
|
19002
|
-
return
|
|
19032
|
+
if (this.isNeovimHost && filepath.startsWith('zipfile:')) {
|
|
19033
|
+
return ZipfileURI.parse(filepath);
|
|
19034
|
+
}
|
|
19035
|
+
if (filepath.startsWith(inMemoryResourcePrefix)) {
|
|
19036
|
+
const parts = filepath.match(RE_IN_MEMORY_FILEPATH);
|
|
19037
|
+
if (parts) {
|
|
19038
|
+
const resource = URI.parse(parts[1] + '://' + (parts[2] === emptyAuthority ? '' : parts[2]) + '/' + parts[3]);
|
|
19039
|
+
const tsFilepath = this.toTsFilePath(resource.toString());
|
|
19040
|
+
const document = tsFilepath && this.documents.get(tsFilepath);
|
|
19041
|
+
return document ? document.uri : resource;
|
|
19042
|
+
}
|
|
19003
19043
|
}
|
|
19004
19044
|
const fileUri = URI.file(filepath);
|
|
19005
19045
|
const document = this.documents.get(fileUri.fsPath);
|
|
19006
19046
|
return document ? document.uri : fileUri;
|
|
19007
19047
|
}
|
|
19048
|
+
toResourceUri(filepath) {
|
|
19049
|
+
return this.toResource(filepath).toString();
|
|
19050
|
+
}
|
|
19008
19051
|
getWorkspaceRootForResource(resource) {
|
|
19009
19052
|
for (const root of this.workspaceFolders.sort(((a, b) => a.uri.fsPath.length - b.uri.fsPath.length))) {
|
|
19010
19053
|
if (root.uri.scheme === resource.scheme && root.uri.authority === resource.authority) {
|
|
@@ -19031,7 +19074,7 @@ class TsClient {
|
|
|
19031
19074
|
switch (capability) {
|
|
19032
19075
|
case ClientCapability.Semantic:
|
|
19033
19076
|
{
|
|
19034
|
-
return
|
|
19077
|
+
return getSemanticSupportedSchemes().includes(resource.scheme);
|
|
19035
19078
|
}
|
|
19036
19079
|
|
|
19037
19080
|
case ClientCapability.Syntax:
|
|
@@ -19052,6 +19095,7 @@ class TsClient {
|
|
|
19052
19095
|
start(workspaceRoot, options) {
|
|
19053
19096
|
this.apiVersion = options.typescriptVersion.version || API.defaultVersion;
|
|
19054
19097
|
this.typescriptVersionSource = options.typescriptVersion.source;
|
|
19098
|
+
this.isNeovimHost = options.hostInfo === 'neovim';
|
|
19055
19099
|
this.tracer = new Tracer(this.tsserverLogger, options.trace);
|
|
19056
19100
|
this.workspaceFolders = workspaceRoot ? [ {
|
|
19057
19101
|
uri: URI.file(workspaceRoot)
|
|
@@ -19391,9 +19435,9 @@ var Location;
|
|
|
19391
19435
|
})(Location || (Location = {}));
|
|
19392
19436
|
|
|
19393
19437
|
function toLocation(fileSpan, client) {
|
|
19394
|
-
const uri = client.
|
|
19438
|
+
const uri = client.toResourceUri(fileSpan.file);
|
|
19395
19439
|
return {
|
|
19396
|
-
uri: uri
|
|
19440
|
+
uri: uri,
|
|
19397
19441
|
range: {
|
|
19398
19442
|
start: Position.fromLocation(fileSpan.start),
|
|
19399
19443
|
end: Position.fromLocation(fileSpan.end)
|
|
@@ -19505,11 +19549,11 @@ function toTextEdit(edit) {
|
|
|
19505
19549
|
}
|
|
19506
19550
|
|
|
19507
19551
|
function toTextDocumentEdit(change, client) {
|
|
19508
|
-
const uri = client.
|
|
19509
|
-
const document = client.toOpenDocument(uri
|
|
19552
|
+
const uri = client.toResourceUri(change.fileName);
|
|
19553
|
+
const document = client.toOpenDocument(uri);
|
|
19510
19554
|
return {
|
|
19511
19555
|
textDocument: {
|
|
19512
|
-
uri: uri
|
|
19556
|
+
uri: uri,
|
|
19513
19557
|
version: document?.version ?? null
|
|
19514
19558
|
},
|
|
19515
19559
|
edits: change.textChanges.map((c => toTextEdit(c)))
|
|
@@ -19574,8 +19618,8 @@ class FileDiagnostics {
|
|
|
19574
19618
|
return result;
|
|
19575
19619
|
}
|
|
19576
19620
|
onDidClose() {
|
|
19577
|
-
this.publishDiagnostics();
|
|
19578
19621
|
this.diagnosticsPerKind.clear();
|
|
19622
|
+
this.publishDiagnostics();
|
|
19579
19623
|
this.closed = true;
|
|
19580
19624
|
}
|
|
19581
19625
|
async waitForDiagnosticsForTesting() {
|
|
@@ -19607,7 +19651,7 @@ class DiagnosticEventQueue {
|
|
|
19607
19651
|
if (this.ignoredDiagnosticCodes.size) {
|
|
19608
19652
|
diagnostics = diagnostics.filter((diagnostic => !this.isDiagnosticIgnored(diagnostic)));
|
|
19609
19653
|
}
|
|
19610
|
-
const uri = this.client.
|
|
19654
|
+
const uri = this.client.toResourceUri(file);
|
|
19611
19655
|
const diagnosticsForFile = this.diagnostics.get(uri) || new FileDiagnostics(uri, this.publishDiagnostics, this.client, this.features);
|
|
19612
19656
|
diagnosticsForFile.update(kind, diagnostics);
|
|
19613
19657
|
this.diagnostics.set(uri, diagnosticsForFile);
|
|
@@ -19616,16 +19660,17 @@ class DiagnosticEventQueue {
|
|
|
19616
19660
|
this.ignoredDiagnosticCodes = new Set(ignoredCodes);
|
|
19617
19661
|
}
|
|
19618
19662
|
getDiagnosticsForFile(file) {
|
|
19619
|
-
const uri = this.client.
|
|
19663
|
+
const uri = this.client.toResourceUri(file);
|
|
19620
19664
|
return this.diagnostics.get(uri)?.getDiagnostics() || [];
|
|
19621
19665
|
}
|
|
19622
19666
|
onDidCloseFile(file) {
|
|
19623
|
-
const uri = this.client.
|
|
19667
|
+
const uri = this.client.toResourceUri(file);
|
|
19624
19668
|
const diagnosticsForFile = this.diagnostics.get(uri);
|
|
19625
19669
|
diagnosticsForFile?.onDidClose();
|
|
19670
|
+
this.diagnostics.delete(uri);
|
|
19626
19671
|
}
|
|
19627
19672
|
async waitForDiagnosticsForTesting(file) {
|
|
19628
|
-
const uri = this.client.
|
|
19673
|
+
const uri = this.client.toResourceUri(file);
|
|
19629
19674
|
let diagnosticsForFile = this.diagnostics.get(uri);
|
|
19630
19675
|
if (diagnosticsForFile) {
|
|
19631
19676
|
diagnosticsForFile.onDidClose();
|
|
@@ -19655,7 +19700,7 @@ class SourceDefinitionCommand {
|
|
|
19655
19700
|
lspClient.showErrorMessage('Go to Source Definition failed. No resource provided.');
|
|
19656
19701
|
return;
|
|
19657
19702
|
}
|
|
19658
|
-
const document = client.toOpenDocument(client.
|
|
19703
|
+
const document = client.toOpenDocument(client.toResourceUri(file));
|
|
19659
19704
|
if (!document) {
|
|
19660
19705
|
lspClient.showErrorMessage('Go to Source Definition failed. File not opened in the editor.');
|
|
19661
19706
|
return;
|
|
@@ -20740,7 +20785,7 @@ function fromProtocolCallHierarchyItem(item, client, workspaceRoot) {
|
|
|
20740
20785
|
kind: fromProtocolScriptElementKind(item.kind),
|
|
20741
20786
|
name: name,
|
|
20742
20787
|
detail: detail,
|
|
20743
|
-
uri: client.
|
|
20788
|
+
uri: client.toResourceUri(item.file),
|
|
20744
20789
|
range: Range.fromTextSpan(item.span),
|
|
20745
20790
|
selectionRange: Range.fromTextSpan(item.selectionSpan)
|
|
20746
20791
|
};
|
|
@@ -21509,7 +21554,7 @@ class TypeScriptImplementationsCodeLensProvider extends TypeScriptBaseCodeLensPr
|
|
|
21509
21554
|
codeLens.command = response.type === 'cancelled' ? TypeScriptBaseCodeLensProvider.cancelledCommand : TypeScriptBaseCodeLensProvider.errorCommand;
|
|
21510
21555
|
return codeLens;
|
|
21511
21556
|
}
|
|
21512
|
-
const locations = response.body.map((reference => main$2.Location.create(this.client.
|
|
21557
|
+
const locations = response.body.map((reference => main$2.Location.create(this.client.toResourceUri(reference.file), reference.start.line === reference.end.line ? Range.fromTextSpan(reference) : main$2.Range.create(Position.fromLocation(reference.start), main$2.Position.create(reference.start.line, 0))))).filter((location => !(location.uri.toString() === codeLens.data.uri && location.range.start.line === codeLens.range.start.line && location.range.start.character === codeLens.range.start.character)));
|
|
21513
21558
|
codeLens.command = this.getCommand(locations, codeLens);
|
|
21514
21559
|
return codeLens;
|
|
21515
21560
|
}
|
|
@@ -21564,7 +21609,7 @@ class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLensProvide
|
|
|
21564
21609
|
codeLens.command = response.type === 'cancelled' ? TypeScriptBaseCodeLensProvider.cancelledCommand : TypeScriptBaseCodeLensProvider.errorCommand;
|
|
21565
21610
|
return codeLens;
|
|
21566
21611
|
}
|
|
21567
|
-
const locations = response.body.refs.filter((reference => !reference.isDefinition)).map((reference => Location.fromTextSpan(this.client.
|
|
21612
|
+
const locations = response.body.refs.filter((reference => !reference.isDefinition)).map((reference => Location.fromTextSpan(this.client.toResourceUri(reference.file), reference)));
|
|
21568
21613
|
codeLens.command = {
|
|
21569
21614
|
title: this.getCodeLensLabel(locations),
|
|
21570
21615
|
command: locations.length ? 'editor.action.showReferences' : '',
|
|
@@ -22386,6 +22431,7 @@ class LspServer {
|
|
|
22386
22431
|
disableAutomaticTypingAcquisition: disableAutomaticTypingAcquisition,
|
|
22387
22432
|
maxTsServerMemory: maxTsServerMemory,
|
|
22388
22433
|
npmLocation: npmLocation,
|
|
22434
|
+
hostInfo: hostInfo,
|
|
22389
22435
|
locale: locale,
|
|
22390
22436
|
plugins: plugins || [],
|
|
22391
22437
|
onEvent: this.onTsEvent.bind(this),
|
|
@@ -22707,7 +22753,7 @@ class LspServer {
|
|
|
22707
22753
|
}
|
|
22708
22754
|
async completionResolve(item, token) {
|
|
22709
22755
|
item.data = item.data?.cacheId !== undefined ? this.completionDataCache.get(item.data.cacheId) : item.data;
|
|
22710
|
-
const uri = this.tsClient.
|
|
22756
|
+
const uri = this.tsClient.toResourceUri(item.data.file);
|
|
22711
22757
|
const document = item.data?.file ? this.tsClient.toOpenDocument(uri) : undefined;
|
|
22712
22758
|
if (!document) {
|
|
22713
22759
|
return item;
|
|
@@ -22780,7 +22826,7 @@ class LspServer {
|
|
|
22780
22826
|
}
|
|
22781
22827
|
const changes = {};
|
|
22782
22828
|
result.locs.forEach((spanGroup => {
|
|
22783
|
-
const uri = this.tsClient.
|
|
22829
|
+
const uri = this.tsClient.toResourceUri(spanGroup.file);
|
|
22784
22830
|
const textEdits = changes[uri] || (changes[uri] = []);
|
|
22785
22831
|
spanGroup.locs.forEach((textSpan => {
|
|
22786
22832
|
textEdits.push({
|
|
@@ -22976,7 +23022,7 @@ class LspServer {
|
|
|
22976
23022
|
if (renameLocation) {
|
|
22977
23023
|
await this.options.lspClient.rename({
|
|
22978
23024
|
textDocument: {
|
|
22979
|
-
uri: this.tsClient.
|
|
23025
|
+
uri: this.tsClient.toResourceUri(args.file)
|
|
22980
23026
|
},
|
|
22981
23027
|
position: Position.fromLocation(renameLocation)
|
|
22982
23028
|
});
|
|
@@ -22986,7 +23032,7 @@ class LspServer {
|
|
|
22986
23032
|
this.tsClient.configurePlugin(pluginName, configuration);
|
|
22987
23033
|
} else if (params.command === Commands.ORGANIZE_IMPORTS && params.arguments) {
|
|
22988
23034
|
const file = params.arguments[0];
|
|
22989
|
-
const uri = this.tsClient.
|
|
23035
|
+
const uri = this.tsClient.toResourceUri(file);
|
|
22990
23036
|
const document = this.tsClient.toOpenDocument(uri);
|
|
22991
23037
|
if (!document) {
|
|
22992
23038
|
return;
|
|
@@ -23043,7 +23089,7 @@ class LspServer {
|
|
|
23043
23089
|
}
|
|
23044
23090
|
const changes = {};
|
|
23045
23091
|
for (const edit of edits) {
|
|
23046
|
-
changes[this.tsClient.
|
|
23092
|
+
changes[this.tsClient.toResourceUri(edit.fileName)] = edit.textChanges.map(toTextEdit);
|
|
23047
23093
|
}
|
|
23048
23094
|
const {applied: applied} = await this.options.lspClient.applyWorkspaceEdit({
|
|
23049
23095
|
edit: {
|
|
@@ -23057,7 +23103,7 @@ class LspServer {
|
|
|
23057
23103
|
for (const rename of params.files) {
|
|
23058
23104
|
const codeEdits = await this.getEditsForFileRename(rename.oldUri, rename.newUri, token);
|
|
23059
23105
|
for (const codeEdit of codeEdits) {
|
|
23060
|
-
const uri = this.tsClient.
|
|
23106
|
+
const uri = this.tsClient.toResourceUri(codeEdit.fileName);
|
|
23061
23107
|
const textEdits = changes[uri] || (changes[uri] = []);
|
|
23062
23108
|
textEdits.push(...codeEdit.textChanges.map(toTextEdit));
|
|
23063
23109
|
}
|
|
@@ -23133,7 +23179,7 @@ class LspServer {
|
|
|
23133
23179
|
}
|
|
23134
23180
|
return response.body.map((item => ({
|
|
23135
23181
|
location: {
|
|
23136
|
-
uri: this.tsClient.
|
|
23182
|
+
uri: this.tsClient.toResourceUri(item.file),
|
|
23137
23183
|
range: {
|
|
23138
23184
|
start: Position.fromLocation(item.start),
|
|
23139
23185
|
end: Position.fromLocation(item.end)
|