@astrojs/language-server 0.9.3 → 0.12.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 +22 -0
- package/bin/browserServer.js +3 -0
- package/bin/nodeServer.js +3 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +8 -0
- package/dist/check.js +2 -5
- package/dist/core/DiagnosticsManager.d.ts +3 -3
- package/dist/core/DiagnosticsManager.js +2 -2
- package/dist/core/config/ConfigManager.d.ts +19 -164
- package/dist/core/config/ConfigManager.js +62 -101
- package/dist/core/config/index.d.ts +1 -0
- package/dist/core/config/index.js +6 -1
- package/dist/core/config/interfaces.d.ts +123 -0
- package/dist/core/config/interfaces.js +2 -0
- package/dist/core/documents/AstroDocument.d.ts +18 -0
- package/dist/core/documents/AstroDocument.js +37 -0
- package/dist/core/documents/DocumentBase.d.ts +10 -2
- package/dist/core/documents/DocumentBase.js +15 -50
- package/dist/core/documents/DocumentManager.d.ts +12 -16
- package/dist/core/documents/DocumentManager.js +32 -26
- package/dist/core/documents/DocumentMapper.js +3 -1
- package/dist/core/documents/index.d.ts +1 -1
- package/dist/core/documents/index.js +6 -2
- package/dist/core/documents/parseAstro.d.ts +2 -2
- package/dist/core/documents/parseHtml.d.ts +2 -2
- package/dist/core/documents/parseHtml.js +4 -1
- package/dist/core/documents/utils.d.ts +22 -26
- package/dist/core/documents/utils.js +96 -134
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/node.d.ts +1 -0
- package/dist/node.js +29 -0
- package/dist/plugins/PluginHost.d.ts +10 -9
- package/dist/plugins/PluginHost.js +30 -36
- package/dist/plugins/astro/AstroPlugin.d.ts +11 -12
- package/dist/plugins/astro/AstroPlugin.js +17 -38
- package/dist/plugins/astro/features/{CompletionProvider.d.ts → CompletionsProvider.d.ts} +5 -5
- package/dist/plugins/astro/features/{CompletionProvider.js → CompletionsProvider.js} +33 -54
- package/dist/plugins/css/CSSDocument.d.ts +3 -3
- package/dist/plugins/css/CSSDocument.js +7 -16
- package/dist/plugins/css/CSSPlugin.d.ts +22 -12
- package/dist/plugins/css/CSSPlugin.js +112 -41
- package/dist/plugins/css/StyleAttributeDocument.d.ts +2 -2
- package/dist/plugins/css/StyleAttributeDocument.js +2 -2
- package/dist/plugins/css/features/astro-selectors.d.ts +2 -0
- package/dist/plugins/css/features/astro-selectors.js +16 -0
- package/dist/plugins/css/features/{getIdClassCompletion.d.ts → getIdClassCompletions.d.ts} +3 -3
- package/dist/plugins/css/features/{getIdClassCompletion.js → getIdClassCompletions.js} +10 -9
- package/dist/plugins/css/{service.d.ts → language-service.d.ts} +0 -0
- package/dist/plugins/css/{service.js → language-service.js} +2 -1
- package/dist/plugins/html/HTMLPlugin.d.ts +15 -17
- package/dist/plugins/html/HTMLPlugin.js +33 -41
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/index.js +7 -3
- package/dist/plugins/interfaces.d.ts +35 -48
- package/dist/plugins/typescript/LanguageServiceManager.d.ts +33 -14
- package/dist/plugins/typescript/LanguageServiceManager.js +57 -32
- package/dist/plugins/typescript/TypeScriptPlugin.d.ts +16 -23
- package/dist/plugins/typescript/TypeScriptPlugin.js +48 -56
- package/dist/plugins/typescript/astro-sys.d.ts +5 -3
- package/dist/plugins/typescript/astro-sys.js +24 -41
- package/dist/plugins/typescript/features/CompletionsProvider.d.ts +6 -6
- package/dist/plugins/typescript/features/CompletionsProvider.js +17 -33
- package/dist/plugins/typescript/features/DiagnosticsProvider.d.ts +4 -4
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +22 -61
- package/dist/plugins/typescript/features/HoverProvider.d.ts +4 -5
- package/dist/plugins/typescript/features/HoverProvider.js +9 -10
- package/dist/plugins/typescript/features/SignatureHelpProvider.d.ts +4 -5
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +15 -11
- package/dist/plugins/typescript/features/utils.d.ts +1 -12
- package/dist/plugins/typescript/features/utils.js +2 -22
- package/dist/plugins/typescript/language-service.d.ts +38 -0
- package/dist/plugins/typescript/language-service.js +222 -0
- package/dist/plugins/typescript/module-loader.d.ts +5 -8
- package/dist/plugins/typescript/module-loader.js +43 -23
- package/dist/plugins/typescript/{DocumentSnapshot.d.ts → snapshots/DocumentSnapshot.d.ts} +45 -42
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.js +135 -0
- package/dist/plugins/typescript/snapshots/SnapshotManager.d.ts +42 -0
- package/dist/plugins/typescript/snapshots/SnapshotManager.js +197 -0
- package/dist/plugins/typescript/snapshots/utils.d.ts +28 -0
- package/dist/plugins/typescript/snapshots/utils.js +84 -0
- package/dist/plugins/typescript/utils.d.ts +10 -11
- package/dist/plugins/typescript/utils.js +122 -151
- package/dist/server.d.ts +2 -4
- package/dist/server.js +91 -54
- package/dist/utils.d.ts +16 -8
- package/dist/utils.js +29 -14
- package/package.json +19 -13
- package/bin/server.js +0 -7
- package/dist/core/documents/Document.d.ts +0 -51
- package/dist/core/documents/Document.js +0 -135
- package/dist/plugins/typescript/DocumentSnapshot.js +0 -202
- package/dist/plugins/typescript/SnapshotManager.d.ts +0 -24
- package/dist/plugins/typescript/SnapshotManager.js +0 -97
- package/dist/plugins/typescript/languageService.d.ts +0 -17
- package/dist/plugins/typescript/languageService.js +0 -169
- package/types/index.d.ts +0 -4
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createFromFrameworkFilePath = exports.createFromAstroFilePath = exports.createFromTSFilePath = exports.createFromNonAstroFilePath = exports.createFromFilePath = exports.createFromDocument = void 0;
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
const astro2tsx_1 = __importDefault(require("../astro2tsx"));
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const DocumentSnapshot_1 = require("./DocumentSnapshot");
|
|
11
|
+
const svelte_language_integration_1 = require("@astrojs/svelte-language-integration");
|
|
12
|
+
// Utilities to create Snapshots from different contexts
|
|
13
|
+
function createFromDocument(document) {
|
|
14
|
+
const { code } = (0, astro2tsx_1.default)(document.getText());
|
|
15
|
+
return new DocumentSnapshot_1.AstroSnapshot(document, code, typescript_1.default.ScriptKind.TSX);
|
|
16
|
+
}
|
|
17
|
+
exports.createFromDocument = createFromDocument;
|
|
18
|
+
/**
|
|
19
|
+
* Returns an Astro or Framework or a ts/js snapshot from a file path, depending on the file contents.
|
|
20
|
+
* @param filePath path to the file
|
|
21
|
+
* @param createDocument function that is used to create a document in case it's an Astro file
|
|
22
|
+
*/
|
|
23
|
+
function createFromFilePath(filePath, createDocument) {
|
|
24
|
+
if ((0, utils_1.isAstroFilePath)(filePath)) {
|
|
25
|
+
return createFromAstroFilePath(filePath, createDocument);
|
|
26
|
+
}
|
|
27
|
+
else if ((0, utils_1.isFrameworkFilePath)(filePath)) {
|
|
28
|
+
const framework = (0, utils_1.getFrameworkFromFilePath)(filePath);
|
|
29
|
+
return createFromFrameworkFilePath(filePath, framework);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return createFromTSFilePath(filePath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.createFromFilePath = createFromFilePath;
|
|
36
|
+
/**
|
|
37
|
+
* Return a Framework or a TS snapshot from a file path, depending on the file contents
|
|
38
|
+
* Unlike createFromFilePath, this does not support creating an Astro snapshot
|
|
39
|
+
*/
|
|
40
|
+
function createFromNonAstroFilePath(filePath) {
|
|
41
|
+
if ((0, utils_1.isFrameworkFilePath)(filePath)) {
|
|
42
|
+
const framework = (0, utils_1.getFrameworkFromFilePath)(filePath);
|
|
43
|
+
return createFromFrameworkFilePath(filePath, framework);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return createFromTSFilePath(filePath);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.createFromNonAstroFilePath = createFromNonAstroFilePath;
|
|
50
|
+
/**
|
|
51
|
+
* Returns a ts/js snapshot from a file path.
|
|
52
|
+
* @param filePath path to the js/ts file
|
|
53
|
+
* @param options options that apply in case it's a svelte file
|
|
54
|
+
*/
|
|
55
|
+
function createFromTSFilePath(filePath) {
|
|
56
|
+
var _a;
|
|
57
|
+
const originalText = (_a = typescript_1.default.sys.readFile(filePath)) !== null && _a !== void 0 ? _a : '';
|
|
58
|
+
return new DocumentSnapshot_1.TypeScriptDocumentSnapshot(0, filePath, originalText);
|
|
59
|
+
}
|
|
60
|
+
exports.createFromTSFilePath = createFromTSFilePath;
|
|
61
|
+
/**
|
|
62
|
+
* Returns an Astro snapshot from a file path.
|
|
63
|
+
* @param filePath path to the Astro file
|
|
64
|
+
* @param createDocument function that is used to create a document
|
|
65
|
+
*/
|
|
66
|
+
function createFromAstroFilePath(filePath, createDocument) {
|
|
67
|
+
var _a;
|
|
68
|
+
const originalText = (_a = typescript_1.default.sys.readFile(filePath)) !== null && _a !== void 0 ? _a : '';
|
|
69
|
+
return createFromDocument(createDocument(filePath, originalText));
|
|
70
|
+
}
|
|
71
|
+
exports.createFromAstroFilePath = createFromAstroFilePath;
|
|
72
|
+
function createFromFrameworkFilePath(filePath, framework) {
|
|
73
|
+
var _a;
|
|
74
|
+
const originalText = (_a = typescript_1.default.sys.readFile(filePath)) !== null && _a !== void 0 ? _a : '';
|
|
75
|
+
let code = '';
|
|
76
|
+
if (framework === 'svelte') {
|
|
77
|
+
code = (0, svelte_language_integration_1.toTSX)(originalText);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
code = 'export default function() {}';
|
|
81
|
+
}
|
|
82
|
+
return new DocumentSnapshot_1.TypeScriptDocumentSnapshot(0, filePath, code, typescript_1.default.ScriptKind.TSX);
|
|
83
|
+
}
|
|
84
|
+
exports.createFromFrameworkFilePath = createFromFrameworkFilePath;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ts from 'typescript';
|
|
2
2
|
import { CompletionItemKind, DiagnosticSeverity, Position, Range } from 'vscode-languageserver';
|
|
3
|
-
import { SnapshotFragment } from './DocumentSnapshot';
|
|
3
|
+
import { SnapshotFragment } from './snapshots/DocumentSnapshot';
|
|
4
4
|
export declare function scriptElementKindToCompletionItemKind(kind: ts.ScriptElementKind): CompletionItemKind;
|
|
5
5
|
export declare function getCommitCharactersForScriptElement(kind: ts.ScriptElementKind): string[] | undefined;
|
|
6
|
-
export declare function mapSeverity(category: ts.DiagnosticCategory): DiagnosticSeverity;
|
|
7
|
-
export declare function getScriptKindFromFileName(fileName: string): ts.ScriptKind;
|
|
8
6
|
export declare function getExtensionFromScriptKind(kind: ts.ScriptKind | undefined): ts.Extension;
|
|
7
|
+
export declare function findTsConfigPath(fileName: string, rootUris: string[]): string;
|
|
8
|
+
export declare function isSubPath(uri: string, possibleSubPath: string): boolean;
|
|
9
|
+
export declare function getScriptKindFromFileName(fileName: string): ts.ScriptKind;
|
|
10
|
+
export declare function mapSeverity(category: ts.DiagnosticCategory): DiagnosticSeverity;
|
|
9
11
|
export declare function convertRange(document: {
|
|
10
12
|
positionAt: (offset: number) => Position;
|
|
11
13
|
}, range: {
|
|
@@ -13,22 +15,19 @@ export declare function convertRange(document: {
|
|
|
13
15
|
length?: number;
|
|
14
16
|
}): Range;
|
|
15
17
|
export declare function convertToLocationRange(defDoc: SnapshotFragment, textSpan: ts.TextSpan): Range;
|
|
16
|
-
declare type FrameworkExt = 'astro' | 'vue' | 'jsx' | 'tsx' | 'svelte';
|
|
18
|
+
export declare type FrameworkExt = 'astro' | 'vue' | 'jsx' | 'tsx' | 'svelte';
|
|
17
19
|
declare type FrameworkVirtualExt = 'ts' | 'tsx';
|
|
20
|
+
export declare function getFrameworkFromFilePath(filePath: string): FrameworkExt;
|
|
18
21
|
export declare function isVirtualFrameworkFilePath(ext: FrameworkExt, virtualExt: FrameworkVirtualExt, filePath: string): boolean;
|
|
19
22
|
export declare function isAstroFilePath(filePath: string): boolean;
|
|
23
|
+
export declare function isFrameworkFilePath(filePath: string): boolean;
|
|
20
24
|
export declare function isVirtualAstroFilePath(filePath: string): boolean;
|
|
21
25
|
export declare function isVirtualVueFilePath(filePath: string): boolean;
|
|
22
|
-
export declare function isVirtualJsxFilePath(filePath: string): boolean;
|
|
23
26
|
export declare function isVirtualSvelteFilePath(filePath: string): boolean;
|
|
24
27
|
export declare function isVirtualFilePath(filePath: string): boolean;
|
|
25
28
|
export declare function toVirtualAstroFilePath(filePath: string): string;
|
|
29
|
+
export declare function toVirtualFilePath(filePath: string): string;
|
|
26
30
|
export declare function toRealAstroFilePath(filePath: string): string;
|
|
27
31
|
export declare function ensureRealAstroFilePath(filePath: string): string;
|
|
28
32
|
export declare function ensureRealFilePath(filePath: string): string;
|
|
29
|
-
export declare function findTsConfigPath(fileName: string, rootUris: string[]): string;
|
|
30
|
-
/** */
|
|
31
|
-
export declare function isSubPath(uri: string, possibleSubPath: string): boolean;
|
|
32
|
-
/** Substitutes */
|
|
33
|
-
export declare function substituteWithWhitespace(result: string, start: number, end: number, oldContent: string, before: string, after: string): string;
|
|
34
33
|
export {};
|
|
@@ -1,69 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
23
|
-
const
|
|
24
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
6
|
+
exports.ensureRealFilePath = exports.ensureRealAstroFilePath = exports.toRealAstroFilePath = exports.toVirtualFilePath = exports.toVirtualAstroFilePath = exports.isVirtualFilePath = exports.isVirtualSvelteFilePath = exports.isVirtualVueFilePath = exports.isVirtualAstroFilePath = exports.isFrameworkFilePath = exports.isAstroFilePath = exports.isVirtualFrameworkFilePath = exports.getFrameworkFromFilePath = exports.convertToLocationRange = exports.convertRange = exports.mapSeverity = exports.getScriptKindFromFileName = exports.isSubPath = exports.findTsConfigPath = exports.getExtensionFromScriptKind = exports.getCommitCharactersForScriptElement = exports.scriptElementKindToCompletionItemKind = void 0;
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
25
8
|
const path_1 = require("path");
|
|
26
9
|
const utils_1 = require("../../utils");
|
|
10
|
+
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
27
11
|
const documents_1 = require("../../core/documents");
|
|
28
12
|
function scriptElementKindToCompletionItemKind(kind) {
|
|
29
13
|
switch (kind) {
|
|
30
|
-
case
|
|
31
|
-
case
|
|
14
|
+
case typescript_1.default.ScriptElementKind.primitiveType:
|
|
15
|
+
case typescript_1.default.ScriptElementKind.keyword:
|
|
32
16
|
return vscode_languageserver_1.CompletionItemKind.Keyword;
|
|
33
|
-
case
|
|
17
|
+
case typescript_1.default.ScriptElementKind.constElement:
|
|
34
18
|
return vscode_languageserver_1.CompletionItemKind.Constant;
|
|
35
|
-
case
|
|
36
|
-
case
|
|
37
|
-
case
|
|
38
|
-
case
|
|
19
|
+
case typescript_1.default.ScriptElementKind.letElement:
|
|
20
|
+
case typescript_1.default.ScriptElementKind.variableElement:
|
|
21
|
+
case typescript_1.default.ScriptElementKind.localVariableElement:
|
|
22
|
+
case typescript_1.default.ScriptElementKind.alias:
|
|
39
23
|
return vscode_languageserver_1.CompletionItemKind.Variable;
|
|
40
|
-
case
|
|
41
|
-
case
|
|
42
|
-
case
|
|
24
|
+
case typescript_1.default.ScriptElementKind.memberVariableElement:
|
|
25
|
+
case typescript_1.default.ScriptElementKind.memberGetAccessorElement:
|
|
26
|
+
case typescript_1.default.ScriptElementKind.memberSetAccessorElement:
|
|
43
27
|
return vscode_languageserver_1.CompletionItemKind.Field;
|
|
44
|
-
case
|
|
28
|
+
case typescript_1.default.ScriptElementKind.functionElement:
|
|
45
29
|
return vscode_languageserver_1.CompletionItemKind.Function;
|
|
46
|
-
case
|
|
47
|
-
case
|
|
48
|
-
case
|
|
49
|
-
case
|
|
30
|
+
case typescript_1.default.ScriptElementKind.memberFunctionElement:
|
|
31
|
+
case typescript_1.default.ScriptElementKind.constructSignatureElement:
|
|
32
|
+
case typescript_1.default.ScriptElementKind.callSignatureElement:
|
|
33
|
+
case typescript_1.default.ScriptElementKind.indexSignatureElement:
|
|
50
34
|
return vscode_languageserver_1.CompletionItemKind.Method;
|
|
51
|
-
case
|
|
35
|
+
case typescript_1.default.ScriptElementKind.enumElement:
|
|
52
36
|
return vscode_languageserver_1.CompletionItemKind.Enum;
|
|
53
|
-
case
|
|
54
|
-
case
|
|
37
|
+
case typescript_1.default.ScriptElementKind.moduleElement:
|
|
38
|
+
case typescript_1.default.ScriptElementKind.externalModuleName:
|
|
55
39
|
return vscode_languageserver_1.CompletionItemKind.Module;
|
|
56
|
-
case
|
|
57
|
-
case
|
|
40
|
+
case typescript_1.default.ScriptElementKind.classElement:
|
|
41
|
+
case typescript_1.default.ScriptElementKind.typeElement:
|
|
58
42
|
return vscode_languageserver_1.CompletionItemKind.Class;
|
|
59
|
-
case
|
|
43
|
+
case typescript_1.default.ScriptElementKind.interfaceElement:
|
|
60
44
|
return vscode_languageserver_1.CompletionItemKind.Interface;
|
|
61
|
-
case
|
|
62
|
-
case
|
|
45
|
+
case typescript_1.default.ScriptElementKind.warning:
|
|
46
|
+
case typescript_1.default.ScriptElementKind.scriptElement:
|
|
63
47
|
return vscode_languageserver_1.CompletionItemKind.File;
|
|
64
|
-
case
|
|
48
|
+
case typescript_1.default.ScriptElementKind.directory:
|
|
65
49
|
return vscode_languageserver_1.CompletionItemKind.Folder;
|
|
66
|
-
case
|
|
50
|
+
case typescript_1.default.ScriptElementKind.string:
|
|
67
51
|
return vscode_languageserver_1.CompletionItemKind.Constant;
|
|
68
52
|
}
|
|
69
53
|
return vscode_languageserver_1.CompletionItemKind.Property;
|
|
@@ -72,25 +56,25 @@ exports.scriptElementKindToCompletionItemKind = scriptElementKindToCompletionIte
|
|
|
72
56
|
function getCommitCharactersForScriptElement(kind) {
|
|
73
57
|
const commitCharacters = [];
|
|
74
58
|
switch (kind) {
|
|
75
|
-
case
|
|
76
|
-
case
|
|
77
|
-
case
|
|
78
|
-
case
|
|
79
|
-
case
|
|
80
|
-
case
|
|
81
|
-
case
|
|
59
|
+
case typescript_1.default.ScriptElementKind.memberGetAccessorElement:
|
|
60
|
+
case typescript_1.default.ScriptElementKind.memberSetAccessorElement:
|
|
61
|
+
case typescript_1.default.ScriptElementKind.constructSignatureElement:
|
|
62
|
+
case typescript_1.default.ScriptElementKind.callSignatureElement:
|
|
63
|
+
case typescript_1.default.ScriptElementKind.indexSignatureElement:
|
|
64
|
+
case typescript_1.default.ScriptElementKind.enumElement:
|
|
65
|
+
case typescript_1.default.ScriptElementKind.interfaceElement:
|
|
82
66
|
commitCharacters.push('.');
|
|
83
67
|
break;
|
|
84
|
-
case
|
|
85
|
-
case
|
|
86
|
-
case
|
|
87
|
-
case
|
|
88
|
-
case
|
|
89
|
-
case
|
|
90
|
-
case
|
|
91
|
-
case
|
|
92
|
-
case
|
|
93
|
-
case
|
|
68
|
+
case typescript_1.default.ScriptElementKind.moduleElement:
|
|
69
|
+
case typescript_1.default.ScriptElementKind.alias:
|
|
70
|
+
case typescript_1.default.ScriptElementKind.constElement:
|
|
71
|
+
case typescript_1.default.ScriptElementKind.letElement:
|
|
72
|
+
case typescript_1.default.ScriptElementKind.variableElement:
|
|
73
|
+
case typescript_1.default.ScriptElementKind.localVariableElement:
|
|
74
|
+
case typescript_1.default.ScriptElementKind.memberVariableElement:
|
|
75
|
+
case typescript_1.default.ScriptElementKind.classElement:
|
|
76
|
+
case typescript_1.default.ScriptElementKind.functionElement:
|
|
77
|
+
case typescript_1.default.ScriptElementKind.memberFunctionElement:
|
|
94
78
|
commitCharacters.push('.', ',');
|
|
95
79
|
commitCharacters.push('(');
|
|
96
80
|
break;
|
|
@@ -98,54 +82,66 @@ function getCommitCharactersForScriptElement(kind) {
|
|
|
98
82
|
return commitCharacters.length === 0 ? undefined : commitCharacters;
|
|
99
83
|
}
|
|
100
84
|
exports.getCommitCharactersForScriptElement = getCommitCharactersForScriptElement;
|
|
101
|
-
function
|
|
102
|
-
switch (
|
|
103
|
-
case
|
|
104
|
-
return
|
|
105
|
-
case
|
|
106
|
-
return
|
|
107
|
-
case
|
|
108
|
-
return
|
|
109
|
-
case
|
|
110
|
-
return
|
|
85
|
+
function getExtensionFromScriptKind(kind) {
|
|
86
|
+
switch (kind) {
|
|
87
|
+
case typescript_1.default.ScriptKind.JSX:
|
|
88
|
+
return typescript_1.default.Extension.Jsx;
|
|
89
|
+
case typescript_1.default.ScriptKind.TS:
|
|
90
|
+
return typescript_1.default.Extension.Ts;
|
|
91
|
+
case typescript_1.default.ScriptKind.TSX:
|
|
92
|
+
return typescript_1.default.Extension.Tsx;
|
|
93
|
+
case typescript_1.default.ScriptKind.JSON:
|
|
94
|
+
return typescript_1.default.Extension.Json;
|
|
95
|
+
case typescript_1.default.ScriptKind.JS:
|
|
96
|
+
default:
|
|
97
|
+
return typescript_1.default.Extension.Js;
|
|
111
98
|
}
|
|
112
|
-
return vscode_languageserver_1.DiagnosticSeverity.Error;
|
|
113
99
|
}
|
|
114
|
-
exports.
|
|
100
|
+
exports.getExtensionFromScriptKind = getExtensionFromScriptKind;
|
|
101
|
+
function findTsConfigPath(fileName, rootUris) {
|
|
102
|
+
const searchDir = (0, path_1.dirname)(fileName);
|
|
103
|
+
const path = typescript_1.default.findConfigFile(searchDir, typescript_1.default.sys.fileExists, 'tsconfig.json') ||
|
|
104
|
+
typescript_1.default.findConfigFile(searchDir, typescript_1.default.sys.fileExists, 'jsconfig.json') ||
|
|
105
|
+
'';
|
|
106
|
+
// Don't return config files that exceed the current workspace context.
|
|
107
|
+
return !!path && rootUris.some((rootUri) => isSubPath(rootUri, path)) ? path : '';
|
|
108
|
+
}
|
|
109
|
+
exports.findTsConfigPath = findTsConfigPath;
|
|
110
|
+
function isSubPath(uri, possibleSubPath) {
|
|
111
|
+
return (0, utils_1.pathToUrl)(possibleSubPath).startsWith(uri);
|
|
112
|
+
}
|
|
113
|
+
exports.isSubPath = isSubPath;
|
|
115
114
|
function getScriptKindFromFileName(fileName) {
|
|
116
|
-
const ext = fileName.
|
|
115
|
+
const ext = fileName.substring(fileName.lastIndexOf('.'));
|
|
117
116
|
switch (ext.toLowerCase()) {
|
|
118
|
-
case
|
|
119
|
-
return
|
|
120
|
-
case
|
|
121
|
-
return
|
|
122
|
-
case
|
|
123
|
-
return
|
|
124
|
-
case
|
|
125
|
-
return
|
|
126
|
-
case
|
|
127
|
-
return
|
|
117
|
+
case typescript_1.default.Extension.Js:
|
|
118
|
+
return typescript_1.default.ScriptKind.JS;
|
|
119
|
+
case typescript_1.default.Extension.Jsx:
|
|
120
|
+
return typescript_1.default.ScriptKind.JSX;
|
|
121
|
+
case typescript_1.default.Extension.Ts:
|
|
122
|
+
return typescript_1.default.ScriptKind.TS;
|
|
123
|
+
case typescript_1.default.Extension.Tsx:
|
|
124
|
+
return typescript_1.default.ScriptKind.TSX;
|
|
125
|
+
case typescript_1.default.Extension.Json:
|
|
126
|
+
return typescript_1.default.ScriptKind.JSON;
|
|
128
127
|
default:
|
|
129
|
-
return
|
|
128
|
+
return typescript_1.default.ScriptKind.Unknown;
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
exports.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
133
|
-
function
|
|
134
|
-
switch (
|
|
135
|
-
case
|
|
136
|
-
return
|
|
137
|
-
case
|
|
138
|
-
return
|
|
139
|
-
case
|
|
140
|
-
return
|
|
141
|
-
case
|
|
142
|
-
return
|
|
143
|
-
case ts.ScriptKind.JS:
|
|
144
|
-
default:
|
|
145
|
-
return ts.Extension.Js;
|
|
132
|
+
function mapSeverity(category) {
|
|
133
|
+
switch (category) {
|
|
134
|
+
case typescript_1.default.DiagnosticCategory.Error:
|
|
135
|
+
return vscode_languageserver_1.DiagnosticSeverity.Error;
|
|
136
|
+
case typescript_1.default.DiagnosticCategory.Warning:
|
|
137
|
+
return vscode_languageserver_1.DiagnosticSeverity.Warning;
|
|
138
|
+
case typescript_1.default.DiagnosticCategory.Suggestion:
|
|
139
|
+
return vscode_languageserver_1.DiagnosticSeverity.Hint;
|
|
140
|
+
case typescript_1.default.DiagnosticCategory.Message:
|
|
141
|
+
return vscode_languageserver_1.DiagnosticSeverity.Information;
|
|
146
142
|
}
|
|
147
143
|
}
|
|
148
|
-
exports.
|
|
144
|
+
exports.mapSeverity = mapSeverity;
|
|
149
145
|
function convertRange(document, range) {
|
|
150
146
|
return vscode_languageserver_1.Range.create(document.positionAt(range.start || 0), document.positionAt((range.start || 0) + (range.length || 0)));
|
|
151
147
|
}
|
|
@@ -165,8 +161,13 @@ function convertToLocationRange(defDoc, textSpan) {
|
|
|
165
161
|
exports.convertToLocationRange = convertToLocationRange;
|
|
166
162
|
const VirtualExtension = {
|
|
167
163
|
ts: 'ts',
|
|
168
|
-
tsx: 'tsx'
|
|
164
|
+
tsx: 'tsx',
|
|
169
165
|
};
|
|
166
|
+
function getFrameworkFromFilePath(filePath) {
|
|
167
|
+
filePath = ensureRealFilePath(filePath);
|
|
168
|
+
return (0, path_1.extname)(filePath).substring(1);
|
|
169
|
+
}
|
|
170
|
+
exports.getFrameworkFromFilePath = getFrameworkFromFilePath;
|
|
170
171
|
function isVirtualFrameworkFilePath(ext, virtualExt, filePath) {
|
|
171
172
|
return filePath.endsWith('.' + ext + '.' + virtualExt);
|
|
172
173
|
}
|
|
@@ -175,24 +176,24 @@ function isAstroFilePath(filePath) {
|
|
|
175
176
|
return filePath.endsWith('.astro');
|
|
176
177
|
}
|
|
177
178
|
exports.isAstroFilePath = isAstroFilePath;
|
|
179
|
+
function isFrameworkFilePath(filePath) {
|
|
180
|
+
return filePath.endsWith('.svelte') || filePath.endsWith('.vue');
|
|
181
|
+
}
|
|
182
|
+
exports.isFrameworkFilePath = isFrameworkFilePath;
|
|
178
183
|
function isVirtualAstroFilePath(filePath) {
|
|
179
184
|
return isVirtualFrameworkFilePath('astro', VirtualExtension.tsx, filePath);
|
|
180
185
|
}
|
|
181
186
|
exports.isVirtualAstroFilePath = isVirtualAstroFilePath;
|
|
182
187
|
function isVirtualVueFilePath(filePath) {
|
|
183
|
-
return isVirtualFrameworkFilePath('vue', VirtualExtension.
|
|
188
|
+
return isVirtualFrameworkFilePath('vue', VirtualExtension.tsx, filePath);
|
|
184
189
|
}
|
|
185
190
|
exports.isVirtualVueFilePath = isVirtualVueFilePath;
|
|
186
|
-
function isVirtualJsxFilePath(filePath) {
|
|
187
|
-
return isVirtualFrameworkFilePath('jsx', VirtualExtension.ts, filePath) || isVirtualFrameworkFilePath('tsx', VirtualExtension.ts, filePath);
|
|
188
|
-
}
|
|
189
|
-
exports.isVirtualJsxFilePath = isVirtualJsxFilePath;
|
|
190
191
|
function isVirtualSvelteFilePath(filePath) {
|
|
191
|
-
return isVirtualFrameworkFilePath('svelte', VirtualExtension.
|
|
192
|
+
return isVirtualFrameworkFilePath('svelte', VirtualExtension.tsx, filePath);
|
|
192
193
|
}
|
|
193
194
|
exports.isVirtualSvelteFilePath = isVirtualSvelteFilePath;
|
|
194
195
|
function isVirtualFilePath(filePath) {
|
|
195
|
-
return isVirtualAstroFilePath(filePath) || isVirtualVueFilePath(filePath) || isVirtualSvelteFilePath(filePath)
|
|
196
|
+
return isVirtualAstroFilePath(filePath) || isVirtualVueFilePath(filePath) || isVirtualSvelteFilePath(filePath);
|
|
196
197
|
}
|
|
197
198
|
exports.isVirtualFilePath = isVirtualFilePath;
|
|
198
199
|
function toVirtualAstroFilePath(filePath) {
|
|
@@ -207,6 +208,18 @@ function toVirtualAstroFilePath(filePath) {
|
|
|
207
208
|
}
|
|
208
209
|
}
|
|
209
210
|
exports.toVirtualAstroFilePath = toVirtualAstroFilePath;
|
|
211
|
+
function toVirtualFilePath(filePath) {
|
|
212
|
+
if (isVirtualFilePath(filePath)) {
|
|
213
|
+
return filePath;
|
|
214
|
+
}
|
|
215
|
+
else if (isFrameworkFilePath(filePath) || isAstroFilePath(filePath)) {
|
|
216
|
+
return `${filePath}.tsx`;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return filePath;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
exports.toVirtualFilePath = toVirtualFilePath;
|
|
210
223
|
function toRealAstroFilePath(filePath) {
|
|
211
224
|
return filePath.slice(0, -'.tsx'.length);
|
|
212
225
|
}
|
|
@@ -225,45 +238,3 @@ function ensureRealFilePath(filePath) {
|
|
|
225
238
|
}
|
|
226
239
|
}
|
|
227
240
|
exports.ensureRealFilePath = ensureRealFilePath;
|
|
228
|
-
function findTsConfigPath(fileName, rootUris) {
|
|
229
|
-
const searchDir = (0, path_1.dirname)(fileName);
|
|
230
|
-
const path = ts.findConfigFile(searchDir, ts.sys.fileExists, 'tsconfig.json') || ts.findConfigFile(searchDir, ts.sys.fileExists, 'jsconfig.json') || '';
|
|
231
|
-
// Don't return config files that exceed the current workspace context.
|
|
232
|
-
return !!path && rootUris.some((rootUri) => isSubPath(rootUri, path)) ? path : '';
|
|
233
|
-
}
|
|
234
|
-
exports.findTsConfigPath = findTsConfigPath;
|
|
235
|
-
/** */
|
|
236
|
-
function isSubPath(uri, possibleSubPath) {
|
|
237
|
-
return (0, utils_1.pathToUrl)(possibleSubPath).startsWith(uri);
|
|
238
|
-
}
|
|
239
|
-
exports.isSubPath = isSubPath;
|
|
240
|
-
/** Substitutes */
|
|
241
|
-
function substituteWithWhitespace(result, start, end, oldContent, before, after) {
|
|
242
|
-
let accumulatedWS = 0;
|
|
243
|
-
result += before;
|
|
244
|
-
for (let i = start + before.length; i < end; i++) {
|
|
245
|
-
let ch = oldContent[i];
|
|
246
|
-
if (ch === '\n' || ch === '\r') {
|
|
247
|
-
// only write new lines, skip the whitespace
|
|
248
|
-
accumulatedWS = 0;
|
|
249
|
-
result += ch;
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
accumulatedWS++;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
result = append(result, ' ', accumulatedWS - after.length);
|
|
256
|
-
result += after;
|
|
257
|
-
return result;
|
|
258
|
-
}
|
|
259
|
-
exports.substituteWithWhitespace = substituteWithWhitespace;
|
|
260
|
-
function append(result, str, n) {
|
|
261
|
-
while (n > 0) {
|
|
262
|
-
if (n & 1) {
|
|
263
|
-
result += str;
|
|
264
|
-
}
|
|
265
|
-
n >>= 1;
|
|
266
|
-
str += str;
|
|
267
|
-
}
|
|
268
|
-
return result;
|
|
269
|
-
}
|
package/dist/server.d.ts
CHANGED