typescript-language-server 4.1.0 → 4.1.1
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 +7 -0
- package/lib/cli.mjs +33 -5
- package/lib/cli.mjs.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [4.1.1](https://github.com/typescript-language-server/typescript-language-server/compare/v4.1.0...v4.1.1) (2023-11-13)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* try to infer languageId from extension when invalid provided ([#799](https://github.com/typescript-language-server/typescript-language-server/issues/799)) ([994186e](https://github.com/typescript-language-server/typescript-language-server/commit/994186e629494545f855d0859f5a058529e64c95))
|
|
10
|
+
|
|
4
11
|
## [4.1.0](https://github.com/typescript-language-server/typescript-language-server/compare/v4.0.0...v4.1.0) (2023-11-08)
|
|
5
12
|
|
|
6
13
|
|
package/lib/cli.mjs
CHANGED
|
@@ -25,7 +25,7 @@ import require$$0$3 from 'url';
|
|
|
25
25
|
|
|
26
26
|
import * as path$e from 'node:path';
|
|
27
27
|
|
|
28
|
-
import path__default, { resolve as resolve$1 } from 'node:path';
|
|
28
|
+
import path__default, { extname, resolve as resolve$1 } from 'node:path';
|
|
29
29
|
|
|
30
30
|
import require$$0$5 from 'constants';
|
|
31
31
|
|
|
@@ -17409,6 +17409,24 @@ function mode2ScriptKind(mode) {
|
|
|
17409
17409
|
return undefined;
|
|
17410
17410
|
}
|
|
17411
17411
|
|
|
17412
|
+
function getModeFromFileUri(uri) {
|
|
17413
|
+
const extension = extname(uri).toUpperCase();
|
|
17414
|
+
switch (extension) {
|
|
17415
|
+
case '.TS':
|
|
17416
|
+
return typescript;
|
|
17417
|
+
|
|
17418
|
+
case '.TSX':
|
|
17419
|
+
return typescriptreact;
|
|
17420
|
+
|
|
17421
|
+
case '.JS':
|
|
17422
|
+
return javascript;
|
|
17423
|
+
|
|
17424
|
+
case '.JSX':
|
|
17425
|
+
return javascriptreact;
|
|
17426
|
+
}
|
|
17427
|
+
return undefined;
|
|
17428
|
+
}
|
|
17429
|
+
|
|
17412
17430
|
class PendingDiagnostics extends ResourceMap {
|
|
17413
17431
|
getOrderedFileSet() {
|
|
17414
17432
|
const orderedResources = Array.from(this.entries()).sort(((a, b) => a.value - b.value)).map((entry => entry.resource));
|
|
@@ -17542,12 +17560,13 @@ class LspDocument {
|
|
|
17542
17560
|
}
|
|
17543
17561
|
|
|
17544
17562
|
class LspDocuments {
|
|
17545
|
-
constructor(client, onCaseInsensitiveFileSystem) {
|
|
17563
|
+
constructor(client, lspClient, onCaseInsensitiveFileSystem) {
|
|
17546
17564
|
this._validateJavaScript = true;
|
|
17547
17565
|
this._validateTypeScript = true;
|
|
17548
17566
|
this._files = [];
|
|
17549
17567
|
this.documents = new Map;
|
|
17550
17568
|
this.client = client;
|
|
17569
|
+
this.lspClient = lspClient;
|
|
17551
17570
|
this.modeIds = new Set(jsTsLanguageModes);
|
|
17552
17571
|
const pathNormalizer = path => this.client.toTsFilePath(path.toString());
|
|
17553
17572
|
this.pendingDiagnostics = new PendingDiagnostics(pathNormalizer, {
|
|
@@ -17574,7 +17593,16 @@ class LspDocuments {
|
|
|
17574
17593
|
}
|
|
17575
17594
|
openTextDocument(textDocument) {
|
|
17576
17595
|
if (!this.modeIds.has(textDocument.languageId)) {
|
|
17577
|
-
|
|
17596
|
+
const detectedLanguageId = getModeFromFileUri(textDocument.uri);
|
|
17597
|
+
if (detectedLanguageId) {
|
|
17598
|
+
this.lspClient.logMessage({
|
|
17599
|
+
type: main$3.MessageType.Warning,
|
|
17600
|
+
message: `Invalid langaugeId "${textDocument.languageId}" provided for uri "${textDocument.uri}". Correcting to "${detectedLanguageId}"`
|
|
17601
|
+
});
|
|
17602
|
+
textDocument.languageId = detectedLanguageId;
|
|
17603
|
+
} else {
|
|
17604
|
+
return false;
|
|
17605
|
+
}
|
|
17578
17606
|
}
|
|
17579
17607
|
const resource = textDocument.uri;
|
|
17580
17608
|
const filepath = this.client.toTsFilePath(resource);
|
|
@@ -19024,7 +19052,7 @@ class TsClient {
|
|
|
19024
19052
|
this.serverState = ServerState.None;
|
|
19025
19053
|
this.workspaceFolders = [];
|
|
19026
19054
|
this.useSyntaxServer = 2;
|
|
19027
|
-
this.documents = new LspDocuments(this, onCaseInsensitiveFileSystem);
|
|
19055
|
+
this.documents = new LspDocuments(this, lspClient, onCaseInsensitiveFileSystem);
|
|
19028
19056
|
this.logger = new PrefixingLogger(logger, '[tsclient]');
|
|
19029
19057
|
this.tsserverLogger = new PrefixingLogger(this.logger, '[tsserver]');
|
|
19030
19058
|
this.lspClient = lspClient;
|
|
@@ -22615,7 +22643,7 @@ class LspServer {
|
|
|
22615
22643
|
throw new Error(`Can't open already open document: ${params.textDocument.uri}`);
|
|
22616
22644
|
}
|
|
22617
22645
|
if (!this.tsClient.openTextDocument(params.textDocument)) {
|
|
22618
|
-
throw new Error(`Cannot open document '${params.textDocument.uri}'.`);
|
|
22646
|
+
throw new Error(`Cannot open document '${params.textDocument.uri}' (languageId: ${params.textDocument.languageId}).`);
|
|
22619
22647
|
}
|
|
22620
22648
|
}
|
|
22621
22649
|
didCloseTextDocument(params) {
|