@astrojs/language-server 0.8.2 → 0.8.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/CHANGELOG.md +25 -0
- package/astro.d.ts +5 -13
- package/dist/check.js +2 -1
- package/dist/core/config/ConfigManager.js +6 -4
- package/dist/core/documents/DocumentMapper.js +4 -2
- package/dist/core/documents/parseAstro.js +1 -1
- package/dist/core/documents/utils.js +4 -3
- package/dist/plugins/PluginHost.js +3 -2
- package/dist/plugins/astro/AstroPlugin.js +1 -1
- package/dist/plugins/astro/features/CompletionProvider.js +10 -9
- package/dist/plugins/css/CSSPlugin.js +2 -2
- package/dist/plugins/typescript/DocumentSnapshot.js +2 -1
- package/dist/plugins/typescript/LanguageServiceManager.js +1 -1
- package/dist/plugins/typescript/SnapshotManager.js +1 -1
- package/dist/plugins/typescript/TypeScriptPlugin.js +1 -1
- package/dist/plugins/typescript/astro-sys.js +1 -1
- package/dist/plugins/typescript/features/CompletionsProvider.js +2 -1
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +7 -6
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +2 -2
- package/dist/plugins/typescript/features/utils.js +2 -1
- package/dist/plugins/typescript/languageService.js +4 -14
- package/dist/plugins/typescript/previewer.js +1 -1
- package/dist/server.js +11 -9
- package/dist/utils.js +2 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @astrojs/language-server
|
|
2
2
|
|
|
3
|
+
## 0.8.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 97559b6: Removes errors with import.meta.hot
|
|
8
|
+
- 4c93d24: Prevent reading tsconfig in .astro files
|
|
9
|
+
|
|
10
|
+
## 0.8.5
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- f1f3091: Fix commenting, namespaced elements, and Fragment typings
|
|
15
|
+
|
|
16
|
+
## 0.8.4
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 481e009: Add Node v12 support, testing
|
|
21
|
+
|
|
22
|
+
## 0.8.3
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- fef3091: Updates `typescript` from 4.5.1-rc to 4.5.2 (stable)
|
|
27
|
+
|
|
3
28
|
## 0.8.2
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/astro.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
export {};
|
|
2
2
|
|
|
3
|
-
declare global {
|
|
4
|
-
interface ImportMeta {
|
|
5
|
-
hot: {
|
|
6
|
-
accept: Function;
|
|
7
|
-
dispose: Function;
|
|
8
|
-
};
|
|
9
|
-
env: Record<string, string>;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
3
|
type AstroRenderedHTML = string;
|
|
14
4
|
|
|
15
5
|
type AstroElement = any;
|
|
@@ -51,6 +41,8 @@ interface Astro {
|
|
|
51
41
|
slots: Record<string, true | undefined>;
|
|
52
42
|
}
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
declare
|
|
56
|
-
|
|
44
|
+
declare var Astro: Astro;
|
|
45
|
+
declare var Fragment: string;
|
|
46
|
+
|
|
47
|
+
void Astro;
|
|
48
|
+
void Fragment;
|
package/dist/check.js
CHANGED
|
@@ -40,10 +40,11 @@ class AstroCheck {
|
|
|
40
40
|
this.pluginHost.register(new plugins_1.TypeScriptPlugin(this.docManager, this.configManager, [workspacePath]));
|
|
41
41
|
}
|
|
42
42
|
async getDiagnosticsForFile(uri) {
|
|
43
|
+
var _a;
|
|
43
44
|
const diagnostics = await this.pluginHost.getDiagnostics({ uri });
|
|
44
45
|
return {
|
|
45
46
|
filePath: new URL(uri).pathname || '',
|
|
46
|
-
text: this.docManager.get(uri)
|
|
47
|
+
text: ((_a = this.docManager.get(uri)) === null || _a === void 0 ? void 0 : _a.getText()) || '',
|
|
47
48
|
diagnostics
|
|
48
49
|
};
|
|
49
50
|
}
|
|
@@ -76,13 +76,14 @@ class ConfigManager {
|
|
|
76
76
|
* Updates config.
|
|
77
77
|
*/
|
|
78
78
|
update(config) {
|
|
79
|
+
var _a;
|
|
79
80
|
// Ideally we shouldn't need the merge here because all updates should be valid and complete configs.
|
|
80
81
|
// But since those configs come from the client they might be out of synch with the valid config:
|
|
81
82
|
// We might at some point in the future forget to synch config settings in all packages after updating the config.
|
|
82
83
|
this.config = (0, lodash_1.merge)({}, defaultLSConfig, this.config, config);
|
|
83
84
|
// Merge will keep arrays/objects if the new one is empty/has less entries,
|
|
84
85
|
// therefore we need some extra checks if there are new settings
|
|
85
|
-
if (config.astro
|
|
86
|
+
if ((_a = config.astro) === null || _a === void 0 ? void 0 : _a.compilerWarnings) {
|
|
86
87
|
this.config.astro.compilerWarnings = config.astro.compilerWarnings;
|
|
87
88
|
}
|
|
88
89
|
this.listeners.forEach((listener) => listener(this));
|
|
@@ -118,11 +119,12 @@ class ConfigManager {
|
|
|
118
119
|
});
|
|
119
120
|
}
|
|
120
121
|
_updateTsUserPreferences(lang, config) {
|
|
122
|
+
var _a, _b, _c, _d;
|
|
121
123
|
this.tsUserPreferences[lang] = {
|
|
122
124
|
...this.tsUserPreferences[lang],
|
|
123
|
-
importModuleSpecifierPreference: config.preferences
|
|
124
|
-
quotePreference: config.preferences
|
|
125
|
-
includeAutomaticOptionalChainCompletions: config.suggest
|
|
125
|
+
importModuleSpecifierPreference: (_a = config.preferences) === null || _a === void 0 ? void 0 : _a.importModuleSpecifier,
|
|
126
|
+
quotePreference: (_b = config.preferences) === null || _b === void 0 ? void 0 : _b.quoteStyle,
|
|
127
|
+
includeAutomaticOptionalChainCompletions: (_d = (_c = config.suggest) === null || _c === void 0 ? void 0 : _c.includeAutomaticOptionalChainCompletions) !== null && _d !== void 0 ? _d : true,
|
|
126
128
|
includeCompletionsWithInsertText: true
|
|
127
129
|
};
|
|
128
130
|
}
|
|
@@ -33,7 +33,8 @@ class IdentityMapper {
|
|
|
33
33
|
return this.url;
|
|
34
34
|
}
|
|
35
35
|
destroy() {
|
|
36
|
-
|
|
36
|
+
var _a, _b;
|
|
37
|
+
(_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
exports.IdentityMapper = IdentityMapper;
|
|
@@ -129,7 +130,8 @@ class SourceMapDocumentMapper {
|
|
|
129
130
|
* Needs to be called when source mapper is no longer needed in order to prevent memory leaks.
|
|
130
131
|
*/
|
|
131
132
|
destroy() {
|
|
132
|
-
|
|
133
|
+
var _a, _b;
|
|
134
|
+
(_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
133
135
|
this.consumer.destroy();
|
|
134
136
|
}
|
|
135
137
|
}
|
|
@@ -55,7 +55,7 @@ function getContent(content, frontmatter) {
|
|
|
55
55
|
}
|
|
56
56
|
case 'closed': {
|
|
57
57
|
const { endOffset } = frontmatter;
|
|
58
|
-
const end = (endOffset
|
|
58
|
+
const end = (endOffset !== null && endOffset !== void 0 ? endOffset : 0) + 3;
|
|
59
59
|
const offset = (0, utils_1.getFirstNonWhitespaceIndex)(content.slice(end));
|
|
60
60
|
return { firstNonWhitespaceOffset: end + offset };
|
|
61
61
|
}
|
|
@@ -181,7 +181,7 @@ export function* walk(node: Node, startIndex = 0) {
|
|
|
181
181
|
* @param tag the tag to extract
|
|
182
182
|
*/
|
|
183
183
|
function extractTags(text, tag, html) {
|
|
184
|
-
const rootNodes = html
|
|
184
|
+
const rootNodes = (html === null || html === void 0 ? void 0 : html.roots) || (0, parseHtml_1.parseHtml)(text).roots;
|
|
185
185
|
const matchedNodes = rootNodes.filter((node) => node.tag === tag);
|
|
186
186
|
if (tag === 'style' && !matchedNodes.length && rootNodes.length && rootNodes[0].tag === 'html') {
|
|
187
187
|
for (let child of walk(rootNodes[0])) {
|
|
@@ -192,8 +192,9 @@ function extractTags(text, tag, html) {
|
|
|
192
192
|
}
|
|
193
193
|
return matchedNodes.map(transformToTagInfo);
|
|
194
194
|
function transformToTagInfo(matchedNode) {
|
|
195
|
-
|
|
196
|
-
const
|
|
195
|
+
var _a, _b;
|
|
196
|
+
const start = (_a = matchedNode.startTagEnd) !== null && _a !== void 0 ? _a : matchedNode.start;
|
|
197
|
+
const end = (_b = matchedNode.endTagStart) !== null && _b !== void 0 ? _b : matchedNode.end;
|
|
197
198
|
const startPos = positionAt(start, text);
|
|
198
199
|
const endPos = positionAt(end, text);
|
|
199
200
|
const container = {
|
|
@@ -47,7 +47,7 @@ class PluginHost {
|
|
|
47
47
|
throw new Error('Cannot call methods on an unopened document');
|
|
48
48
|
}
|
|
49
49
|
const result = await this.execute('resolveCompletion', [document, completionItem], ExecuteMode.FirstNonNull);
|
|
50
|
-
return result
|
|
50
|
+
return result !== null && result !== void 0 ? result : completionItem;
|
|
51
51
|
}
|
|
52
52
|
async doHover(textDocument, position) {
|
|
53
53
|
const document = this.getDocument(textDocument.uri);
|
|
@@ -99,8 +99,9 @@ class PluginHost {
|
|
|
99
99
|
return await this.execute('getSignatureHelp', [document, position, context, cancellationToken], ExecuteMode.FirstNonNull);
|
|
100
100
|
}
|
|
101
101
|
onWatchFileChanges(onWatchFileChangesParams) {
|
|
102
|
+
var _a;
|
|
102
103
|
for (const support of this.plugins) {
|
|
103
|
-
support.onWatchFileChanges
|
|
104
|
+
(_a = support.onWatchFileChanges) === null || _a === void 0 ? void 0 : _a.call(support, onWatchFileChangesParams);
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
getDocument(uri) {
|
|
@@ -95,7 +95,7 @@ class AstroPlugin {
|
|
|
95
95
|
const filePath = (0, utils_1.urlToPath)(document.uri);
|
|
96
96
|
const tsFilePath = (0, utils_2.toVirtualAstroFilePath)(filePath);
|
|
97
97
|
const program = lang.getProgram();
|
|
98
|
-
const sourceFile = program
|
|
98
|
+
const sourceFile = program === null || program === void 0 ? void 0 : program.getSourceFile(tsFilePath);
|
|
99
99
|
if (!sourceFile) {
|
|
100
100
|
return undefined;
|
|
101
101
|
}
|
|
@@ -35,12 +35,12 @@ class CompletionProvider {
|
|
|
35
35
|
if (!doc)
|
|
36
36
|
return null;
|
|
37
37
|
let items = [];
|
|
38
|
-
if (completionContext
|
|
38
|
+
if ((completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerCharacter) === '-') {
|
|
39
39
|
const frontmatter = this.getComponentScriptCompletion(doc, position, completionContext);
|
|
40
40
|
if (frontmatter)
|
|
41
41
|
items.push(frontmatter);
|
|
42
42
|
}
|
|
43
|
-
if (completionContext
|
|
43
|
+
if ((completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerCharacter) === ':') {
|
|
44
44
|
const clientHint = this.getClientHintCompletion(doc, position, completionContext);
|
|
45
45
|
if (clientHint)
|
|
46
46
|
items.push(...clientHint);
|
|
@@ -108,6 +108,7 @@ class CompletionProvider {
|
|
|
108
108
|
return null;
|
|
109
109
|
}
|
|
110
110
|
async getPropCompletions(document, position, completionContext) {
|
|
111
|
+
var _a, _b;
|
|
111
112
|
const offset = document.offsetAt(position);
|
|
112
113
|
const html = document.html;
|
|
113
114
|
const node = html.findNodeAt(offset);
|
|
@@ -118,7 +119,7 @@ class CompletionProvider {
|
|
|
118
119
|
if (!inAttribute) {
|
|
119
120
|
return [];
|
|
120
121
|
}
|
|
121
|
-
if (completionContext
|
|
122
|
+
if ((completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerCharacter) === '/' || (completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerCharacter) === '>') {
|
|
122
123
|
return [];
|
|
123
124
|
}
|
|
124
125
|
// If inside of attribute value, skip.
|
|
@@ -131,8 +132,8 @@ class CompletionProvider {
|
|
|
131
132
|
const filePath = (0, utils_2.urlToPath)(document.uri);
|
|
132
133
|
const tsFilePath = (0, utils_3.toVirtualAstroFilePath)(filePath);
|
|
133
134
|
const program = thisLang.getProgram();
|
|
134
|
-
const sourceFile = program
|
|
135
|
-
const typeChecker = program
|
|
135
|
+
const sourceFile = program === null || program === void 0 ? void 0 : program.getSourceFile(tsFilePath);
|
|
136
|
+
const typeChecker = program === null || program === void 0 ? void 0 : program.getTypeChecker();
|
|
136
137
|
if (!sourceFile || !typeChecker) {
|
|
137
138
|
return [];
|
|
138
139
|
}
|
|
@@ -150,14 +151,14 @@ class CompletionProvider {
|
|
|
150
151
|
const completionItems = [];
|
|
151
152
|
// Add completions for this types props
|
|
152
153
|
for (let baseType of componentType.getBaseTypes() || []) {
|
|
153
|
-
const members = baseType.getSymbol()
|
|
154
|
+
const members = ((_a = baseType.getSymbol()) === null || _a === void 0 ? void 0 : _a.members) || [];
|
|
154
155
|
members.forEach(mem => {
|
|
155
156
|
let completionItem = this.getCompletionItemForTypeMember(mem, typeChecker);
|
|
156
157
|
completionItems.push(completionItem);
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
160
|
// Add completions for this types base members
|
|
160
|
-
const members = componentType.getSymbol()
|
|
161
|
+
const members = ((_b = componentType.getSymbol()) === null || _b === void 0 ? void 0 : _b.members) || [];
|
|
161
162
|
members.forEach(mem => {
|
|
162
163
|
let completionItem = this.getCompletionItemForTypeMember(mem, typeChecker);
|
|
163
164
|
completionItems.push(completionItem);
|
|
@@ -190,11 +191,11 @@ class CompletionProvider {
|
|
|
190
191
|
return null;
|
|
191
192
|
}
|
|
192
193
|
getPropType(type, typeChecker) {
|
|
193
|
-
const sym = type
|
|
194
|
+
const sym = type === null || type === void 0 ? void 0 : type.getSymbol();
|
|
194
195
|
if (!sym) {
|
|
195
196
|
return null;
|
|
196
197
|
}
|
|
197
|
-
for (const decl of sym
|
|
198
|
+
for (const decl of (sym === null || sym === void 0 ? void 0 : sym.getDeclarations()) || []) {
|
|
198
199
|
const fileName = decl.getSourceFile().fileName;
|
|
199
200
|
if ((0, utils_3.isVirtualAstroFilePath)(fileName)) {
|
|
200
201
|
if (!ts.isFunctionDeclaration(decl)) {
|
|
@@ -22,8 +22,8 @@ class CSSPlugin {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
getCompletions(document, position, completionContext) {
|
|
25
|
-
const triggerCharacter = completionContext
|
|
26
|
-
const triggerKind = completionContext
|
|
25
|
+
const triggerCharacter = completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerCharacter;
|
|
26
|
+
const triggerKind = completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerKind;
|
|
27
27
|
const isCustomTriggerCharacter = triggerKind === vscode_languageserver_1.CompletionTriggerKind.TriggerCharacter;
|
|
28
28
|
if (isCustomTriggerCharacter && triggerCharacter && !this.triggerCharacters.has(triggerCharacter)) {
|
|
29
29
|
return null;
|
|
@@ -31,7 +31,8 @@ const utils_3 = require("./utils");
|
|
|
31
31
|
const os_1 = require("os");
|
|
32
32
|
const astro2tsx_1 = __importDefault(require("./astro2tsx"));
|
|
33
33
|
const createDocumentSnapshot = (filePath, currentText, createDocument) => {
|
|
34
|
-
|
|
34
|
+
var _a;
|
|
35
|
+
const text = currentText || ((_a = ts.sys.readFile(filePath)) !== null && _a !== void 0 ? _a : '');
|
|
35
36
|
if ((0, utils_3.isAstroFilePath)(filePath)) {
|
|
36
37
|
if (!createDocument)
|
|
37
38
|
throw new Error('Astro documents require the "createDocument" utility to be provided');
|
|
@@ -27,7 +27,7 @@ class LanguageServiceManager {
|
|
|
27
27
|
// This refreshes the document in the ts language service
|
|
28
28
|
this.getTypeScriptDoc(document);
|
|
29
29
|
};
|
|
30
|
-
docManager.on('documentChange', (0, utils_1.debounceSameArg)(handleDocumentChange, (newDoc, prevDoc) => newDoc.uri === prevDoc
|
|
30
|
+
docManager.on('documentChange', (0, utils_1.debounceSameArg)(handleDocumentChange, (newDoc, prevDoc) => newDoc.uri === (prevDoc === null || prevDoc === void 0 ? void 0 : prevDoc.uri), 1000));
|
|
31
31
|
docManager.on('documentOpen', handleDocumentChange);
|
|
32
32
|
}
|
|
33
33
|
getWorkspaceRoot(fileName) {
|
|
@@ -34,7 +34,7 @@ class SnapshotManager {
|
|
|
34
34
|
}
|
|
35
35
|
updateProjectFiles() {
|
|
36
36
|
const { include, exclude } = this.fileSpec;
|
|
37
|
-
if (include
|
|
37
|
+
if ((include === null || include === void 0 ? void 0 : include.length) === 0)
|
|
38
38
|
return;
|
|
39
39
|
const projectFiles = ts.sys.readDirectory(this.workspaceRoot, this.watchExtensions, exclude, include);
|
|
40
40
|
this.projectFiles = Array.from(new Set([...this.projectFiles, ...projectFiles]));
|
|
@@ -149,7 +149,7 @@ class TypeScriptPlugin {
|
|
|
149
149
|
}
|
|
150
150
|
getGoToDefinitionRefsForImportSpecifier(tsFilePath, offset, lang) {
|
|
151
151
|
const program = lang.getProgram();
|
|
152
|
-
const sourceFile = program
|
|
152
|
+
const sourceFile = program === null || program === void 0 ? void 0 : program.getSourceFile(tsFilePath);
|
|
153
153
|
if (sourceFile) {
|
|
154
154
|
let node = ts.getTouchingPropertyName(sourceFile, offset);
|
|
155
155
|
if (node && node.kind === typescript_1.SyntaxKind.Identifier) {
|
|
@@ -50,7 +50,7 @@ function createAstroSys(getSnapshot) {
|
|
|
50
50
|
return snapshot.getFullText();
|
|
51
51
|
},
|
|
52
52
|
readDirectory(path, extensions, exclude, include, depth) {
|
|
53
|
-
const extensionsWithAstro = (extensions
|
|
53
|
+
const extensionsWithAstro = (extensions !== null && extensions !== void 0 ? extensions : []).concat(...['.astro', '.svelte', '.vue']);
|
|
54
54
|
const result = ts.sys.readDirectory(path, extensionsWithAstro, exclude, include, depth);
|
|
55
55
|
return result;
|
|
56
56
|
},
|
|
@@ -34,6 +34,7 @@ class CompletionsProviderImpl {
|
|
|
34
34
|
this.lang = lang;
|
|
35
35
|
}
|
|
36
36
|
async getCompletions(document, position, _completionContext) {
|
|
37
|
+
var _a;
|
|
37
38
|
// TODO: handle inside expression
|
|
38
39
|
if (!(0, utils_1.isInsideFrontmatter)(document.getText(), document.offsetAt(position))) {
|
|
39
40
|
return null;
|
|
@@ -44,7 +45,7 @@ class CompletionsProviderImpl {
|
|
|
44
45
|
const { tsDoc, lang } = await this.lang.getTypeScriptDoc(document);
|
|
45
46
|
const fragment = await tsDoc.getFragment();
|
|
46
47
|
const offset = document.offsetAt(position);
|
|
47
|
-
const entries = lang.getCompletionsAtPosition(fragment.filePath, offset, completionOptions)
|
|
48
|
+
const entries = ((_a = lang.getCompletionsAtPosition(fragment.filePath, offset, completionOptions)) === null || _a === void 0 ? void 0 : _a.entries) || [];
|
|
48
49
|
const completionItems = entries
|
|
49
50
|
.map((entry) => this.toCompletionItem(fragment, entry, document.uri, position, new Set()))
|
|
50
51
|
.filter((i) => i);
|
|
@@ -14,11 +14,12 @@ class DiagnosticsProviderImpl {
|
|
|
14
14
|
this.languageServiceManager = languageServiceManager;
|
|
15
15
|
}
|
|
16
16
|
async getDiagnostics(document, _cancellationToken) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
if ((((_a = document.getFilePath()) === null || _a === void 0 ? void 0 : _a.includes('/node_modules/')) ||
|
|
19
|
+
((_b = document.getFilePath()) === null || _b === void 0 ? void 0 : _b.includes('\\node_modules\\'))) &&
|
|
19
20
|
// Sapper convention: Put stuff inside node_modules below src
|
|
20
|
-
!(document.getFilePath()
|
|
21
|
-
document.getFilePath()
|
|
21
|
+
!(((_c = document.getFilePath()) === null || _c === void 0 ? void 0 : _c.includes('/src/node_modules/')) ||
|
|
22
|
+
((_d = document.getFilePath()) === null || _d === void 0 ? void 0 : _d.includes('\\src\\node_modules\\')))) {
|
|
22
23
|
// Don't return diagnostics for files inside node_modules. These are considered read-only (cannot be changed)
|
|
23
24
|
// and in case of svelte-check they would pollute/skew the output
|
|
24
25
|
return [];
|
|
@@ -50,7 +51,7 @@ class DiagnosticsProviderImpl {
|
|
|
50
51
|
...semanticDiagnostics
|
|
51
52
|
];
|
|
52
53
|
const fragment = await tsDoc.getFragment();
|
|
53
|
-
const sourceFile = lang.getProgram()
|
|
54
|
+
const sourceFile = (_e = lang.getProgram()) === null || _e === void 0 ? void 0 : _e.getSourceFile(filePath);
|
|
54
55
|
const isNoFalsePositiveInst = isNoFalsePositive();
|
|
55
56
|
return diagnostics
|
|
56
57
|
.filter(isNotGenerated(tsDoc.getText(0, tsDoc.getLength())))
|
|
@@ -81,7 +82,7 @@ class DiagnosticsProviderImpl {
|
|
|
81
82
|
}
|
|
82
83
|
getTagBoundaries(lang, tsFilePath) {
|
|
83
84
|
const program = lang.getProgram();
|
|
84
|
-
const sourceFile = program
|
|
85
|
+
const sourceFile = program === null || program === void 0 ? void 0 : program.getSourceFile(tsFilePath);
|
|
85
86
|
const boundaries = {
|
|
86
87
|
script: [],
|
|
87
88
|
markdown: []
|
|
@@ -15,7 +15,7 @@ class SignatureHelpProviderImpl {
|
|
|
15
15
|
async getSignatureHelp(document, position, context, cancellationToken) {
|
|
16
16
|
const { lang, tsDoc } = await this.lang.getTypeScriptDoc(document);
|
|
17
17
|
const fragment = await tsDoc.getFragment();
|
|
18
|
-
if (cancellationToken
|
|
18
|
+
if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
const offset = fragment.offsetAt(fragment.getGeneratedPosition(position));
|
|
@@ -41,7 +41,7 @@ class SignatureHelpProviderImpl {
|
|
|
41
41
|
* adopted from https://github.com/microsoft/vscode/blob/265a2f6424dfbd3a9788652c7d376a7991d049a3/extensions/typescript-language-features/src/languageFeatures/signatureHelp.ts#L103
|
|
42
42
|
*/
|
|
43
43
|
toTsTriggerReason(context) {
|
|
44
|
-
switch (context
|
|
44
|
+
switch (context === null || context === void 0 ? void 0 : context.triggerKind) {
|
|
45
45
|
case vscode_languageserver_1.SignatureHelpTriggerKind.TriggerCharacter:
|
|
46
46
|
if (context.triggerCharacter) {
|
|
47
47
|
if (this.isReTrigger(context.isRetrigger, context.triggerCharacter)) {
|
|
@@ -33,7 +33,8 @@ class SnapshotFragmentMap {
|
|
|
33
33
|
return this.map.get(fileName);
|
|
34
34
|
}
|
|
35
35
|
getFragment(fileName) {
|
|
36
|
-
|
|
36
|
+
var _a;
|
|
37
|
+
return (_a = this.map.get(fileName)) === null || _a === void 0 ? void 0 : _a.fragment;
|
|
37
38
|
}
|
|
38
39
|
async retrieve(fileName) {
|
|
39
40
|
let snapshotFragment = this.get(fileName);
|
|
@@ -58,14 +58,7 @@ async function createLanguageService(tsconfigPath, workspaceRoot, docContext) {
|
|
|
58
58
|
return ts.sys.readDirectory(path, [...extensions, '.vue', '.svelte', '.astro', '.js', '.jsx'], exclude, include, depth);
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
|
-
|
|
62
|
-
if (!configJson.extends) {
|
|
63
|
-
configJson = Object.assign({
|
|
64
|
-
exclude: getDefaultExclude(),
|
|
65
|
-
}, configJson);
|
|
66
|
-
}
|
|
67
|
-
// Delete include so that astro files don't get excluded.
|
|
68
|
-
delete configJson.include;
|
|
61
|
+
const configJson = getDefaultJsConfig();
|
|
69
62
|
const existingCompilerOptions = {
|
|
70
63
|
jsx: ts.JsxEmit.Preserve,
|
|
71
64
|
module: ts.ModuleKind.ESNext,
|
|
@@ -129,7 +122,7 @@ async function createLanguageService(tsconfigPath, workspaceRoot, docContext) {
|
|
|
129
122
|
throw new Error(`Unable to find document`);
|
|
130
123
|
}
|
|
131
124
|
const previousSnapshot = snapshotManager.get(filePath);
|
|
132
|
-
if (document && previousSnapshot
|
|
125
|
+
if (document && (previousSnapshot === null || previousSnapshot === void 0 ? void 0 : previousSnapshot.version.toString()) === `${document.version}`) {
|
|
133
126
|
return previousSnapshot;
|
|
134
127
|
}
|
|
135
128
|
const currentText = document ? document.getText() : null;
|
|
@@ -149,18 +142,15 @@ async function createLanguageService(tsconfigPath, workspaceRoot, docContext) {
|
|
|
149
142
|
return doc;
|
|
150
143
|
}
|
|
151
144
|
}
|
|
152
|
-
/**
|
|
153
|
-
* This should only be used when there's no jsconfig/tsconfig at all
|
|
154
|
-
*/
|
|
155
145
|
function getDefaultJsConfig() {
|
|
156
146
|
let compilerOptions = {
|
|
157
147
|
maxNodeModuleJsDepth: 2,
|
|
158
148
|
allowSyntheticDefaultImports: true,
|
|
159
|
-
allowJs: true
|
|
149
|
+
allowJs: true,
|
|
160
150
|
};
|
|
161
151
|
return {
|
|
162
152
|
compilerOptions,
|
|
163
|
-
|
|
153
|
+
exclude: getDefaultExclude(),
|
|
164
154
|
};
|
|
165
155
|
}
|
|
166
156
|
function getDefaultExclude() {
|
|
@@ -72,7 +72,7 @@ function getTagBodyText(tag) {
|
|
|
72
72
|
function getTagDocumentation(tag) {
|
|
73
73
|
function getWithType() {
|
|
74
74
|
const body = (typescript_1.default.displayPartsToString(tag.text) || '').split(/^(\S+)\s*-?\s*/);
|
|
75
|
-
if (body
|
|
75
|
+
if ((body === null || body === void 0 ? void 0 : body.length) === 3) {
|
|
76
76
|
const param = body[1];
|
|
77
77
|
const doc = body[2];
|
|
78
78
|
const label = `*@${tag.name}* \`${param}\``;
|
package/dist/server.js
CHANGED
|
@@ -17,22 +17,23 @@ function startServer() {
|
|
|
17
17
|
const configManager = new config_1.ConfigManager();
|
|
18
18
|
const pluginHost = new plugins_1.PluginHost(docManager);
|
|
19
19
|
connection.onInitialize((evt) => {
|
|
20
|
-
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
21
|
+
const workspaceUris = (_b = (_a = evt.workspaceFolders) === null || _a === void 0 ? void 0 : _a.map((folder) => folder.uri.toString())) !== null && _b !== void 0 ? _b : [(_c = evt.rootUri) !== null && _c !== void 0 ? _c : ''];
|
|
21
22
|
pluginHost.initialize({
|
|
22
|
-
filterIncompleteCompletions: !evt.initializationOptions
|
|
23
|
-
definitionLinkSupport: !!evt.capabilities.textDocument
|
|
23
|
+
filterIncompleteCompletions: !((_d = evt.initializationOptions) === null || _d === void 0 ? void 0 : _d.dontFilterIncompleteCompletions),
|
|
24
|
+
definitionLinkSupport: !!((_f = (_e = evt.capabilities.textDocument) === null || _e === void 0 ? void 0 : _e.definition) === null || _f === void 0 ? void 0 : _f.linkSupport),
|
|
24
25
|
});
|
|
25
26
|
pluginHost.register(new plugins_1.HTMLPlugin(docManager, configManager));
|
|
26
27
|
pluginHost.register(new plugins_1.CSSPlugin(docManager, configManager));
|
|
27
28
|
pluginHost.register(new plugins_1.TypeScriptPlugin(docManager, configManager, workspaceUris));
|
|
28
29
|
pluginHost.register(new plugins_1.AstroPlugin(docManager, configManager, workspaceUris));
|
|
29
|
-
configManager.update(evt.initializationOptions
|
|
30
|
-
evt.initializationOptions
|
|
30
|
+
configManager.update(((_j = (_h = (_g = evt.initializationOptions) === null || _g === void 0 ? void 0 : _g.configuration) === null || _h === void 0 ? void 0 : _h.astro) === null || _j === void 0 ? void 0 : _j.plugin) ||
|
|
31
|
+
((_k = evt.initializationOptions) === null || _k === void 0 ? void 0 : _k.config) ||
|
|
31
32
|
{});
|
|
32
|
-
configManager.updateTsJsUserPreferences(evt.initializationOptions
|
|
33
|
-
evt.initializationOptions
|
|
33
|
+
configManager.updateTsJsUserPreferences(((_l = evt.initializationOptions) === null || _l === void 0 ? void 0 : _l.configuration) ||
|
|
34
|
+
((_m = evt.initializationOptions) === null || _m === void 0 ? void 0 : _m.typescriptConfig) ||
|
|
34
35
|
{});
|
|
35
|
-
configManager.updateEmmetConfig(evt.initializationOptions
|
|
36
|
+
configManager.updateEmmetConfig(((_p = (_o = evt.initializationOptions) === null || _o === void 0 ? void 0 : _o.configuration) === null || _p === void 0 ? void 0 : _p.emmet) || ((_q = evt.initializationOptions) === null || _q === void 0 ? void 0 : _q.emmetConfig) || {});
|
|
36
37
|
return {
|
|
37
38
|
capabilities: {
|
|
38
39
|
textDocumentSync: vscode_languageserver_1.TextDocumentSyncKind.Incremental,
|
|
@@ -100,7 +101,8 @@ function startServer() {
|
|
|
100
101
|
//connection.onDidChangeTextDocument(updateAllDiagnostics);
|
|
101
102
|
// Config
|
|
102
103
|
connection.onDidChangeConfiguration(({ settings }) => {
|
|
103
|
-
|
|
104
|
+
var _a;
|
|
105
|
+
configManager.update((_a = settings.astro) === null || _a === void 0 ? void 0 : _a.plugin);
|
|
104
106
|
configManager.updateEmmetConfig(settings.emmet);
|
|
105
107
|
configManager.updateTsJsUserPreferences(settings);
|
|
106
108
|
});
|
package/dist/utils.js
CHANGED
|
@@ -28,7 +28,8 @@ exports.pathToUrl = pathToUrl;
|
|
|
28
28
|
* the same name like a html tag.
|
|
29
29
|
*/
|
|
30
30
|
function isPossibleComponent(node) {
|
|
31
|
-
|
|
31
|
+
var _a;
|
|
32
|
+
return !!((_a = node.tag) === null || _a === void 0 ? void 0 : _a[0].match(/[A-Z]/));
|
|
32
33
|
}
|
|
33
34
|
exports.isPossibleComponent = isPossibleComponent;
|
|
34
35
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"author": "Skypack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lodash": "^4.17.21",
|
|
24
24
|
"source-map": "^0.7.3",
|
|
25
25
|
"ts-morph": "^12.0.0",
|
|
26
|
-
"typescript": "^4.5.
|
|
26
|
+
"typescript": "^4.5.2",
|
|
27
27
|
"vscode-css-languageservice": "^5.1.1",
|
|
28
28
|
"vscode-emmet-helper": "2.1.2",
|
|
29
29
|
"vscode-html-languageservice": "^3.0.3",
|