@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,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HTMLPlugin = void 0;
|
|
4
|
-
const emmet_helper_1 = require("@vscode/emmet-helper");
|
|
5
|
-
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
6
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
7
|
-
const utils_1 = require("../../core/documents/utils");
|
|
8
|
-
const astro_attributes_1 = require("./features/astro-attributes");
|
|
9
|
-
const utils_2 = require("./utils");
|
|
10
|
-
class HTMLPlugin {
|
|
11
|
-
constructor(configManager) {
|
|
12
|
-
this.__name = 'html';
|
|
13
|
-
this.lang = (0, vscode_html_languageservice_1.getLanguageService)({
|
|
14
|
-
customDataProviders: [astro_attributes_1.astroAttributes, astro_attributes_1.astroElements, astro_attributes_1.classListAttribute],
|
|
15
|
-
});
|
|
16
|
-
this.attributeOnlyLang = (0, vscode_html_languageservice_1.getLanguageService)({
|
|
17
|
-
customDataProviders: [astro_attributes_1.astroAttributes],
|
|
18
|
-
useDefaultDataProvider: false,
|
|
19
|
-
});
|
|
20
|
-
this.componentLang = (0, vscode_html_languageservice_1.getLanguageService)({
|
|
21
|
-
customDataProviders: [astro_attributes_1.astroAttributes, astro_attributes_1.astroDirectives],
|
|
22
|
-
useDefaultDataProvider: false,
|
|
23
|
-
});
|
|
24
|
-
this.styleScriptTemplate = new Set(['style']);
|
|
25
|
-
this.configManager = configManager;
|
|
26
|
-
}
|
|
27
|
-
async doHover(document, position) {
|
|
28
|
-
if (!(await this.featureEnabled(document, 'hover'))) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const html = document.html;
|
|
32
|
-
if (!html) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
const node = html.findNodeAt(document.offsetAt(position));
|
|
36
|
-
if (!node) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
// If the node we're hovering on is a component, instead only provide astro-specific hover info
|
|
40
|
-
if ((0, utils_1.isPossibleComponent)(node) && node.tag !== 'Fragment') {
|
|
41
|
-
return this.componentLang.doHover(document, position, html);
|
|
42
|
-
}
|
|
43
|
-
return this.lang.doHover(document, position, html);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get HTML completions
|
|
47
|
-
*/
|
|
48
|
-
async getCompletions(document, position) {
|
|
49
|
-
if (!(await this.featureEnabled(document, 'completions'))) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
const html = document.html;
|
|
53
|
-
const offset = document.offsetAt(position);
|
|
54
|
-
if (!html ||
|
|
55
|
-
(0, utils_1.isInsideFrontmatter)(document.getText(), offset) ||
|
|
56
|
-
(0, utils_1.isInsideExpression)(document.getText(), html.findNodeAt(offset).start, offset)) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
// Get Emmet completions
|
|
60
|
-
let emmetResults = {
|
|
61
|
-
isIncomplete: true,
|
|
62
|
-
items: [],
|
|
63
|
-
};
|
|
64
|
-
const emmetConfig = await this.configManager.getEmmetConfig(document);
|
|
65
|
-
const extensionConfig = (await this.configManager.getConfig('astro', document.uri)) ?? {};
|
|
66
|
-
if (extensionConfig?.html?.completions?.emmet ?? true) {
|
|
67
|
-
this.lang.setCompletionParticipants([
|
|
68
|
-
{
|
|
69
|
-
onHtmlContent: () => (emmetResults = (0, emmet_helper_1.doComplete)(document, position, 'html', emmetConfig) || emmetResults),
|
|
70
|
-
},
|
|
71
|
-
]);
|
|
72
|
-
}
|
|
73
|
-
// If we're in a component starting tag, we do not want HTML language completions
|
|
74
|
-
// as HTML attributes are not valid for components
|
|
75
|
-
const inComponentTag = (0, utils_1.isInComponentStartTag)(html, offset);
|
|
76
|
-
const inTagName = (0, utils_1.isInTagName)(html, offset);
|
|
77
|
-
const results = inComponentTag && !inTagName
|
|
78
|
-
? (0, utils_2.removeDataAttrCompletion)(this.attributeOnlyLang.doComplete(document, position, html).items)
|
|
79
|
-
: this.lang.doComplete(document, position, html).items.filter(isNoAddedTagWithNoDocumentation);
|
|
80
|
-
const langCompletions = inComponentTag ? [] : this.getLangCompletions(results);
|
|
81
|
-
return vscode_languageserver_1.CompletionList.create([...results, ...langCompletions, ...emmetResults.items],
|
|
82
|
-
// Emmet completions change on every keystroke, so they are never complete
|
|
83
|
-
emmetResults.items.length > 0);
|
|
84
|
-
// Filter script and style completions with no documentation to prevent duplicates
|
|
85
|
-
// due to our added definitions for those tags
|
|
86
|
-
function isNoAddedTagWithNoDocumentation(item) {
|
|
87
|
-
return !(['script', 'style'].includes(item.label) && item.documentation === undefined);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
getFoldingRanges(document) {
|
|
91
|
-
const html = document.html;
|
|
92
|
-
if (!html) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
return this.lang.getFoldingRanges(document);
|
|
96
|
-
}
|
|
97
|
-
getLinkedEditingRanges(document, position) {
|
|
98
|
-
const html = document.html;
|
|
99
|
-
if (!html) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
const ranges = this.lang.findLinkedEditingRanges(document, position, html);
|
|
103
|
-
if (!ranges) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
return { ranges };
|
|
107
|
-
}
|
|
108
|
-
async doTagComplete(document, position) {
|
|
109
|
-
if (!(await this.featureEnabled(document, 'tagComplete'))) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
const html = document.html;
|
|
113
|
-
const offset = document.offsetAt(position);
|
|
114
|
-
if (!html ||
|
|
115
|
-
(0, utils_1.isInsideFrontmatter)(document.getText(), offset) ||
|
|
116
|
-
(0, utils_1.isInsideExpression)(document.getText(), html.findNodeAt(offset).start, offset)) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
return this.lang.doTagComplete(document, position, html);
|
|
120
|
-
}
|
|
121
|
-
prepareRename(document, position) {
|
|
122
|
-
const html = document.html;
|
|
123
|
-
const offset = document.offsetAt(position);
|
|
124
|
-
const node = html.findNodeAt(offset);
|
|
125
|
-
if (!node || (0, utils_1.isPossibleComponent)(node) || !node.tag || !this.isRenameAtTag(node, offset)) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
const tagNameStart = node.start + '<'.length;
|
|
129
|
-
return vscode_languageserver_1.Range.create(document.positionAt(tagNameStart), document.positionAt(tagNameStart + node.tag.length));
|
|
130
|
-
}
|
|
131
|
-
rename(document, position, newName) {
|
|
132
|
-
const html = document.html;
|
|
133
|
-
const offset = document.offsetAt(position);
|
|
134
|
-
if (!html || (0, utils_1.isInsideFrontmatter)(document.getText(), offset)) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
const node = html.findNodeAt(offset);
|
|
138
|
-
// The TypeScript plugin handles renaming for components
|
|
139
|
-
if (!node || (0, utils_1.isPossibleComponent)(node) || !this.isRenameAtTag(node, offset)) {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
return this.lang.doRename(document, position, newName, html);
|
|
143
|
-
}
|
|
144
|
-
async getDocumentSymbols(document) {
|
|
145
|
-
if (!(await this.featureEnabled(document, 'documentSymbols'))) {
|
|
146
|
-
return [];
|
|
147
|
-
}
|
|
148
|
-
const html = document.html;
|
|
149
|
-
if (!html) {
|
|
150
|
-
return [];
|
|
151
|
-
}
|
|
152
|
-
return this.lang.findDocumentSymbols(document, html);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Get lang completions for style tags (ex: `<style lang="scss">`)
|
|
156
|
-
*/
|
|
157
|
-
getLangCompletions(completions) {
|
|
158
|
-
const styleScriptTemplateCompletions = completions.filter((completion) => completion.kind === vscode_languageserver_1.CompletionItemKind.Property && this.styleScriptTemplate.has(completion.label));
|
|
159
|
-
const langCompletions = [];
|
|
160
|
-
addLangCompletion('style', ['scss', 'sass', 'less', 'styl', 'stylus']);
|
|
161
|
-
return langCompletions;
|
|
162
|
-
/** Add language completions */
|
|
163
|
-
function addLangCompletion(tag, languages) {
|
|
164
|
-
const existingCompletion = styleScriptTemplateCompletions.find((completion) => completion.label === tag);
|
|
165
|
-
if (!existingCompletion) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
languages.forEach((lang) => langCompletions.push({
|
|
169
|
-
...existingCompletion,
|
|
170
|
-
label: `${tag} (lang="${lang}")`,
|
|
171
|
-
insertText: existingCompletion.insertText && `${existingCompletion.insertText} lang="${lang}"`,
|
|
172
|
-
textEdit: existingCompletion.textEdit && vscode_languageserver_1.TextEdit.is(existingCompletion.textEdit)
|
|
173
|
-
? {
|
|
174
|
-
range: existingCompletion.textEdit.range,
|
|
175
|
-
newText: `${existingCompletion.textEdit.newText} lang="${lang}"`,
|
|
176
|
-
}
|
|
177
|
-
: undefined,
|
|
178
|
-
}));
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Returns true if rename happens at the tag name, not anywhere inbetween.
|
|
183
|
-
*/
|
|
184
|
-
isRenameAtTag(node, offset) {
|
|
185
|
-
if (!node.tag) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
const startTagNameEnd = node.start + `<${node.tag}`.length;
|
|
189
|
-
const isAtStartTag = offset > node.start && offset <= startTagNameEnd;
|
|
190
|
-
const isAtEndTag = node.endTagStart !== undefined && offset >= node.endTagStart && offset < node.end;
|
|
191
|
-
return isAtStartTag || isAtEndTag;
|
|
192
|
-
}
|
|
193
|
-
async featureEnabled(document, feature) {
|
|
194
|
-
return ((await this.configManager.isEnabled(document, 'html')) &&
|
|
195
|
-
(await this.configManager.isEnabled(document, 'html', feature)));
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
exports.HTMLPlugin = HTMLPlugin;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { CompletionItem } from 'vscode-languageserver-types';
|
|
2
|
-
/**
|
|
3
|
-
* The VS Code HTML language service provides a completion for data attributes that is independent from
|
|
4
|
-
* data providers, which mean that you can't disable it, so this function removes them from completions
|
|
5
|
-
*/
|
|
6
|
-
export declare function removeDataAttrCompletion(items: CompletionItem[]): CompletionItem[];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeDataAttrCompletion = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The VS Code HTML language service provides a completion for data attributes that is independent from
|
|
6
|
-
* data providers, which mean that you can't disable it, so this function removes them from completions
|
|
7
|
-
*/
|
|
8
|
-
function removeDataAttrCompletion(items) {
|
|
9
|
-
return items.filter((item) => !item.label.startsWith('data-'));
|
|
10
|
-
}
|
|
11
|
-
exports.removeDataAttrCompletion = removeDataAttrCompletion;
|
package/dist/plugins/index.d.ts
DELETED
package/dist/plugins/index.js
DELETED
|
@@ -1,22 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./astro/AstroPlugin"), exports);
|
|
18
|
-
__exportStar(require("./css/CSSPlugin"), exports);
|
|
19
|
-
__exportStar(require("./html/HTMLPlugin"), exports);
|
|
20
|
-
__exportStar(require("./interfaces"), exports);
|
|
21
|
-
__exportStar(require("./PluginHost"), exports);
|
|
22
|
-
__exportStar(require("./typescript/TypeScriptPlugin"), exports);
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { CodeAction, CodeActionContext, Color, ColorInformation, ColorPresentation, CompletionContext, CompletionItem, CompletionList, DefinitionLink, Diagnostic, FileChangeType, FoldingRange, FormattingOptions, Hover, InlayHint, LinkedEditingRanges, Location, Position, Range, ReferenceContext, SelectionRange, SemanticTokens, SignatureHelp, SignatureHelpContext, SymbolInformation, TextDocumentContentChangeEvent, TextDocumentIdentifier, TextEdit, WorkspaceEdit } from 'vscode-languageserver';
|
|
2
|
-
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
-
export type Resolvable<T> = T | Promise<T>;
|
|
4
|
-
export interface AppCompletionItem<T extends TextDocumentIdentifier = any> extends CompletionItem {
|
|
5
|
-
data?: T;
|
|
6
|
-
}
|
|
7
|
-
export interface AppCompletionList<T extends TextDocumentIdentifier = any> extends CompletionList {
|
|
8
|
-
items: Array<AppCompletionItem<T>>;
|
|
9
|
-
}
|
|
10
|
-
export interface DiagnosticsProvider {
|
|
11
|
-
getDiagnostics(document: TextDocument): Resolvable<Diagnostic[]>;
|
|
12
|
-
}
|
|
13
|
-
export interface HoverProvider {
|
|
14
|
-
doHover(document: TextDocument, position: Position): Resolvable<Hover | null>;
|
|
15
|
-
}
|
|
16
|
-
export interface FoldingRangesProvider {
|
|
17
|
-
getFoldingRanges(document: TextDocument): Resolvable<FoldingRange[] | null>;
|
|
18
|
-
}
|
|
19
|
-
export interface CompletionsProvider<T extends TextDocumentIdentifier = any> {
|
|
20
|
-
getCompletions(document: TextDocument, position: Position, completionContext?: CompletionContext): Resolvable<AppCompletionList<T> | null>;
|
|
21
|
-
resolveCompletion?(document: TextDocument, completionItem: AppCompletionItem<T>): Resolvable<AppCompletionItem<T>>;
|
|
22
|
-
}
|
|
23
|
-
export interface FormattingProvider {
|
|
24
|
-
formatDocument(document: TextDocument, options: FormattingOptions): Resolvable<TextEdit[]>;
|
|
25
|
-
}
|
|
26
|
-
export interface TagCompleteProvider {
|
|
27
|
-
doTagComplete(document: TextDocument, position: Position): Resolvable<string | null>;
|
|
28
|
-
}
|
|
29
|
-
export interface DocumentColorsProvider {
|
|
30
|
-
getDocumentColors(document: TextDocument): Resolvable<ColorInformation[]>;
|
|
31
|
-
}
|
|
32
|
-
export interface ColorPresentationsProvider {
|
|
33
|
-
getColorPresentations(document: TextDocument, range: Range, color: Color): Resolvable<ColorPresentation[]>;
|
|
34
|
-
}
|
|
35
|
-
export interface DocumentSymbolsProvider {
|
|
36
|
-
getDocumentSymbols(document: TextDocument): Resolvable<SymbolInformation[]>;
|
|
37
|
-
}
|
|
38
|
-
export interface FileReferencesProvider {
|
|
39
|
-
fileReferences(document: TextDocument): Promise<Location[] | null>;
|
|
40
|
-
}
|
|
41
|
-
export interface DefinitionsProvider {
|
|
42
|
-
getDefinitions(document: TextDocument, position: Position): Resolvable<DefinitionLink[]>;
|
|
43
|
-
}
|
|
44
|
-
export interface BackwardsCompatibleDefinitionsProvider {
|
|
45
|
-
getDefinitions(document: TextDocument, position: Position): Resolvable<DefinitionLink[] | Location[]>;
|
|
46
|
-
}
|
|
47
|
-
export interface CodeActionsProvider {
|
|
48
|
-
getCodeActions(document: TextDocument, range: Range, context: CodeActionContext): Resolvable<CodeAction[]>;
|
|
49
|
-
executeCommand?(document: TextDocument, command: string, args?: any[]): Resolvable<WorkspaceEdit | string | null>;
|
|
50
|
-
}
|
|
51
|
-
export interface FileRename {
|
|
52
|
-
oldUri: string;
|
|
53
|
-
newUri: string;
|
|
54
|
-
}
|
|
55
|
-
export interface UpdateImportsProvider {
|
|
56
|
-
updateImports(fileRename: FileRename): Resolvable<WorkspaceEdit | null>;
|
|
57
|
-
}
|
|
58
|
-
export interface InlayHintsProvider {
|
|
59
|
-
getInlayHints(document: TextDocument, range: Range): Resolvable<InlayHint[]>;
|
|
60
|
-
}
|
|
61
|
-
export interface RenameProvider {
|
|
62
|
-
rename(document: TextDocument, position: Position, newName: string): Resolvable<WorkspaceEdit | null>;
|
|
63
|
-
prepareRename(document: TextDocument, position: Position): Resolvable<Range | null>;
|
|
64
|
-
}
|
|
65
|
-
export interface FindReferencesProvider {
|
|
66
|
-
findReferences(document: TextDocument, position: Position, context: ReferenceContext): Promise<Location[] | null>;
|
|
67
|
-
}
|
|
68
|
-
export interface SignatureHelpProvider {
|
|
69
|
-
getSignatureHelp(document: TextDocument, position: Position, context: SignatureHelpContext | undefined): Resolvable<SignatureHelp | null>;
|
|
70
|
-
}
|
|
71
|
-
export interface SelectionRangeProvider {
|
|
72
|
-
getSelectionRange(document: TextDocument, position: Position): Resolvable<SelectionRange | null>;
|
|
73
|
-
}
|
|
74
|
-
export interface SemanticTokensProvider {
|
|
75
|
-
getSemanticTokens(textDocument: TextDocument, range?: Range): Resolvable<SemanticTokens | null>;
|
|
76
|
-
}
|
|
77
|
-
export interface LinkedEditingRangesProvider {
|
|
78
|
-
getLinkedEditingRanges(document: TextDocument, position: Position): Resolvable<LinkedEditingRanges | null>;
|
|
79
|
-
}
|
|
80
|
-
export interface ImplementationProvider {
|
|
81
|
-
getImplementation(document: TextDocument, position: Position): Resolvable<Location[] | null>;
|
|
82
|
-
}
|
|
83
|
-
export interface TypeDefinitionsProvider {
|
|
84
|
-
getTypeDefinitions(document: TextDocument, position: Position): Resolvable<Location[] | null>;
|
|
85
|
-
}
|
|
86
|
-
export interface OnWatchFileChangesParam {
|
|
87
|
-
fileName: string;
|
|
88
|
-
changeType: FileChangeType;
|
|
89
|
-
}
|
|
90
|
-
export interface OnWatchFileChangesProvider {
|
|
91
|
-
onWatchFileChanges(onWatchFileChangesParams: OnWatchFileChangesParam[]): Promise<void>;
|
|
92
|
-
}
|
|
93
|
-
export interface UpdateNonAstroFile {
|
|
94
|
-
updateNonAstroFile(fileName: string, changes: TextDocumentContentChangeEvent[], text?: string): void;
|
|
95
|
-
}
|
|
96
|
-
type ProviderBase = DiagnosticsProvider & HoverProvider & CompletionsProvider & FileReferencesProvider & DefinitionsProvider & TypeDefinitionsProvider & ImplementationProvider & FormattingProvider & FoldingRangesProvider & TagCompleteProvider & DocumentColorsProvider & ColorPresentationsProvider & DocumentSymbolsProvider & UpdateImportsProvider & CodeActionsProvider & FindReferencesProvider & RenameProvider & SignatureHelpProvider & SemanticTokensProvider & SelectionRangeProvider & OnWatchFileChangesProvider & LinkedEditingRangesProvider & InlayHintsProvider & UpdateNonAstroFile;
|
|
97
|
-
export type LSProvider = ProviderBase;
|
|
98
|
-
export type Plugin = Partial<ProviderBase> & {
|
|
99
|
-
__name: string;
|
|
100
|
-
};
|
|
101
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript';
|
|
2
|
-
import type { TextDocumentContentChangeEvent } from 'vscode-languageserver';
|
|
3
|
-
import type { ConfigManager } from '../../core/config';
|
|
4
|
-
import type { AstroDocument, DocumentManager } from '../../core/documents';
|
|
5
|
-
import { LanguageServiceContainer, LanguageServiceDocumentContext } from './language-service';
|
|
6
|
-
import type { DocumentSnapshot } from './snapshots/DocumentSnapshot';
|
|
7
|
-
import { SnapshotManager } from './snapshots/SnapshotManager';
|
|
8
|
-
export declare class LanguageServiceManager {
|
|
9
|
-
private readonly docManager;
|
|
10
|
-
private readonly workspaceUris;
|
|
11
|
-
private readonly configManager;
|
|
12
|
-
docContext: LanguageServiceDocumentContext;
|
|
13
|
-
private globalSnapshotManager;
|
|
14
|
-
constructor(docManager: DocumentManager, workspaceUris: string[], configManager: ConfigManager, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized?: Record<string, string> | undefined);
|
|
15
|
-
/**
|
|
16
|
-
* Create an AstroDocument (only for astro files)
|
|
17
|
-
*/
|
|
18
|
-
private createDocument;
|
|
19
|
-
getSnapshot(document: AstroDocument): Promise<DocumentSnapshot>;
|
|
20
|
-
getSnapshot(pathOrDoc: string | AstroDocument): Promise<DocumentSnapshot>;
|
|
21
|
-
/**
|
|
22
|
-
* Updates snapshot path in all existing ts services and retrieves snapshot
|
|
23
|
-
*/
|
|
24
|
-
updateSnapshotPath(oldPath: string, newPath: string): Promise<DocumentSnapshot>;
|
|
25
|
-
/**
|
|
26
|
-
* Deletes snapshot in all existing ts services
|
|
27
|
-
*/
|
|
28
|
-
deleteSnapshot(filePath: string): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Updates project files in all existing ts services
|
|
31
|
-
*/
|
|
32
|
-
updateProjectFiles(): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Updates file in all ts services where it exists
|
|
35
|
-
*/
|
|
36
|
-
updateExistingNonAstroFile(path: string, changes?: TextDocumentContentChangeEvent[], text?: string): Promise<void>;
|
|
37
|
-
getLSAndTSDoc(document: AstroDocument): Promise<{
|
|
38
|
-
tsDoc: DocumentSnapshot;
|
|
39
|
-
lang: ts.LanguageService;
|
|
40
|
-
}>;
|
|
41
|
-
getLSForPath(path: string): Promise<ts.LanguageService>;
|
|
42
|
-
getTypeScriptLanguageService(filePath: string): Promise<LanguageServiceContainer>;
|
|
43
|
-
/**
|
|
44
|
-
* @internal Public for tests only
|
|
45
|
-
*/
|
|
46
|
-
getSnapshotManager(filePath: string): Promise<SnapshotManager>;
|
|
47
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LanguageServiceManager = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const language_service_1 = require("./language-service");
|
|
6
|
-
const SnapshotManager_1 = require("./snapshots/SnapshotManager");
|
|
7
|
-
class LanguageServiceManager {
|
|
8
|
-
constructor(docManager, workspaceUris, configManager, ts, tsLocalized) {
|
|
9
|
-
this.docManager = docManager;
|
|
10
|
-
this.workspaceUris = workspaceUris;
|
|
11
|
-
this.configManager = configManager;
|
|
12
|
-
/**
|
|
13
|
-
* Create an AstroDocument (only for astro files)
|
|
14
|
-
*/
|
|
15
|
-
this.createDocument = (fileName, content) => {
|
|
16
|
-
const uri = (0, utils_1.pathToUrl)(fileName);
|
|
17
|
-
const document = this.docManager.openDocument({
|
|
18
|
-
text: content,
|
|
19
|
-
uri,
|
|
20
|
-
});
|
|
21
|
-
this.docManager.lockDocument(uri);
|
|
22
|
-
return document;
|
|
23
|
-
};
|
|
24
|
-
this.globalSnapshotManager = new SnapshotManager_1.GlobalSnapshotManager(ts);
|
|
25
|
-
this.docContext = {
|
|
26
|
-
createDocument: this.createDocument,
|
|
27
|
-
globalSnapshotManager: this.globalSnapshotManager,
|
|
28
|
-
configManager: this.configManager,
|
|
29
|
-
ts,
|
|
30
|
-
tsLocalized: tsLocalized,
|
|
31
|
-
};
|
|
32
|
-
const handleDocumentChange = (document) => {
|
|
33
|
-
this.getSnapshot(document);
|
|
34
|
-
};
|
|
35
|
-
docManager.on('documentChange', (0, utils_1.debounceSameArg)(handleDocumentChange, (newDoc, prevDoc) => newDoc.uri === prevDoc?.uri, 1000));
|
|
36
|
-
docManager.on('documentOpen', handleDocumentChange);
|
|
37
|
-
}
|
|
38
|
-
async getSnapshot(pathOrDoc) {
|
|
39
|
-
const filePath = typeof pathOrDoc === 'string' ? pathOrDoc : pathOrDoc.getFilePath() || '';
|
|
40
|
-
const tsService = await this.getTypeScriptLanguageService(filePath);
|
|
41
|
-
return tsService.updateSnapshot(pathOrDoc, this.docContext.ts);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Updates snapshot path in all existing ts services and retrieves snapshot
|
|
45
|
-
*/
|
|
46
|
-
async updateSnapshotPath(oldPath, newPath) {
|
|
47
|
-
await this.deleteSnapshot(oldPath);
|
|
48
|
-
return this.getSnapshot(newPath);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Deletes snapshot in all existing ts services
|
|
52
|
-
*/
|
|
53
|
-
async deleteSnapshot(filePath) {
|
|
54
|
-
await (0, language_service_1.forAllLanguageServices)((service) => service.deleteSnapshot(filePath));
|
|
55
|
-
this.docManager.releaseDocument((0, utils_1.pathToUrl)(filePath));
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Updates project files in all existing ts services
|
|
59
|
-
*/
|
|
60
|
-
async updateProjectFiles() {
|
|
61
|
-
await (0, language_service_1.forAllLanguageServices)((service) => service.updateProjectFiles());
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Updates file in all ts services where it exists
|
|
65
|
-
*/
|
|
66
|
-
async updateExistingNonAstroFile(path, changes, text) {
|
|
67
|
-
path = (0, utils_1.normalizePath)(path);
|
|
68
|
-
// Only update once because all snapshots are shared between
|
|
69
|
-
// services. Since we don't have a current version of TS/JS
|
|
70
|
-
// files, the operation wouldn't be idempotent.
|
|
71
|
-
let didUpdate = false;
|
|
72
|
-
await (0, language_service_1.forAllLanguageServices)((service) => {
|
|
73
|
-
if (service.hasFile(path) && !didUpdate) {
|
|
74
|
-
didUpdate = true;
|
|
75
|
-
service.updateNonAstroFile(path, changes, text);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
async getLSAndTSDoc(document) {
|
|
80
|
-
const lang = await this.getLSForPath(document.getFilePath() || '');
|
|
81
|
-
const tsDoc = await this.getSnapshot(document);
|
|
82
|
-
return { tsDoc, lang };
|
|
83
|
-
}
|
|
84
|
-
async getLSForPath(path) {
|
|
85
|
-
return (await this.getTypeScriptLanguageService(path)).getService();
|
|
86
|
-
}
|
|
87
|
-
async getTypeScriptLanguageService(filePath) {
|
|
88
|
-
return (0, language_service_1.getLanguageService)(filePath, this.workspaceUris, this.docContext);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* @internal Public for tests only
|
|
92
|
-
*/
|
|
93
|
-
async getSnapshotManager(filePath) {
|
|
94
|
-
return (await this.getTypeScriptLanguageService(filePath)).snapshotManager;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.LanguageServiceManager = LanguageServiceManager;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { TSXResult } from '@astrojs/compiler/types';
|
|
2
|
-
import { CancellationToken, CodeAction, CodeActionContext, CompletionContext, DefinitionLink, Diagnostic, FoldingRange, Hover, InlayHint, Location, Position, Range, ReferenceContext, SemanticTokens, SignatureHelp, SignatureHelpContext, SymbolInformation, TextDocumentContentChangeEvent, WorkspaceEdit } from 'vscode-languageserver';
|
|
3
|
-
import type { ConfigManager } from '../../core/config';
|
|
4
|
-
import type { AstroDocument } from '../../core/documents';
|
|
5
|
-
import type { AppCompletionItem, AppCompletionList, OnWatchFileChangesParam, Plugin } from '../interfaces';
|
|
6
|
-
import { CompletionItemData } from './features/CompletionsProvider';
|
|
7
|
-
import type { LanguageServiceManager } from './LanguageServiceManager';
|
|
8
|
-
export declare class TypeScriptPlugin implements Plugin {
|
|
9
|
-
__name: string;
|
|
10
|
-
private configManager;
|
|
11
|
-
private readonly languageServiceManager;
|
|
12
|
-
private readonly codeActionsProvider;
|
|
13
|
-
private readonly completionProvider;
|
|
14
|
-
private readonly hoverProvider;
|
|
15
|
-
private readonly fileReferencesProvider;
|
|
16
|
-
private readonly definitionsProvider;
|
|
17
|
-
private readonly typeDefinitionsProvider;
|
|
18
|
-
private readonly implementationsProvider;
|
|
19
|
-
private readonly referencesProvider;
|
|
20
|
-
private readonly signatureHelpProvider;
|
|
21
|
-
private readonly diagnosticsProvider;
|
|
22
|
-
private readonly documentSymbolsProvider;
|
|
23
|
-
private readonly inlayHintsProvider;
|
|
24
|
-
private readonly semanticTokensProvider;
|
|
25
|
-
private readonly foldingRangesProvider;
|
|
26
|
-
private readonly renameProvider;
|
|
27
|
-
private readonly ts;
|
|
28
|
-
constructor(configManager: ConfigManager, languageServiceManager: LanguageServiceManager);
|
|
29
|
-
doHover(document: AstroDocument, position: Position): Promise<Hover | null>;
|
|
30
|
-
prepareRename(document: AstroDocument, position: Position): Promise<Range | null>;
|
|
31
|
-
rename(document: AstroDocument, position: Position, newName: string): Promise<WorkspaceEdit | null>;
|
|
32
|
-
getFoldingRanges(document: AstroDocument): Promise<FoldingRange[] | null>;
|
|
33
|
-
getSemanticTokens(document: AstroDocument, range?: Range, cancellationToken?: CancellationToken): Promise<SemanticTokens | null>;
|
|
34
|
-
getDocumentSymbols(document: AstroDocument): Promise<SymbolInformation[]>;
|
|
35
|
-
getCodeActions(document: AstroDocument, range: Range, context: CodeActionContext, cancellationToken?: CancellationToken): Promise<CodeAction[]>;
|
|
36
|
-
getCompletions(document: AstroDocument, position: Position, completionContext?: CompletionContext, cancellationToken?: CancellationToken): Promise<AppCompletionList<CompletionItemData> | null>;
|
|
37
|
-
resolveCompletion(document: AstroDocument, completionItem: AppCompletionItem<CompletionItemData>, cancellationToken?: CancellationToken): Promise<AppCompletionItem<CompletionItemData>>;
|
|
38
|
-
getInlayHints(document: AstroDocument, range: Range): Promise<InlayHint[]>;
|
|
39
|
-
fileReferences(document: AstroDocument): Promise<Location[] | null>;
|
|
40
|
-
getDefinitions(document: AstroDocument, position: Position): Promise<DefinitionLink[]>;
|
|
41
|
-
getTypeDefinitions(document: AstroDocument, position: Position): Promise<Location[] | null>;
|
|
42
|
-
getImplementation(document: AstroDocument, position: Position): Promise<Location[] | null>;
|
|
43
|
-
findReferences(document: AstroDocument, position: Position, context: ReferenceContext): Promise<Location[] | null>;
|
|
44
|
-
getDiagnostics(document: AstroDocument, cancellationToken?: CancellationToken): Promise<Diagnostic[]>;
|
|
45
|
-
onWatchFileChanges(onWatchFileChangesParas: OnWatchFileChangesParam[]): Promise<void>;
|
|
46
|
-
updateNonAstroFile(fileName: string, changes: TextDocumentContentChangeEvent[], text?: string): Promise<void>;
|
|
47
|
-
getSignatureHelp(document: AstroDocument, position: Position, context: SignatureHelpContext | undefined, cancellationToken?: CancellationToken): Promise<SignatureHelp | null>;
|
|
48
|
-
getTSXForDocument(document: AstroDocument): TSXResult;
|
|
49
|
-
/**
|
|
50
|
-
* @internal Public for tests only
|
|
51
|
-
*/
|
|
52
|
-
getSnapshotManager(fileName: string): Promise<import("./snapshots/SnapshotManager").SnapshotManager>;
|
|
53
|
-
private featureEnabled;
|
|
54
|
-
}
|