@astrojs/language-server 0.11.0 → 0.13.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/CHANGELOG.md +23 -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 +1 -0
- 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 +42 -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 +1 -1
- 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 +11 -9
- package/dist/plugins/PluginHost.js +34 -36
- package/dist/plugins/astro/AstroPlugin.d.ts +11 -12
- package/dist/plugins/astro/AstroPlugin.js +17 -42
- package/dist/plugins/astro/features/{CompletionProvider.d.ts → CompletionsProvider.d.ts} +5 -5
- package/dist/plugins/astro/features/{CompletionProvider.js → CompletionsProvider.js} +33 -58
- package/dist/plugins/css/CSSDocument.d.ts +3 -3
- package/dist/plugins/css/CSSDocument.js +7 -16
- package/dist/plugins/css/CSSPlugin.d.ts +31 -12
- package/dist/plugins/css/CSSPlugin.js +174 -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 +18 -17
- package/dist/plugins/html/HTMLPlugin.js +69 -41
- package/dist/plugins/html/features/astro-attributes.d.ts +2 -0
- package/dist/plugins/html/features/astro-attributes.js +126 -0
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/index.js +2 -2
- 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 +18 -23
- package/dist/plugins/typescript/TypeScriptPlugin.js +58 -55
- package/dist/plugins/typescript/astro-sys.d.ts +5 -3
- package/dist/plugins/typescript/astro-sys.js +24 -45
- package/dist/plugins/typescript/features/CompletionsProvider.d.ts +6 -6
- package/dist/plugins/typescript/features/CompletionsProvider.js +18 -38
- package/dist/plugins/typescript/features/DiagnosticsProvider.d.ts +4 -4
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +27 -87
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.d.ts +10 -0
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.js +69 -0
- 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 +230 -0
- package/dist/plugins/typescript/module-loader.d.ts +5 -8
- package/dist/plugins/typescript/module-loader.js +43 -23
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.d.ts +90 -0
- 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 -13
- package/dist/plugins/typescript/utils.js +154 -158
- package/dist/server.d.ts +2 -4
- package/dist/server.js +93 -54
- package/dist/utils.d.ts +20 -16
- package/dist/utils.js +35 -24
- package/package.json +18 -12
- package/types/astro-jsx.d.ts +1077 -0
- 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.d.ts +0 -99
- package/dist/plugins/typescript/DocumentSnapshot.js +0 -259
- package/dist/plugins/typescript/SnapshotManager.d.ts +0 -24
- package/dist/plugins/typescript/SnapshotManager.js +0 -103
- package/dist/plugins/typescript/languageService.d.ts +0 -17
- package/dist/plugins/typescript/languageService.js +0 -173
- 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(props: Record<string, any>): any {<div></div>}';
|
|
81
|
+
}
|
|
82
|
+
return new DocumentSnapshot_1.TypeScriptDocumentSnapshot(0, filePath, code, typescript_1.default.ScriptKind.TSX);
|
|
83
|
+
}
|
|
84
|
+
exports.createFromFrameworkFilePath = createFromFrameworkFilePath;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CompletionItemKind, DiagnosticSeverity, Position, Range } from 'vscode-languageserver';
|
|
3
|
-
import { SnapshotFragment } from './DocumentSnapshot';
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { CompletionItemKind, DiagnosticSeverity, Position, Range, SymbolKind } from 'vscode-languageserver';
|
|
3
|
+
import { SnapshotFragment } from './snapshots/DocumentSnapshot';
|
|
4
|
+
export declare function symbolKindFromString(kind: string): SymbolKind;
|
|
4
5
|
export declare function scriptElementKindToCompletionItemKind(kind: ts.ScriptElementKind): CompletionItemKind;
|
|
5
6
|
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
7
|
export declare function getExtensionFromScriptKind(kind: ts.ScriptKind | undefined): ts.Extension;
|
|
8
|
+
export declare function findTsConfigPath(fileName: string, rootUris: string[]): string;
|
|
9
|
+
export declare function isSubPath(uri: string, possibleSubPath: string): boolean;
|
|
10
|
+
export declare function getScriptKindFromFileName(fileName: string): ts.ScriptKind;
|
|
11
|
+
export declare function mapSeverity(category: ts.DiagnosticCategory): DiagnosticSeverity;
|
|
9
12
|
export declare function convertRange(document: {
|
|
10
13
|
positionAt: (offset: number) => Position;
|
|
11
14
|
}, range: {
|
|
@@ -13,25 +16,19 @@ export declare function convertRange(document: {
|
|
|
13
16
|
length?: number;
|
|
14
17
|
}): Range;
|
|
15
18
|
export declare function convertToLocationRange(defDoc: SnapshotFragment, textSpan: ts.TextSpan): Range;
|
|
16
|
-
declare type FrameworkExt = 'astro' | 'vue' | 'jsx' | 'tsx' | 'svelte'
|
|
19
|
+
export declare type FrameworkExt = 'astro' | 'vue' | 'jsx' | 'tsx' | 'svelte';
|
|
17
20
|
declare type FrameworkVirtualExt = 'ts' | 'tsx';
|
|
21
|
+
export declare function getFrameworkFromFilePath(filePath: string): FrameworkExt;
|
|
18
22
|
export declare function isVirtualFrameworkFilePath(ext: FrameworkExt, virtualExt: FrameworkVirtualExt, filePath: string): boolean;
|
|
19
23
|
export declare function isAstroFilePath(filePath: string): boolean;
|
|
20
24
|
export declare function isFrameworkFilePath(filePath: string): boolean;
|
|
21
25
|
export declare function isVirtualAstroFilePath(filePath: string): boolean;
|
|
22
26
|
export declare function isVirtualVueFilePath(filePath: string): boolean;
|
|
23
|
-
export declare function isVirtualJsxFilePath(filePath: string): boolean;
|
|
24
27
|
export declare function isVirtualSvelteFilePath(filePath: string): boolean;
|
|
25
|
-
export declare function isVirtualTsFilePath(filePath: string): boolean;
|
|
26
28
|
export declare function isVirtualFilePath(filePath: string): boolean;
|
|
27
29
|
export declare function toVirtualAstroFilePath(filePath: string): string;
|
|
28
30
|
export declare function toVirtualFilePath(filePath: string): string;
|
|
29
31
|
export declare function toRealAstroFilePath(filePath: string): string;
|
|
30
32
|
export declare function ensureRealAstroFilePath(filePath: string): string;
|
|
31
33
|
export declare function ensureRealFilePath(filePath: string): string;
|
|
32
|
-
export declare function findTsConfigPath(fileName: string, rootUris: string[]): string;
|
|
33
|
-
/** */
|
|
34
|
-
export declare function isSubPath(uri: string, possibleSubPath: string): boolean;
|
|
35
|
-
/** Substitutes */
|
|
36
|
-
export declare function substituteWithWhitespace(result: string, start: number, end: number, oldContent: string, before: string, after: string): string;
|
|
37
34
|
export {};
|
|
@@ -1,73 +1,102 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
const
|
|
28
|
-
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 = exports.symbolKindFromString = void 0;
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
29
8
|
const path_1 = require("path");
|
|
30
9
|
const utils_1 = require("../../utils");
|
|
10
|
+
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
31
11
|
const documents_1 = require("../../core/documents");
|
|
12
|
+
function symbolKindFromString(kind) {
|
|
13
|
+
switch (kind) {
|
|
14
|
+
case 'module':
|
|
15
|
+
return vscode_languageserver_1.SymbolKind.Module;
|
|
16
|
+
case 'class':
|
|
17
|
+
return vscode_languageserver_1.SymbolKind.Class;
|
|
18
|
+
case 'local class':
|
|
19
|
+
return vscode_languageserver_1.SymbolKind.Class;
|
|
20
|
+
case 'interface':
|
|
21
|
+
return vscode_languageserver_1.SymbolKind.Interface;
|
|
22
|
+
case 'enum':
|
|
23
|
+
return vscode_languageserver_1.SymbolKind.Enum;
|
|
24
|
+
case 'enum member':
|
|
25
|
+
return vscode_languageserver_1.SymbolKind.Constant;
|
|
26
|
+
case 'var':
|
|
27
|
+
return vscode_languageserver_1.SymbolKind.Variable;
|
|
28
|
+
case 'local var':
|
|
29
|
+
return vscode_languageserver_1.SymbolKind.Variable;
|
|
30
|
+
case 'function':
|
|
31
|
+
return vscode_languageserver_1.SymbolKind.Function;
|
|
32
|
+
case 'local function':
|
|
33
|
+
return vscode_languageserver_1.SymbolKind.Function;
|
|
34
|
+
case 'method':
|
|
35
|
+
return vscode_languageserver_1.SymbolKind.Method;
|
|
36
|
+
case 'getter':
|
|
37
|
+
return vscode_languageserver_1.SymbolKind.Method;
|
|
38
|
+
case 'setter':
|
|
39
|
+
return vscode_languageserver_1.SymbolKind.Method;
|
|
40
|
+
case 'property':
|
|
41
|
+
return vscode_languageserver_1.SymbolKind.Property;
|
|
42
|
+
case 'constructor':
|
|
43
|
+
return vscode_languageserver_1.SymbolKind.Constructor;
|
|
44
|
+
case 'parameter':
|
|
45
|
+
return vscode_languageserver_1.SymbolKind.Variable;
|
|
46
|
+
case 'type parameter':
|
|
47
|
+
return vscode_languageserver_1.SymbolKind.Variable;
|
|
48
|
+
case 'alias':
|
|
49
|
+
return vscode_languageserver_1.SymbolKind.Variable;
|
|
50
|
+
case 'let':
|
|
51
|
+
return vscode_languageserver_1.SymbolKind.Variable;
|
|
52
|
+
case 'const':
|
|
53
|
+
return vscode_languageserver_1.SymbolKind.Constant;
|
|
54
|
+
case 'JSX attribute':
|
|
55
|
+
return vscode_languageserver_1.SymbolKind.Property;
|
|
56
|
+
default:
|
|
57
|
+
return vscode_languageserver_1.SymbolKind.Variable;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.symbolKindFromString = symbolKindFromString;
|
|
32
61
|
function scriptElementKindToCompletionItemKind(kind) {
|
|
33
62
|
switch (kind) {
|
|
34
|
-
case
|
|
35
|
-
case
|
|
63
|
+
case typescript_1.default.ScriptElementKind.primitiveType:
|
|
64
|
+
case typescript_1.default.ScriptElementKind.keyword:
|
|
36
65
|
return vscode_languageserver_1.CompletionItemKind.Keyword;
|
|
37
|
-
case
|
|
66
|
+
case typescript_1.default.ScriptElementKind.constElement:
|
|
38
67
|
return vscode_languageserver_1.CompletionItemKind.Constant;
|
|
39
|
-
case
|
|
40
|
-
case
|
|
41
|
-
case
|
|
42
|
-
case
|
|
68
|
+
case typescript_1.default.ScriptElementKind.letElement:
|
|
69
|
+
case typescript_1.default.ScriptElementKind.variableElement:
|
|
70
|
+
case typescript_1.default.ScriptElementKind.localVariableElement:
|
|
71
|
+
case typescript_1.default.ScriptElementKind.alias:
|
|
43
72
|
return vscode_languageserver_1.CompletionItemKind.Variable;
|
|
44
|
-
case
|
|
45
|
-
case
|
|
46
|
-
case
|
|
73
|
+
case typescript_1.default.ScriptElementKind.memberVariableElement:
|
|
74
|
+
case typescript_1.default.ScriptElementKind.memberGetAccessorElement:
|
|
75
|
+
case typescript_1.default.ScriptElementKind.memberSetAccessorElement:
|
|
47
76
|
return vscode_languageserver_1.CompletionItemKind.Field;
|
|
48
|
-
case
|
|
77
|
+
case typescript_1.default.ScriptElementKind.functionElement:
|
|
49
78
|
return vscode_languageserver_1.CompletionItemKind.Function;
|
|
50
|
-
case
|
|
51
|
-
case
|
|
52
|
-
case
|
|
53
|
-
case
|
|
79
|
+
case typescript_1.default.ScriptElementKind.memberFunctionElement:
|
|
80
|
+
case typescript_1.default.ScriptElementKind.constructSignatureElement:
|
|
81
|
+
case typescript_1.default.ScriptElementKind.callSignatureElement:
|
|
82
|
+
case typescript_1.default.ScriptElementKind.indexSignatureElement:
|
|
54
83
|
return vscode_languageserver_1.CompletionItemKind.Method;
|
|
55
|
-
case
|
|
84
|
+
case typescript_1.default.ScriptElementKind.enumElement:
|
|
56
85
|
return vscode_languageserver_1.CompletionItemKind.Enum;
|
|
57
|
-
case
|
|
58
|
-
case
|
|
86
|
+
case typescript_1.default.ScriptElementKind.moduleElement:
|
|
87
|
+
case typescript_1.default.ScriptElementKind.externalModuleName:
|
|
59
88
|
return vscode_languageserver_1.CompletionItemKind.Module;
|
|
60
|
-
case
|
|
61
|
-
case
|
|
89
|
+
case typescript_1.default.ScriptElementKind.classElement:
|
|
90
|
+
case typescript_1.default.ScriptElementKind.typeElement:
|
|
62
91
|
return vscode_languageserver_1.CompletionItemKind.Class;
|
|
63
|
-
case
|
|
92
|
+
case typescript_1.default.ScriptElementKind.interfaceElement:
|
|
64
93
|
return vscode_languageserver_1.CompletionItemKind.Interface;
|
|
65
|
-
case
|
|
66
|
-
case
|
|
94
|
+
case typescript_1.default.ScriptElementKind.warning:
|
|
95
|
+
case typescript_1.default.ScriptElementKind.scriptElement:
|
|
67
96
|
return vscode_languageserver_1.CompletionItemKind.File;
|
|
68
|
-
case
|
|
97
|
+
case typescript_1.default.ScriptElementKind.directory:
|
|
69
98
|
return vscode_languageserver_1.CompletionItemKind.Folder;
|
|
70
|
-
case
|
|
99
|
+
case typescript_1.default.ScriptElementKind.string:
|
|
71
100
|
return vscode_languageserver_1.CompletionItemKind.Constant;
|
|
72
101
|
}
|
|
73
102
|
return vscode_languageserver_1.CompletionItemKind.Property;
|
|
@@ -76,25 +105,25 @@ exports.scriptElementKindToCompletionItemKind = scriptElementKindToCompletionIte
|
|
|
76
105
|
function getCommitCharactersForScriptElement(kind) {
|
|
77
106
|
const commitCharacters = [];
|
|
78
107
|
switch (kind) {
|
|
79
|
-
case
|
|
80
|
-
case
|
|
81
|
-
case
|
|
82
|
-
case
|
|
83
|
-
case
|
|
84
|
-
case
|
|
85
|
-
case
|
|
108
|
+
case typescript_1.default.ScriptElementKind.memberGetAccessorElement:
|
|
109
|
+
case typescript_1.default.ScriptElementKind.memberSetAccessorElement:
|
|
110
|
+
case typescript_1.default.ScriptElementKind.constructSignatureElement:
|
|
111
|
+
case typescript_1.default.ScriptElementKind.callSignatureElement:
|
|
112
|
+
case typescript_1.default.ScriptElementKind.indexSignatureElement:
|
|
113
|
+
case typescript_1.default.ScriptElementKind.enumElement:
|
|
114
|
+
case typescript_1.default.ScriptElementKind.interfaceElement:
|
|
86
115
|
commitCharacters.push('.');
|
|
87
116
|
break;
|
|
88
|
-
case
|
|
89
|
-
case
|
|
90
|
-
case
|
|
91
|
-
case
|
|
92
|
-
case
|
|
93
|
-
case
|
|
94
|
-
case
|
|
95
|
-
case
|
|
96
|
-
case
|
|
97
|
-
case
|
|
117
|
+
case typescript_1.default.ScriptElementKind.moduleElement:
|
|
118
|
+
case typescript_1.default.ScriptElementKind.alias:
|
|
119
|
+
case typescript_1.default.ScriptElementKind.constElement:
|
|
120
|
+
case typescript_1.default.ScriptElementKind.letElement:
|
|
121
|
+
case typescript_1.default.ScriptElementKind.variableElement:
|
|
122
|
+
case typescript_1.default.ScriptElementKind.localVariableElement:
|
|
123
|
+
case typescript_1.default.ScriptElementKind.memberVariableElement:
|
|
124
|
+
case typescript_1.default.ScriptElementKind.classElement:
|
|
125
|
+
case typescript_1.default.ScriptElementKind.functionElement:
|
|
126
|
+
case typescript_1.default.ScriptElementKind.memberFunctionElement:
|
|
98
127
|
commitCharacters.push('.', ',');
|
|
99
128
|
commitCharacters.push('(');
|
|
100
129
|
break;
|
|
@@ -102,54 +131,66 @@ function getCommitCharactersForScriptElement(kind) {
|
|
|
102
131
|
return commitCharacters.length === 0 ? undefined : commitCharacters;
|
|
103
132
|
}
|
|
104
133
|
exports.getCommitCharactersForScriptElement = getCommitCharactersForScriptElement;
|
|
105
|
-
function
|
|
106
|
-
switch (
|
|
107
|
-
case
|
|
108
|
-
return
|
|
109
|
-
case
|
|
110
|
-
return
|
|
111
|
-
case
|
|
112
|
-
return
|
|
113
|
-
case
|
|
114
|
-
return
|
|
134
|
+
function getExtensionFromScriptKind(kind) {
|
|
135
|
+
switch (kind) {
|
|
136
|
+
case typescript_1.default.ScriptKind.JSX:
|
|
137
|
+
return typescript_1.default.Extension.Jsx;
|
|
138
|
+
case typescript_1.default.ScriptKind.TS:
|
|
139
|
+
return typescript_1.default.Extension.Ts;
|
|
140
|
+
case typescript_1.default.ScriptKind.TSX:
|
|
141
|
+
return typescript_1.default.Extension.Tsx;
|
|
142
|
+
case typescript_1.default.ScriptKind.JSON:
|
|
143
|
+
return typescript_1.default.Extension.Json;
|
|
144
|
+
case typescript_1.default.ScriptKind.JS:
|
|
145
|
+
default:
|
|
146
|
+
return typescript_1.default.Extension.Js;
|
|
115
147
|
}
|
|
116
|
-
return vscode_languageserver_1.DiagnosticSeverity.Error;
|
|
117
148
|
}
|
|
118
|
-
exports.
|
|
149
|
+
exports.getExtensionFromScriptKind = getExtensionFromScriptKind;
|
|
150
|
+
function findTsConfigPath(fileName, rootUris) {
|
|
151
|
+
const searchDir = (0, path_1.dirname)(fileName);
|
|
152
|
+
const path = typescript_1.default.findConfigFile(searchDir, typescript_1.default.sys.fileExists, 'tsconfig.json') ||
|
|
153
|
+
typescript_1.default.findConfigFile(searchDir, typescript_1.default.sys.fileExists, 'jsconfig.json') ||
|
|
154
|
+
'';
|
|
155
|
+
// Don't return config files that exceed the current workspace context.
|
|
156
|
+
return !!path && rootUris.some((rootUri) => isSubPath(rootUri, path)) ? path : '';
|
|
157
|
+
}
|
|
158
|
+
exports.findTsConfigPath = findTsConfigPath;
|
|
159
|
+
function isSubPath(uri, possibleSubPath) {
|
|
160
|
+
return (0, utils_1.pathToUrl)(possibleSubPath).startsWith(uri);
|
|
161
|
+
}
|
|
162
|
+
exports.isSubPath = isSubPath;
|
|
119
163
|
function getScriptKindFromFileName(fileName) {
|
|
120
|
-
const ext = fileName.
|
|
164
|
+
const ext = fileName.substring(fileName.lastIndexOf('.'));
|
|
121
165
|
switch (ext.toLowerCase()) {
|
|
122
|
-
case
|
|
123
|
-
return
|
|
124
|
-
case
|
|
125
|
-
return
|
|
126
|
-
case
|
|
127
|
-
return
|
|
128
|
-
case
|
|
129
|
-
return
|
|
130
|
-
case
|
|
131
|
-
return
|
|
166
|
+
case typescript_1.default.Extension.Js:
|
|
167
|
+
return typescript_1.default.ScriptKind.JS;
|
|
168
|
+
case typescript_1.default.Extension.Jsx:
|
|
169
|
+
return typescript_1.default.ScriptKind.JSX;
|
|
170
|
+
case typescript_1.default.Extension.Ts:
|
|
171
|
+
return typescript_1.default.ScriptKind.TS;
|
|
172
|
+
case typescript_1.default.Extension.Tsx:
|
|
173
|
+
return typescript_1.default.ScriptKind.TSX;
|
|
174
|
+
case typescript_1.default.Extension.Json:
|
|
175
|
+
return typescript_1.default.ScriptKind.JSON;
|
|
132
176
|
default:
|
|
133
|
-
return
|
|
177
|
+
return typescript_1.default.ScriptKind.Unknown;
|
|
134
178
|
}
|
|
135
179
|
}
|
|
136
180
|
exports.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
137
|
-
function
|
|
138
|
-
switch (
|
|
139
|
-
case
|
|
140
|
-
return
|
|
141
|
-
case
|
|
142
|
-
return
|
|
143
|
-
case
|
|
144
|
-
return
|
|
145
|
-
case
|
|
146
|
-
return
|
|
147
|
-
case ts.ScriptKind.JS:
|
|
148
|
-
default:
|
|
149
|
-
return ts.Extension.Js;
|
|
181
|
+
function mapSeverity(category) {
|
|
182
|
+
switch (category) {
|
|
183
|
+
case typescript_1.default.DiagnosticCategory.Error:
|
|
184
|
+
return vscode_languageserver_1.DiagnosticSeverity.Error;
|
|
185
|
+
case typescript_1.default.DiagnosticCategory.Warning:
|
|
186
|
+
return vscode_languageserver_1.DiagnosticSeverity.Warning;
|
|
187
|
+
case typescript_1.default.DiagnosticCategory.Suggestion:
|
|
188
|
+
return vscode_languageserver_1.DiagnosticSeverity.Hint;
|
|
189
|
+
case typescript_1.default.DiagnosticCategory.Message:
|
|
190
|
+
return vscode_languageserver_1.DiagnosticSeverity.Information;
|
|
150
191
|
}
|
|
151
192
|
}
|
|
152
|
-
exports.
|
|
193
|
+
exports.mapSeverity = mapSeverity;
|
|
153
194
|
function convertRange(document, range) {
|
|
154
195
|
return vscode_languageserver_1.Range.create(document.positionAt(range.start || 0), document.positionAt((range.start || 0) + (range.length || 0)));
|
|
155
196
|
}
|
|
@@ -169,8 +210,13 @@ function convertToLocationRange(defDoc, textSpan) {
|
|
|
169
210
|
exports.convertToLocationRange = convertToLocationRange;
|
|
170
211
|
const VirtualExtension = {
|
|
171
212
|
ts: 'ts',
|
|
172
|
-
tsx: 'tsx'
|
|
213
|
+
tsx: 'tsx',
|
|
173
214
|
};
|
|
215
|
+
function getFrameworkFromFilePath(filePath) {
|
|
216
|
+
filePath = ensureRealFilePath(filePath);
|
|
217
|
+
return (0, path_1.extname)(filePath).substring(1);
|
|
218
|
+
}
|
|
219
|
+
exports.getFrameworkFromFilePath = getFrameworkFromFilePath;
|
|
174
220
|
function isVirtualFrameworkFilePath(ext, virtualExt, filePath) {
|
|
175
221
|
return filePath.endsWith('.' + ext + '.' + virtualExt);
|
|
176
222
|
}
|
|
@@ -191,20 +237,12 @@ function isVirtualVueFilePath(filePath) {
|
|
|
191
237
|
return isVirtualFrameworkFilePath('vue', VirtualExtension.tsx, filePath);
|
|
192
238
|
}
|
|
193
239
|
exports.isVirtualVueFilePath = isVirtualVueFilePath;
|
|
194
|
-
function isVirtualJsxFilePath(filePath) {
|
|
195
|
-
return isVirtualFrameworkFilePath('jsx', VirtualExtension.ts, filePath) || isVirtualFrameworkFilePath('tsx', VirtualExtension.ts, filePath);
|
|
196
|
-
}
|
|
197
|
-
exports.isVirtualJsxFilePath = isVirtualJsxFilePath;
|
|
198
240
|
function isVirtualSvelteFilePath(filePath) {
|
|
199
241
|
return isVirtualFrameworkFilePath('svelte', VirtualExtension.tsx, filePath);
|
|
200
242
|
}
|
|
201
243
|
exports.isVirtualSvelteFilePath = isVirtualSvelteFilePath;
|
|
202
|
-
function isVirtualTsFilePath(filePath) {
|
|
203
|
-
return isVirtualFrameworkFilePath('ts', VirtualExtension.tsx, filePath);
|
|
204
|
-
}
|
|
205
|
-
exports.isVirtualTsFilePath = isVirtualTsFilePath;
|
|
206
244
|
function isVirtualFilePath(filePath) {
|
|
207
|
-
return isVirtualAstroFilePath(filePath) || isVirtualVueFilePath(filePath) || isVirtualSvelteFilePath(filePath)
|
|
245
|
+
return isVirtualAstroFilePath(filePath) || isVirtualVueFilePath(filePath) || isVirtualSvelteFilePath(filePath);
|
|
208
246
|
}
|
|
209
247
|
exports.isVirtualFilePath = isVirtualFilePath;
|
|
210
248
|
function toVirtualAstroFilePath(filePath) {
|
|
@@ -223,7 +261,7 @@ function toVirtualFilePath(filePath) {
|
|
|
223
261
|
if (isVirtualFilePath(filePath)) {
|
|
224
262
|
return filePath;
|
|
225
263
|
}
|
|
226
|
-
else if (isFrameworkFilePath(filePath) || isAstroFilePath(filePath)
|
|
264
|
+
else if (isFrameworkFilePath(filePath) || isAstroFilePath(filePath)) {
|
|
227
265
|
return `${filePath}.tsx`;
|
|
228
266
|
}
|
|
229
267
|
else {
|
|
@@ -249,45 +287,3 @@ function ensureRealFilePath(filePath) {
|
|
|
249
287
|
}
|
|
250
288
|
}
|
|
251
289
|
exports.ensureRealFilePath = ensureRealFilePath;
|
|
252
|
-
function findTsConfigPath(fileName, rootUris) {
|
|
253
|
-
const searchDir = (0, path_1.dirname)(fileName);
|
|
254
|
-
const path = ts.findConfigFile(searchDir, ts.sys.fileExists, 'tsconfig.json') || ts.findConfigFile(searchDir, ts.sys.fileExists, 'jsconfig.json') || '';
|
|
255
|
-
// Don't return config files that exceed the current workspace context.
|
|
256
|
-
return !!path && rootUris.some((rootUri) => isSubPath(rootUri, path)) ? path : '';
|
|
257
|
-
}
|
|
258
|
-
exports.findTsConfigPath = findTsConfigPath;
|
|
259
|
-
/** */
|
|
260
|
-
function isSubPath(uri, possibleSubPath) {
|
|
261
|
-
return (0, utils_1.pathToUrl)(possibleSubPath).startsWith(uri);
|
|
262
|
-
}
|
|
263
|
-
exports.isSubPath = isSubPath;
|
|
264
|
-
/** Substitutes */
|
|
265
|
-
function substituteWithWhitespace(result, start, end, oldContent, before, after) {
|
|
266
|
-
let accumulatedWS = 0;
|
|
267
|
-
result += before;
|
|
268
|
-
for (let i = start + before.length; i < end; i++) {
|
|
269
|
-
let ch = oldContent[i];
|
|
270
|
-
if (ch === '\n' || ch === '\r') {
|
|
271
|
-
// only write new lines, skip the whitespace
|
|
272
|
-
accumulatedWS = 0;
|
|
273
|
-
result += ch;
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
accumulatedWS++;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
result = append(result, ' ', accumulatedWS - after.length);
|
|
280
|
-
result += after;
|
|
281
|
-
return result;
|
|
282
|
-
}
|
|
283
|
-
exports.substituteWithWhitespace = substituteWithWhitespace;
|
|
284
|
-
function append(result, str, n) {
|
|
285
|
-
while (n > 0) {
|
|
286
|
-
if (n & 1) {
|
|
287
|
-
result += str;
|
|
288
|
-
}
|
|
289
|
-
n >>= 1;
|
|
290
|
-
str += str;
|
|
291
|
-
}
|
|
292
|
-
return result;
|
|
293
|
-
}
|
package/dist/server.d.ts
CHANGED