@astrojs/language-server 1.0.5 → 2.0.0-next.6
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/LICENSE +3 -5
- package/bin/nodeServer.js +7 -3
- package/dist/core/astro2tsx.d.ts +6 -0
- package/dist/core/astro2tsx.js +119 -0
- package/dist/core/compilerUtils.d.ts +27 -0
- package/dist/core/compilerUtils.js +52 -0
- package/dist/core/index.d.ts +27 -0
- package/dist/core/index.js +119 -0
- package/dist/core/parseAstro.d.ts +27 -0
- package/dist/core/parseAstro.js +47 -0
- package/dist/core/parseCSS.d.ts +7 -0
- package/dist/core/parseCSS.js +116 -0
- package/dist/core/parseHTML.d.ts +7 -0
- package/dist/core/parseHTML.js +113 -0
- package/dist/core/parseJS.d.ts +7 -0
- package/dist/core/parseJS.js +236 -0
- package/dist/core/svelte.d.ts +18 -0
- package/dist/core/svelte.js +45 -0
- package/dist/core/utils.d.ts +14 -0
- package/dist/core/utils.js +138 -0
- package/dist/core/vue.d.ts +18 -0
- package/dist/core/vue.js +45 -0
- package/dist/importPackage.d.ts +1 -1
- package/dist/importPackage.js +4 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +26 -6
- package/dist/languageServerPlugin.d.ts +2 -0
- package/dist/languageServerPlugin.js +76 -0
- package/dist/nodeServer.js +6 -0
- package/dist/plugins/astro.d.ts +3 -0
- package/dist/plugins/astro.js +123 -0
- package/dist/plugins/{html/features/astro-attributes.js → html-data.js} +1 -0
- package/dist/plugins/html.d.ts +3 -0
- package/dist/plugins/html.js +33 -0
- package/dist/plugins/typescript/codeActions.d.ts +4 -0
- package/dist/plugins/typescript/codeActions.js +49 -0
- package/dist/plugins/typescript/completions.d.ts +3 -0
- package/dist/plugins/typescript/completions.js +81 -0
- package/dist/plugins/typescript/diagnostics.d.ts +12 -0
- package/dist/plugins/typescript/diagnostics.js +99 -0
- package/dist/plugins/typescript/index.d.ts +3 -0
- package/dist/plugins/typescript/index.js +57 -0
- package/dist/utils.d.ts +19 -69
- package/dist/utils.js +66 -239
- package/package.json +39 -37
- package/types/astro-jsx.d.ts +49 -5
- package/bin/browserServer.js +0 -3
- package/dist/browser.js +0 -15
- package/dist/check.d.ts +0 -23
- package/dist/check.js +0 -60
- package/dist/core/DiagnosticsManager.d.ts +0 -13
- package/dist/core/DiagnosticsManager.js +0 -29
- package/dist/core/config/ConfigManager.d.ts +0 -43
- package/dist/core/config/ConfigManager.js +0 -226
- package/dist/core/config/index.d.ts +0 -2
- package/dist/core/config/index.js +0 -18
- package/dist/core/config/interfaces.d.ts +0 -77
- package/dist/core/config/interfaces.js +0 -2
- package/dist/core/documents/AstroDocument.d.ts +0 -19
- package/dist/core/documents/AstroDocument.js +0 -43
- package/dist/core/documents/DocumentBase.d.ts +0 -68
- package/dist/core/documents/DocumentBase.js +0 -75
- package/dist/core/documents/DocumentManager.d.ts +0 -23
- package/dist/core/documents/DocumentManager.js +0 -100
- package/dist/core/documents/DocumentMapper.d.ts +0 -94
- package/dist/core/documents/DocumentMapper.js +0 -264
- package/dist/core/documents/index.d.ts +0 -5
- package/dist/core/documents/index.js +0 -21
- package/dist/core/documents/parseAstro.d.ts +0 -15
- package/dist/core/documents/parseAstro.js +0 -63
- package/dist/core/documents/parseHtml.d.ts +0 -13
- package/dist/core/documents/parseHtml.js +0 -126
- package/dist/core/documents/utils.d.ts +0 -63
- package/dist/core/documents/utils.js +0 -223
- package/dist/node.d.ts +0 -1
- package/dist/node.js +0 -43
- package/dist/plugins/PluginHost.d.ts +0 -42
- package/dist/plugins/PluginHost.js +0 -206
- package/dist/plugins/astro/AstroPlugin.d.ts +0 -17
- package/dist/plugins/astro/AstroPlugin.js +0 -90
- package/dist/plugins/astro/features/CompletionsProvider.d.ts +0 -17
- package/dist/plugins/astro/features/CompletionsProvider.js +0 -242
- package/dist/plugins/astro/features/DiagnosticsProvider.d.ts +0 -10
- package/dist/plugins/astro/features/DiagnosticsProvider.js +0 -23
- package/dist/plugins/css/CSSDocument.d.ts +0 -45
- package/dist/plugins/css/CSSDocument.js +0 -68
- package/dist/plugins/css/CSSPlugin.d.ts +0 -39
- package/dist/plugins/css/CSSPlugin.js +0 -274
- package/dist/plugins/css/StyleAttributeDocument.d.ts +0 -40
- package/dist/plugins/css/StyleAttributeDocument.js +0 -64
- package/dist/plugins/css/features/astro-selectors.d.ts +0 -2
- package/dist/plugins/css/features/astro-selectors.js +0 -15
- package/dist/plugins/css/features/getIdClassCompletions.d.ts +0 -19
- package/dist/plugins/css/features/getIdClassCompletions.js +0 -57
- package/dist/plugins/css/language-service.d.ts +0 -3
- package/dist/plugins/css/language-service.js +0 -47
- package/dist/plugins/html/HTMLPlugin.d.ts +0 -33
- package/dist/plugins/html/HTMLPlugin.js +0 -198
- package/dist/plugins/html/utils.d.ts +0 -6
- package/dist/plugins/html/utils.js +0 -11
- package/dist/plugins/index.d.ts +0 -6
- package/dist/plugins/index.js +0 -22
- package/dist/plugins/interfaces.d.ts +0 -101
- package/dist/plugins/interfaces.js +0 -2
- package/dist/plugins/typescript/LanguageServiceManager.d.ts +0 -47
- package/dist/plugins/typescript/LanguageServiceManager.js +0 -97
- package/dist/plugins/typescript/TypeScriptPlugin.d.ts +0 -54
- package/dist/plugins/typescript/TypeScriptPlugin.js +0 -152
- package/dist/plugins/typescript/astro-sys.d.ts +0 -8
- package/dist/plugins/typescript/astro-sys.js +0 -46
- package/dist/plugins/typescript/astro2tsx.d.ts +0 -2
- package/dist/plugins/typescript/astro2tsx.js +0 -26
- package/dist/plugins/typescript/features/CodeActionsProvider.d.ts +0 -17
- package/dist/plugins/typescript/features/CodeActionsProvider.js +0 -212
- package/dist/plugins/typescript/features/CompletionsProvider.d.ts +0 -31
- package/dist/plugins/typescript/features/CompletionsProvider.js +0 -294
- package/dist/plugins/typescript/features/DefinitionsProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/DefinitionsProvider.js +0 -58
- package/dist/plugins/typescript/features/DiagnosticsProvider.d.ts +0 -25
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +0 -249
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.d.ts +0 -11
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.js +0 -67
- package/dist/plugins/typescript/features/FileReferencesProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/FileReferencesProvider.js +0 -27
- package/dist/plugins/typescript/features/FoldingRangesProvider.d.ts +0 -12
- package/dist/plugins/typescript/features/FoldingRangesProvider.js +0 -71
- package/dist/plugins/typescript/features/HoverProvider.d.ts +0 -10
- package/dist/plugins/typescript/features/HoverProvider.js +0 -50
- package/dist/plugins/typescript/features/ImplementationsProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/ImplementationsProvider.js +0 -53
- package/dist/plugins/typescript/features/InlayHintsProvider.d.ts +0 -13
- package/dist/plugins/typescript/features/InlayHintsProvider.js +0 -30
- package/dist/plugins/typescript/features/ReferencesProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/ReferencesProvider.js +0 -55
- package/dist/plugins/typescript/features/RenameProvider.d.ts +0 -13
- package/dist/plugins/typescript/features/RenameProvider.js +0 -60
- package/dist/plugins/typescript/features/SemanticTokenProvider.d.ts +0 -16
- package/dist/plugins/typescript/features/SemanticTokenProvider.js +0 -75
- package/dist/plugins/typescript/features/SignatureHelpProvider.d.ts +0 -22
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +0 -111
- package/dist/plugins/typescript/features/TypeDefinitionsProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/TypeDefinitionsProvider.js +0 -54
- package/dist/plugins/typescript/features/utils.d.ts +0 -14
- package/dist/plugins/typescript/features/utils.js +0 -48
- package/dist/plugins/typescript/language-service.d.ts +0 -42
- package/dist/plugins/typescript/language-service.js +0 -278
- package/dist/plugins/typescript/module-loader.d.ts +0 -23
- package/dist/plugins/typescript/module-loader.js +0 -155
- package/dist/plugins/typescript/previewer.d.ts +0 -7
- package/dist/plugins/typescript/previewer.js +0 -108
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.d.ts +0 -95
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.js +0 -187
- package/dist/plugins/typescript/snapshots/SnapshotManager.d.ts +0 -44
- package/dist/plugins/typescript/snapshots/SnapshotManager.js +0 -179
- package/dist/plugins/typescript/snapshots/utils.d.ts +0 -29
- package/dist/plugins/typescript/snapshots/utils.js +0 -106
- package/dist/plugins/typescript/utils.d.ts +0 -75
- package/dist/plugins/typescript/utils.js +0 -366
- package/dist/server.d.ts +0 -6
- package/dist/server.js +0 -275
- package/types/README.md +0 -5
- /package/dist/{browser.d.ts → nodeServer.d.ts} +0 -0
- /package/dist/plugins/{html/features/astro-attributes.d.ts → html-data.d.ts} +0 -0
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getScriptTagSnapshot = exports.getScriptTagLanguage = exports.isDocumentSymbolsPath = 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.removeAstroComponentSuffix = exports.checkEndOfFileCodeInsert = exports.ensureFrontmatterInsert = exports.convertToLocationRange = exports.convertRange = exports.getScriptKindFromFileName = exports.isSubPath = exports.findTsConfigPath = exports.getExtensionFromScriptKind = exports.getCommitCharactersForScriptElement = exports.scriptElementKindToCompletionItemKind = exports.symbolKindFromString = exports.getSemanticTokenLegend = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
6
|
-
const documents_1 = require("../../core/documents");
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
8
|
-
function getSemanticTokenLegend() {
|
|
9
|
-
const tokenModifiers = [];
|
|
10
|
-
[
|
|
11
|
-
[0 /* TokenModifier.declaration */, vscode_languageserver_1.SemanticTokenModifiers.declaration],
|
|
12
|
-
[1 /* TokenModifier.static */, vscode_languageserver_1.SemanticTokenModifiers.static],
|
|
13
|
-
[2 /* TokenModifier.async */, vscode_languageserver_1.SemanticTokenModifiers.async],
|
|
14
|
-
[3 /* TokenModifier.readonly */, vscode_languageserver_1.SemanticTokenModifiers.readonly],
|
|
15
|
-
[4 /* TokenModifier.defaultLibrary */, vscode_languageserver_1.SemanticTokenModifiers.defaultLibrary],
|
|
16
|
-
[5 /* TokenModifier.local */, 'local'],
|
|
17
|
-
].forEach(([tsModifier, legend]) => (tokenModifiers[tsModifier] = legend));
|
|
18
|
-
const tokenTypes = [];
|
|
19
|
-
[
|
|
20
|
-
[0 /* TokenType.class */, vscode_languageserver_1.SemanticTokenTypes.class],
|
|
21
|
-
[1 /* TokenType.enum */, vscode_languageserver_1.SemanticTokenTypes.enum],
|
|
22
|
-
[2 /* TokenType.interface */, vscode_languageserver_1.SemanticTokenTypes.interface],
|
|
23
|
-
[3 /* TokenType.namespace */, vscode_languageserver_1.SemanticTokenTypes.namespace],
|
|
24
|
-
[4 /* TokenType.typeParameter */, vscode_languageserver_1.SemanticTokenTypes.typeParameter],
|
|
25
|
-
[5 /* TokenType.type */, vscode_languageserver_1.SemanticTokenTypes.type],
|
|
26
|
-
[6 /* TokenType.parameter */, vscode_languageserver_1.SemanticTokenTypes.parameter],
|
|
27
|
-
[7 /* TokenType.variable */, vscode_languageserver_1.SemanticTokenTypes.variable],
|
|
28
|
-
[8 /* TokenType.enumMember */, vscode_languageserver_1.SemanticTokenTypes.enumMember],
|
|
29
|
-
[9 /* TokenType.property */, vscode_languageserver_1.SemanticTokenTypes.property],
|
|
30
|
-
[10 /* TokenType.function */, vscode_languageserver_1.SemanticTokenTypes.function],
|
|
31
|
-
[11 /* TokenType.method */, vscode_languageserver_1.SemanticTokenTypes.method],
|
|
32
|
-
].forEach(([tokenType, legend]) => (tokenTypes[tokenType] = legend));
|
|
33
|
-
return {
|
|
34
|
-
tokenModifiers,
|
|
35
|
-
tokenTypes,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
exports.getSemanticTokenLegend = getSemanticTokenLegend;
|
|
39
|
-
function symbolKindFromString(kind) {
|
|
40
|
-
switch (kind) {
|
|
41
|
-
case 'module':
|
|
42
|
-
return vscode_languageserver_1.SymbolKind.Module;
|
|
43
|
-
case 'class':
|
|
44
|
-
return vscode_languageserver_1.SymbolKind.Class;
|
|
45
|
-
case 'local class':
|
|
46
|
-
return vscode_languageserver_1.SymbolKind.Class;
|
|
47
|
-
case 'interface':
|
|
48
|
-
return vscode_languageserver_1.SymbolKind.Interface;
|
|
49
|
-
case 'enum':
|
|
50
|
-
return vscode_languageserver_1.SymbolKind.Enum;
|
|
51
|
-
case 'enum member':
|
|
52
|
-
return vscode_languageserver_1.SymbolKind.Constant;
|
|
53
|
-
case 'var':
|
|
54
|
-
return vscode_languageserver_1.SymbolKind.Variable;
|
|
55
|
-
case 'local var':
|
|
56
|
-
return vscode_languageserver_1.SymbolKind.Variable;
|
|
57
|
-
case 'function':
|
|
58
|
-
return vscode_languageserver_1.SymbolKind.Function;
|
|
59
|
-
case 'local function':
|
|
60
|
-
return vscode_languageserver_1.SymbolKind.Function;
|
|
61
|
-
case 'method':
|
|
62
|
-
return vscode_languageserver_1.SymbolKind.Method;
|
|
63
|
-
case 'getter':
|
|
64
|
-
return vscode_languageserver_1.SymbolKind.Method;
|
|
65
|
-
case 'setter':
|
|
66
|
-
return vscode_languageserver_1.SymbolKind.Method;
|
|
67
|
-
case 'property':
|
|
68
|
-
return vscode_languageserver_1.SymbolKind.Property;
|
|
69
|
-
case 'constructor':
|
|
70
|
-
return vscode_languageserver_1.SymbolKind.Constructor;
|
|
71
|
-
case 'parameter':
|
|
72
|
-
return vscode_languageserver_1.SymbolKind.Variable;
|
|
73
|
-
case 'type parameter':
|
|
74
|
-
return vscode_languageserver_1.SymbolKind.Variable;
|
|
75
|
-
case 'alias':
|
|
76
|
-
return vscode_languageserver_1.SymbolKind.Variable;
|
|
77
|
-
case 'let':
|
|
78
|
-
return vscode_languageserver_1.SymbolKind.Variable;
|
|
79
|
-
case 'const':
|
|
80
|
-
return vscode_languageserver_1.SymbolKind.Constant;
|
|
81
|
-
case 'JSX attribute':
|
|
82
|
-
return vscode_languageserver_1.SymbolKind.Property;
|
|
83
|
-
default:
|
|
84
|
-
return vscode_languageserver_1.SymbolKind.Variable;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.symbolKindFromString = symbolKindFromString;
|
|
88
|
-
function scriptElementKindToCompletionItemKind(kind, ts) {
|
|
89
|
-
switch (kind) {
|
|
90
|
-
case ts.ScriptElementKind.primitiveType:
|
|
91
|
-
case ts.ScriptElementKind.keyword:
|
|
92
|
-
return vscode_languageserver_1.CompletionItemKind.Keyword;
|
|
93
|
-
case ts.ScriptElementKind.constElement:
|
|
94
|
-
return vscode_languageserver_1.CompletionItemKind.Constant;
|
|
95
|
-
case ts.ScriptElementKind.letElement:
|
|
96
|
-
case ts.ScriptElementKind.variableElement:
|
|
97
|
-
case ts.ScriptElementKind.localVariableElement:
|
|
98
|
-
case ts.ScriptElementKind.alias:
|
|
99
|
-
return vscode_languageserver_1.CompletionItemKind.Variable;
|
|
100
|
-
case ts.ScriptElementKind.memberVariableElement:
|
|
101
|
-
case ts.ScriptElementKind.memberGetAccessorElement:
|
|
102
|
-
case ts.ScriptElementKind.memberSetAccessorElement:
|
|
103
|
-
return vscode_languageserver_1.CompletionItemKind.Field;
|
|
104
|
-
case ts.ScriptElementKind.functionElement:
|
|
105
|
-
return vscode_languageserver_1.CompletionItemKind.Function;
|
|
106
|
-
case ts.ScriptElementKind.memberFunctionElement:
|
|
107
|
-
case ts.ScriptElementKind.constructSignatureElement:
|
|
108
|
-
case ts.ScriptElementKind.callSignatureElement:
|
|
109
|
-
case ts.ScriptElementKind.indexSignatureElement:
|
|
110
|
-
return vscode_languageserver_1.CompletionItemKind.Method;
|
|
111
|
-
case ts.ScriptElementKind.enumElement:
|
|
112
|
-
return vscode_languageserver_1.CompletionItemKind.Enum;
|
|
113
|
-
case ts.ScriptElementKind.moduleElement:
|
|
114
|
-
case ts.ScriptElementKind.externalModuleName:
|
|
115
|
-
return vscode_languageserver_1.CompletionItemKind.Module;
|
|
116
|
-
case ts.ScriptElementKind.classElement:
|
|
117
|
-
case ts.ScriptElementKind.typeElement:
|
|
118
|
-
return vscode_languageserver_1.CompletionItemKind.Class;
|
|
119
|
-
case ts.ScriptElementKind.interfaceElement:
|
|
120
|
-
return vscode_languageserver_1.CompletionItemKind.Interface;
|
|
121
|
-
case ts.ScriptElementKind.warning:
|
|
122
|
-
case ts.ScriptElementKind.scriptElement:
|
|
123
|
-
return vscode_languageserver_1.CompletionItemKind.File;
|
|
124
|
-
case ts.ScriptElementKind.directory:
|
|
125
|
-
return vscode_languageserver_1.CompletionItemKind.Folder;
|
|
126
|
-
case ts.ScriptElementKind.string:
|
|
127
|
-
return vscode_languageserver_1.CompletionItemKind.Constant;
|
|
128
|
-
}
|
|
129
|
-
return vscode_languageserver_1.CompletionItemKind.Property;
|
|
130
|
-
}
|
|
131
|
-
exports.scriptElementKindToCompletionItemKind = scriptElementKindToCompletionItemKind;
|
|
132
|
-
function getCommitCharactersForScriptElement(kind, ts) {
|
|
133
|
-
const commitCharacters = [];
|
|
134
|
-
switch (kind) {
|
|
135
|
-
case ts.ScriptElementKind.memberGetAccessorElement:
|
|
136
|
-
case ts.ScriptElementKind.memberSetAccessorElement:
|
|
137
|
-
case ts.ScriptElementKind.constructSignatureElement:
|
|
138
|
-
case ts.ScriptElementKind.callSignatureElement:
|
|
139
|
-
case ts.ScriptElementKind.indexSignatureElement:
|
|
140
|
-
case ts.ScriptElementKind.enumElement:
|
|
141
|
-
case ts.ScriptElementKind.interfaceElement:
|
|
142
|
-
commitCharacters.push('.');
|
|
143
|
-
break;
|
|
144
|
-
case ts.ScriptElementKind.moduleElement:
|
|
145
|
-
case ts.ScriptElementKind.alias:
|
|
146
|
-
case ts.ScriptElementKind.constElement:
|
|
147
|
-
case ts.ScriptElementKind.letElement:
|
|
148
|
-
case ts.ScriptElementKind.variableElement:
|
|
149
|
-
case ts.ScriptElementKind.localVariableElement:
|
|
150
|
-
case ts.ScriptElementKind.memberVariableElement:
|
|
151
|
-
case ts.ScriptElementKind.classElement:
|
|
152
|
-
case ts.ScriptElementKind.functionElement:
|
|
153
|
-
case ts.ScriptElementKind.memberFunctionElement:
|
|
154
|
-
commitCharacters.push('.', ',');
|
|
155
|
-
commitCharacters.push('(');
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
return commitCharacters.length === 0 ? undefined : commitCharacters;
|
|
159
|
-
}
|
|
160
|
-
exports.getCommitCharactersForScriptElement = getCommitCharactersForScriptElement;
|
|
161
|
-
function getExtensionFromScriptKind(kind, ts) {
|
|
162
|
-
switch (kind) {
|
|
163
|
-
case ts.ScriptKind.JSX:
|
|
164
|
-
return ts.Extension.Jsx;
|
|
165
|
-
case ts.ScriptKind.TS:
|
|
166
|
-
return ts.Extension.Ts;
|
|
167
|
-
case ts.ScriptKind.TSX:
|
|
168
|
-
return ts.Extension.Tsx;
|
|
169
|
-
case ts.ScriptKind.JSON:
|
|
170
|
-
return ts.Extension.Json;
|
|
171
|
-
case ts.ScriptKind.JS:
|
|
172
|
-
default:
|
|
173
|
-
return ts.Extension.Js;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.getExtensionFromScriptKind = getExtensionFromScriptKind;
|
|
177
|
-
function findTsConfigPath(fileName, rootUris, ts) {
|
|
178
|
-
const searchDir = (0, path_1.dirname)(fileName);
|
|
179
|
-
const path = ts.findConfigFile(searchDir, ts.sys.fileExists, 'tsconfig.json') ||
|
|
180
|
-
ts.findConfigFile(searchDir, ts.sys.fileExists, 'jsconfig.json') ||
|
|
181
|
-
'';
|
|
182
|
-
// Don't return config files that exceed the current workspace context.
|
|
183
|
-
return !!path && rootUris.some((rootUri) => isSubPath(rootUri, path)) ? path : '';
|
|
184
|
-
}
|
|
185
|
-
exports.findTsConfigPath = findTsConfigPath;
|
|
186
|
-
function isSubPath(uri, possibleSubPath) {
|
|
187
|
-
return (0, utils_1.pathToUrl)(possibleSubPath).startsWith(uri);
|
|
188
|
-
}
|
|
189
|
-
exports.isSubPath = isSubPath;
|
|
190
|
-
function getScriptKindFromFileName(fileName, ts) {
|
|
191
|
-
const ext = fileName.substring(fileName.lastIndexOf('.'));
|
|
192
|
-
switch (ext.toLowerCase()) {
|
|
193
|
-
case ts.Extension.Js:
|
|
194
|
-
return ts.ScriptKind.JS;
|
|
195
|
-
case ts.Extension.Jsx:
|
|
196
|
-
return ts.ScriptKind.JSX;
|
|
197
|
-
case ts.Extension.Ts:
|
|
198
|
-
return ts.ScriptKind.TS;
|
|
199
|
-
case ts.Extension.Tsx:
|
|
200
|
-
return ts.ScriptKind.TSX;
|
|
201
|
-
case ts.Extension.Json:
|
|
202
|
-
return ts.ScriptKind.JSON;
|
|
203
|
-
default:
|
|
204
|
-
return ts.ScriptKind.Unknown;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
exports.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
208
|
-
function convertRange(document, range) {
|
|
209
|
-
return vscode_languageserver_1.Range.create(document.positionAt(range.start || 0), document.positionAt((range.start || 0) + (range.length || 0)));
|
|
210
|
-
}
|
|
211
|
-
exports.convertRange = convertRange;
|
|
212
|
-
function convertToLocationRange(defDoc, textSpan) {
|
|
213
|
-
const range = (0, documents_1.mapRangeToOriginal)(defDoc, convertRange(defDoc, textSpan));
|
|
214
|
-
// Some definition like the svelte component class definition don't exist in the original, so we map to 0,1
|
|
215
|
-
if (range.start.line < 0) {
|
|
216
|
-
range.start.line = 0;
|
|
217
|
-
range.start.character = 1;
|
|
218
|
-
}
|
|
219
|
-
if (range.end.line < 0) {
|
|
220
|
-
range.end = range.start;
|
|
221
|
-
}
|
|
222
|
-
return range;
|
|
223
|
-
}
|
|
224
|
-
exports.convertToLocationRange = convertToLocationRange;
|
|
225
|
-
// Some code actions will insert code at the start of the file instead of inside our frontmatter
|
|
226
|
-
// We'll redirect those to the proper starting place
|
|
227
|
-
function ensureFrontmatterInsert(resultRange, document) {
|
|
228
|
-
if (document.astroMeta.frontmatter.state === 'closed') {
|
|
229
|
-
const position = document.positionAt(document.astroMeta.frontmatter.startOffset);
|
|
230
|
-
position.line += 1;
|
|
231
|
-
position.character = resultRange.start.character;
|
|
232
|
-
return vscode_languageserver_1.Range.create(position, position);
|
|
233
|
-
}
|
|
234
|
-
return resultRange;
|
|
235
|
-
}
|
|
236
|
-
exports.ensureFrontmatterInsert = ensureFrontmatterInsert;
|
|
237
|
-
// Some code actions ill insert code at the end of the generated TSX file, so we'll manually
|
|
238
|
-
// redirect it to the end of the frontmatter instead
|
|
239
|
-
function checkEndOfFileCodeInsert(resultRange, document) {
|
|
240
|
-
if (resultRange.start.line > document.lineCount) {
|
|
241
|
-
if (document.astroMeta.frontmatter.state === 'closed') {
|
|
242
|
-
const position = document.positionAt(document.astroMeta.frontmatter.endOffset);
|
|
243
|
-
return vscode_languageserver_1.Range.create(position, position);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return resultRange;
|
|
247
|
-
}
|
|
248
|
-
exports.checkEndOfFileCodeInsert = checkEndOfFileCodeInsert;
|
|
249
|
-
function removeAstroComponentSuffix(name) {
|
|
250
|
-
return name.replace(/(\w+)__AstroComponent_/, '$1');
|
|
251
|
-
}
|
|
252
|
-
exports.removeAstroComponentSuffix = removeAstroComponentSuffix;
|
|
253
|
-
const VirtualExtension = {
|
|
254
|
-
ts: 'ts',
|
|
255
|
-
tsx: 'tsx',
|
|
256
|
-
};
|
|
257
|
-
function getFrameworkFromFilePath(filePath) {
|
|
258
|
-
filePath = ensureRealFilePath(filePath);
|
|
259
|
-
return (0, path_1.extname)(filePath).substring(1);
|
|
260
|
-
}
|
|
261
|
-
exports.getFrameworkFromFilePath = getFrameworkFromFilePath;
|
|
262
|
-
function isVirtualFrameworkFilePath(ext, virtualExt, filePath) {
|
|
263
|
-
return filePath.endsWith('.' + ext + '.' + virtualExt);
|
|
264
|
-
}
|
|
265
|
-
exports.isVirtualFrameworkFilePath = isVirtualFrameworkFilePath;
|
|
266
|
-
function isAstroFilePath(filePath) {
|
|
267
|
-
return filePath.endsWith('.astro');
|
|
268
|
-
}
|
|
269
|
-
exports.isAstroFilePath = isAstroFilePath;
|
|
270
|
-
function isFrameworkFilePath(filePath) {
|
|
271
|
-
return filePath.endsWith('.svelte') || filePath.endsWith('.vue');
|
|
272
|
-
}
|
|
273
|
-
exports.isFrameworkFilePath = isFrameworkFilePath;
|
|
274
|
-
function isVirtualAstroFilePath(filePath) {
|
|
275
|
-
return isVirtualFrameworkFilePath('astro', VirtualExtension.tsx, filePath);
|
|
276
|
-
}
|
|
277
|
-
exports.isVirtualAstroFilePath = isVirtualAstroFilePath;
|
|
278
|
-
function isVirtualVueFilePath(filePath) {
|
|
279
|
-
return isVirtualFrameworkFilePath('vue', VirtualExtension.tsx, filePath);
|
|
280
|
-
}
|
|
281
|
-
exports.isVirtualVueFilePath = isVirtualVueFilePath;
|
|
282
|
-
function isVirtualSvelteFilePath(filePath) {
|
|
283
|
-
return isVirtualFrameworkFilePath('svelte', VirtualExtension.tsx, filePath);
|
|
284
|
-
}
|
|
285
|
-
exports.isVirtualSvelteFilePath = isVirtualSvelteFilePath;
|
|
286
|
-
function isVirtualFilePath(filePath) {
|
|
287
|
-
return isVirtualAstroFilePath(filePath) || isVirtualVueFilePath(filePath) || isVirtualSvelteFilePath(filePath);
|
|
288
|
-
}
|
|
289
|
-
exports.isVirtualFilePath = isVirtualFilePath;
|
|
290
|
-
function toVirtualAstroFilePath(filePath) {
|
|
291
|
-
if (isVirtualAstroFilePath(filePath)) {
|
|
292
|
-
return filePath;
|
|
293
|
-
}
|
|
294
|
-
else if (isAstroFilePath(filePath)) {
|
|
295
|
-
return `${filePath}.tsx`;
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
return filePath;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
exports.toVirtualAstroFilePath = toVirtualAstroFilePath;
|
|
302
|
-
function toVirtualFilePath(filePath) {
|
|
303
|
-
if (isVirtualFilePath(filePath)) {
|
|
304
|
-
return filePath;
|
|
305
|
-
}
|
|
306
|
-
else if (isFrameworkFilePath(filePath) || isAstroFilePath(filePath)) {
|
|
307
|
-
return `${filePath}.tsx`;
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
return filePath;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
exports.toVirtualFilePath = toVirtualFilePath;
|
|
314
|
-
function toRealAstroFilePath(filePath) {
|
|
315
|
-
return filePath.slice(0, -'.tsx'.length);
|
|
316
|
-
}
|
|
317
|
-
exports.toRealAstroFilePath = toRealAstroFilePath;
|
|
318
|
-
function ensureRealAstroFilePath(filePath) {
|
|
319
|
-
return isVirtualAstroFilePath(filePath) ? toRealAstroFilePath(filePath) : filePath;
|
|
320
|
-
}
|
|
321
|
-
exports.ensureRealAstroFilePath = ensureRealAstroFilePath;
|
|
322
|
-
function ensureRealFilePath(filePath) {
|
|
323
|
-
// For Document Symbols, we need to return a different snapshot, so we append a query param to the file path
|
|
324
|
-
// However, we need this removed when we need to deal with real (as in, real on the filesystem) paths
|
|
325
|
-
filePath = filePath.replace('?documentSymbols', '');
|
|
326
|
-
if (isVirtualFilePath(filePath)) {
|
|
327
|
-
let extLen = filePath.endsWith('.tsx') ? 4 : 3;
|
|
328
|
-
return filePath.slice(0, filePath.length - extLen);
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
return filePath;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
exports.ensureRealFilePath = ensureRealFilePath;
|
|
335
|
-
function isDocumentSymbolsPath(filePath) {
|
|
336
|
-
return filePath.endsWith('?documentSymbols');
|
|
337
|
-
}
|
|
338
|
-
exports.isDocumentSymbolsPath = isDocumentSymbolsPath;
|
|
339
|
-
/**
|
|
340
|
-
* Return if a script tag is TypeScript or JavaScript
|
|
341
|
-
*/
|
|
342
|
-
function getScriptTagLanguage(scriptTag) {
|
|
343
|
-
// Using any kind of attributes on the script tag will disable hoisting, so we can just check if there's any
|
|
344
|
-
if (Object.entries(scriptTag.attributes).length === 0) {
|
|
345
|
-
return 'ts';
|
|
346
|
-
}
|
|
347
|
-
return 'js';
|
|
348
|
-
}
|
|
349
|
-
exports.getScriptTagLanguage = getScriptTagLanguage;
|
|
350
|
-
function getScriptTagSnapshot(snapshot, document, tagInfo, position) {
|
|
351
|
-
const index = document.scriptTags.findIndex((value) => value.container.start == tagInfo.start);
|
|
352
|
-
const scriptTagLanguage = getScriptTagLanguage(document.scriptTags[index]);
|
|
353
|
-
const scriptFilePath = snapshot.filePath + `.__script${index}.${scriptTagLanguage}`;
|
|
354
|
-
const scriptTagSnapshot = snapshot.scriptTagSnapshots[index];
|
|
355
|
-
let offset = 0;
|
|
356
|
-
if (position) {
|
|
357
|
-
offset = scriptTagSnapshot.offsetAt(scriptTagSnapshot.getGeneratedPosition(position));
|
|
358
|
-
}
|
|
359
|
-
return {
|
|
360
|
-
snapshot: scriptTagSnapshot,
|
|
361
|
-
filePath: scriptFilePath,
|
|
362
|
-
index,
|
|
363
|
-
offset,
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
exports.getScriptTagSnapshot = getScriptTagSnapshot;
|
package/dist/server.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as vscode from 'vscode-languageserver';
|
|
2
|
-
export interface RuntimeEnvironment {
|
|
3
|
-
loadTypescript: (initOptions: any) => typeof import('typescript/lib/tsserverlibrary');
|
|
4
|
-
loadTypescriptLocalized: (initOptions: any) => Record<string, string> | undefined;
|
|
5
|
-
}
|
|
6
|
-
export declare function startLanguageServer(connection: vscode.Connection, env: RuntimeEnvironment): void;
|
package/dist/server.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.startLanguageServer = void 0;
|
|
27
|
-
const vscode = __importStar(require("vscode-languageserver"));
|
|
28
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
29
|
-
const ConfigManager_1 = require("./core/config/ConfigManager");
|
|
30
|
-
const DiagnosticsManager_1 = require("./core/DiagnosticsManager");
|
|
31
|
-
const DocumentManager_1 = require("./core/documents/DocumentManager");
|
|
32
|
-
const plugins_1 = require("./plugins");
|
|
33
|
-
const AstroPlugin_1 = require("./plugins/astro/AstroPlugin");
|
|
34
|
-
const CSSPlugin_1 = require("./plugins/css/CSSPlugin");
|
|
35
|
-
const HTMLPlugin_1 = require("./plugins/html/HTMLPlugin");
|
|
36
|
-
const PluginHost_1 = require("./plugins/PluginHost");
|
|
37
|
-
const CodeActionsProvider_1 = require("./plugins/typescript/features/CodeActionsProvider");
|
|
38
|
-
const LanguageServiceManager_1 = require("./plugins/typescript/LanguageServiceManager");
|
|
39
|
-
const utils_1 = require("./plugins/typescript/utils");
|
|
40
|
-
const utils_2 = require("./utils");
|
|
41
|
-
const TagCloseRequest = new vscode.RequestType('html/tag');
|
|
42
|
-
// Start the language server
|
|
43
|
-
function startLanguageServer(connection, env) {
|
|
44
|
-
// Create our managers
|
|
45
|
-
const documentManager = new DocumentManager_1.DocumentManager();
|
|
46
|
-
const pluginHost = new PluginHost_1.PluginHost(documentManager);
|
|
47
|
-
let configManager;
|
|
48
|
-
let typescriptPlugin = undefined;
|
|
49
|
-
let hasConfigurationCapability = false;
|
|
50
|
-
connection.onInitialize((params) => {
|
|
51
|
-
let isPnpInit = false;
|
|
52
|
-
const canRequirePnp = params.initializationOptions?.canRequirePnp ?? false;
|
|
53
|
-
const environment = params.initializationOptions?.environment ?? 'node';
|
|
54
|
-
const workspaceUris = params.workspaceFolders?.map((folder) => folder.uri.toString()) ?? [params.rootUri ?? ''];
|
|
55
|
-
workspaceUris.forEach((uri) => {
|
|
56
|
-
uri = (0, utils_2.urlToPath)(uri);
|
|
57
|
-
if (canRequirePnp && !isPnpInit) {
|
|
58
|
-
const possiblePnpPath = (0, utils_2.getWorkspacePnpPath)(uri);
|
|
59
|
-
if (possiblePnpPath) {
|
|
60
|
-
require(possiblePnpPath).setup();
|
|
61
|
-
isPnpInit = true;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// If the workspace is not an Astro project, we shouldn't warn about not finding Astro
|
|
65
|
-
// Unless the extension enabled itself in an untitled workspace, in which case the warning is valid
|
|
66
|
-
if (!(0, utils_2.isAstroWorkspace)(uri) && uri !== '/' && uri !== '') {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const astroInstall = (0, utils_2.getAstroInstall)([uri]);
|
|
70
|
-
if (!astroInstall) {
|
|
71
|
-
connection.sendNotification(vscode_languageserver_1.ShowMessageNotification.type, {
|
|
72
|
-
message: `Couldn't find Astro in workspace "${uri}". Experience might be degraded. For the best experience, please make sure Astro is installed and then restart the language server`,
|
|
73
|
-
type: vscode_languageserver_1.MessageType.Warning,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
hasConfigurationCapability = !!(params.capabilities.workspace && !!params.capabilities.workspace.configuration);
|
|
78
|
-
configManager = new ConfigManager_1.ConfigManager(connection, hasConfigurationCapability);
|
|
79
|
-
pluginHost.initialize({
|
|
80
|
-
filterIncompleteCompletions: !params.initializationOptions?.dontFilterIncompleteCompletions,
|
|
81
|
-
definitionLinkSupport: !!params.capabilities.textDocument?.definition?.linkSupport,
|
|
82
|
-
});
|
|
83
|
-
// Register plugins
|
|
84
|
-
pluginHost.registerPlugin(new HTMLPlugin_1.HTMLPlugin(configManager));
|
|
85
|
-
pluginHost.registerPlugin(new CSSPlugin_1.CSSPlugin(configManager));
|
|
86
|
-
// We don't currently support running the TypeScript and Astro plugin in the browser
|
|
87
|
-
if (environment === 'node') {
|
|
88
|
-
const ts = env.loadTypescript(params.initializationOptions);
|
|
89
|
-
if (ts) {
|
|
90
|
-
const tsLocalized = env.loadTypescriptLocalized(params.initializationOptions);
|
|
91
|
-
const languageServiceManager = new LanguageServiceManager_1.LanguageServiceManager(documentManager, workspaceUris.map(utils_2.normalizeUri), configManager, ts, tsLocalized);
|
|
92
|
-
typescriptPlugin = new plugins_1.TypeScriptPlugin(configManager, languageServiceManager);
|
|
93
|
-
pluginHost.registerPlugin(new AstroPlugin_1.AstroPlugin(configManager, languageServiceManager));
|
|
94
|
-
pluginHost.registerPlugin(typescriptPlugin);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
connection.sendNotification(vscode_languageserver_1.ShowMessageNotification.type, {
|
|
98
|
-
message: `Astro: Couldn't load TypeScript from path ${params?.initializationOptions?.typescript?.serverPath}. Only HTML and CSS features will be enabled`,
|
|
99
|
-
type: vscode_languageserver_1.MessageType.Warning,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
capabilities: {
|
|
105
|
-
textDocumentSync: {
|
|
106
|
-
openClose: true,
|
|
107
|
-
change: vscode.TextDocumentSyncKind.Incremental,
|
|
108
|
-
save: {
|
|
109
|
-
includeText: true,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
foldingRangeProvider: true,
|
|
113
|
-
definitionProvider: true,
|
|
114
|
-
typeDefinitionProvider: true,
|
|
115
|
-
referencesProvider: true,
|
|
116
|
-
implementationProvider: true,
|
|
117
|
-
renameProvider: params.capabilities.textDocument?.rename?.prepareSupport ? { prepareProvider: true } : true,
|
|
118
|
-
documentFormattingProvider: true,
|
|
119
|
-
codeActionProvider: {
|
|
120
|
-
codeActionKinds: [
|
|
121
|
-
vscode_languageserver_1.CodeActionKind.QuickFix,
|
|
122
|
-
vscode_languageserver_1.CodeActionKind.SourceOrganizeImports,
|
|
123
|
-
// VS Code specific
|
|
124
|
-
CodeActionsProvider_1.sortImportKind,
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
completionProvider: {
|
|
128
|
-
resolveProvider: true,
|
|
129
|
-
triggerCharacters: [
|
|
130
|
-
'.',
|
|
131
|
-
'"',
|
|
132
|
-
"'",
|
|
133
|
-
'`',
|
|
134
|
-
'/',
|
|
135
|
-
'@',
|
|
136
|
-
'<',
|
|
137
|
-
' ',
|
|
138
|
-
// Emmet
|
|
139
|
-
'>',
|
|
140
|
-
'*',
|
|
141
|
-
'#',
|
|
142
|
-
'$',
|
|
143
|
-
'+',
|
|
144
|
-
'^',
|
|
145
|
-
'(',
|
|
146
|
-
'[',
|
|
147
|
-
'@',
|
|
148
|
-
'-',
|
|
149
|
-
// No whitespace because
|
|
150
|
-
// it makes for weird/too many completions
|
|
151
|
-
// of other completion providers
|
|
152
|
-
// Astro
|
|
153
|
-
':',
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
colorProvider: true,
|
|
157
|
-
hoverProvider: true,
|
|
158
|
-
documentSymbolProvider: true,
|
|
159
|
-
linkedEditingRangeProvider: true,
|
|
160
|
-
semanticTokensProvider: {
|
|
161
|
-
legend: (0, utils_1.getSemanticTokenLegend)(),
|
|
162
|
-
range: true,
|
|
163
|
-
full: true,
|
|
164
|
-
},
|
|
165
|
-
inlayHintProvider: true,
|
|
166
|
-
signatureHelpProvider: {
|
|
167
|
-
triggerCharacters: ['(', ',', '<'],
|
|
168
|
-
retriggerCharacters: [')'],
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
});
|
|
173
|
-
// The params don't matter here because in "pull mode" it's always null, it's intended that when the config is updated
|
|
174
|
-
// you should just reset "your internal cache" and get the config again for relevant documents, weird API design
|
|
175
|
-
connection.onDidChangeConfiguration(async (change) => {
|
|
176
|
-
if (hasConfigurationCapability) {
|
|
177
|
-
configManager.updateConfig();
|
|
178
|
-
documentManager.getAllOpenedByClient().forEach(async (document) => {
|
|
179
|
-
await configManager.getConfig('astro', document[1].uri);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
configManager.updateGlobalConfig(change.settings.astro || ConfigManager_1.defaultLSConfig);
|
|
184
|
-
}
|
|
185
|
-
updateAllDiagnostics();
|
|
186
|
-
});
|
|
187
|
-
// Documents
|
|
188
|
-
connection.onDidOpenTextDocument((params) => {
|
|
189
|
-
documentManager.openDocument(params.textDocument);
|
|
190
|
-
documentManager.markAsOpenedInClient(params.textDocument.uri);
|
|
191
|
-
});
|
|
192
|
-
connection.onDidCloseTextDocument((params) => documentManager.closeDocument(params.textDocument.uri));
|
|
193
|
-
connection.onDidChangeTextDocument((params) => {
|
|
194
|
-
documentManager.updateDocument(params.textDocument, params.contentChanges);
|
|
195
|
-
});
|
|
196
|
-
const diagnosticsManager = new DiagnosticsManager_1.DiagnosticsManager(connection.sendDiagnostics, documentManager, pluginHost.getDiagnostics.bind(pluginHost));
|
|
197
|
-
const updateAllDiagnostics = (0, utils_2.debounceThrottle)(() => diagnosticsManager.updateAll(), 1000);
|
|
198
|
-
connection.onDidChangeWatchedFiles(async (evt) => {
|
|
199
|
-
const params = evt.changes
|
|
200
|
-
.map((change) => ({
|
|
201
|
-
fileName: (0, utils_2.urlToPath)(change.uri),
|
|
202
|
-
changeType: change.type,
|
|
203
|
-
}))
|
|
204
|
-
.filter((change) => !!change.fileName);
|
|
205
|
-
await pluginHost.onWatchFileChanges(params);
|
|
206
|
-
updateAllDiagnostics();
|
|
207
|
-
});
|
|
208
|
-
// Features
|
|
209
|
-
connection.onHover((params) => pluginHost.doHover(params.textDocument, params.position));
|
|
210
|
-
connection.onDefinition((evt) => pluginHost.getDefinitions(evt.textDocument, evt.position));
|
|
211
|
-
connection.onTypeDefinition((evt) => pluginHost.getTypeDefinitions(evt.textDocument, evt.position));
|
|
212
|
-
connection.onReferences((evt) => pluginHost.getReferences(evt.textDocument, evt.position, evt.context));
|
|
213
|
-
connection.onImplementation((evt) => pluginHost.getImplementations(evt.textDocument, evt.position));
|
|
214
|
-
connection.onFoldingRanges((evt) => pluginHost.getFoldingRanges(evt.textDocument));
|
|
215
|
-
connection.onCodeAction((evt, cancellationToken) => pluginHost.getCodeActions(evt.textDocument, evt.range, evt.context, cancellationToken));
|
|
216
|
-
connection.onCompletion(async (evt) => {
|
|
217
|
-
const promise = pluginHost.getCompletions(evt.textDocument, evt.position, evt.context);
|
|
218
|
-
return promise;
|
|
219
|
-
});
|
|
220
|
-
connection.onCompletionResolve((completionItem) => {
|
|
221
|
-
const data = completionItem.data;
|
|
222
|
-
if (!data) {
|
|
223
|
-
return completionItem;
|
|
224
|
-
}
|
|
225
|
-
return pluginHost.resolveCompletion(data, completionItem);
|
|
226
|
-
});
|
|
227
|
-
connection.onDocumentSymbol((params, cancellationToken) => pluginHost.getDocumentSymbols(params.textDocument, cancellationToken));
|
|
228
|
-
connection.onRequest(vscode_languageserver_1.SemanticTokensRequest.type, (evt, cancellationToken) => pluginHost.getSemanticTokens(evt.textDocument, undefined, cancellationToken));
|
|
229
|
-
connection.onRequest(vscode_languageserver_1.SemanticTokensRangeRequest.type, (evt, cancellationToken) => pluginHost.getSemanticTokens(evt.textDocument, evt.range, cancellationToken));
|
|
230
|
-
connection.onRequest(vscode_languageserver_1.LinkedEditingRangeRequest.type, async (evt) => await pluginHost.getLinkedEditingRanges(evt.textDocument, evt.position));
|
|
231
|
-
connection.onDocumentFormatting((params) => pluginHost.formatDocument(params.textDocument, params.options));
|
|
232
|
-
connection.onDocumentColor((params) => pluginHost.getDocumentColors(params.textDocument));
|
|
233
|
-
connection.onColorPresentation((params) => pluginHost.getColorPresentations(params.textDocument, params.range, params.color));
|
|
234
|
-
connection.onRequest(vscode_languageserver_1.InlayHintRequest.type, (params, cancellationToken) => pluginHost.getInlayHints(params.textDocument, params.range, cancellationToken));
|
|
235
|
-
connection.onRequest(TagCloseRequest, (evt) => pluginHost.doTagComplete(evt.textDocument, evt.position));
|
|
236
|
-
connection.onSignatureHelp((evt, cancellationToken) => pluginHost.getSignatureHelp(evt.textDocument, evt.position, evt.context, cancellationToken));
|
|
237
|
-
connection.onPrepareRename((evt) => pluginHost.prepareRename(evt.textDocument, evt.position));
|
|
238
|
-
connection.onRenameRequest((evt) => pluginHost.rename(evt.textDocument, evt.position, evt.newName));
|
|
239
|
-
connection.onDidSaveTextDocument(updateAllDiagnostics);
|
|
240
|
-
connection.onNotification('$/onDidChangeNonAstroFile', async (e) => {
|
|
241
|
-
const path = (0, utils_2.urlToPath)(e.uri);
|
|
242
|
-
if (path) {
|
|
243
|
-
pluginHost.updateNonAstroFile(path, e.changes, e.text);
|
|
244
|
-
}
|
|
245
|
-
updateAllDiagnostics();
|
|
246
|
-
});
|
|
247
|
-
connection.onRequest('$/getFileReferences', async (uri) => {
|
|
248
|
-
return pluginHost.fileReferences({ uri });
|
|
249
|
-
});
|
|
250
|
-
connection.onRequest('$/getTSXOutput', async (uri) => {
|
|
251
|
-
const doc = documentManager.get(uri);
|
|
252
|
-
if (!doc) {
|
|
253
|
-
return undefined;
|
|
254
|
-
}
|
|
255
|
-
if (doc && typescriptPlugin) {
|
|
256
|
-
const tsxOutput = typescriptPlugin.getTSXForDocument(doc);
|
|
257
|
-
return tsxOutput.code;
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
documentManager.on('documentChange', updateAllDiagnostics);
|
|
261
|
-
documentManager.on('documentClose', (document) => {
|
|
262
|
-
diagnosticsManager.removeDiagnostics(document);
|
|
263
|
-
configManager.removeDocument(document.uri);
|
|
264
|
-
});
|
|
265
|
-
// Taking off 🚀
|
|
266
|
-
connection.onInitialized(() => {
|
|
267
|
-
connection.console.log('Successfully initialized! 🚀');
|
|
268
|
-
// Register for all configuration changes.
|
|
269
|
-
if (hasConfigurationCapability) {
|
|
270
|
-
connection.client.register(vscode_languageserver_1.DidChangeConfigurationNotification.type);
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
connection.listen();
|
|
274
|
-
}
|
|
275
|
-
exports.startLanguageServer = startLanguageServer;
|
package/types/README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Types
|
|
2
|
-
|
|
3
|
-
**Heads up!** `env.d.ts` and `astro-jsx.d.ts` in this folder are only used as fallback by the language server whenever we're not able to load the real types from the user's project. The types here should be in line with the types from Astro, but only loosely as not being able to load the real types from the user's project is an uncommon situation and some things are not necessarily possible without relying on Astro's internals
|
|
4
|
-
|
|
5
|
-
As such, if you're making a PR to fix/improve something related to types, you should probably make a PR to [Astro itself](https://github.com/withastro/astro), not this project!
|
|
File without changes
|
|
File without changes
|