@astrojs/language-server 0.7.19 → 0.8.4
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 +24 -0
- package/dist/check.js +2 -1
- package/dist/core/config/ConfigManager.js +8 -6
- package/dist/core/documents/Document.js +6 -6
- package/dist/core/documents/DocumentBase.js +2 -2
- package/dist/core/documents/DocumentManager.js +6 -6
- package/dist/core/documents/DocumentMapper.js +9 -7
- package/dist/core/documents/parseAstro.js +3 -3
- package/dist/core/documents/parseHtml.js +2 -2
- package/dist/core/documents/utils.js +7 -6
- package/dist/plugins/PluginHost.js +7 -6
- package/dist/plugins/astro/AstroPlugin.js +6 -6
- package/dist/plugins/astro/features/CompletionProvider.js +15 -14
- package/dist/plugins/css/CSSDocument.js +1 -1
- package/dist/plugins/css/CSSPlugin.js +9 -9
- package/dist/plugins/css/StyleAttributeDocument.js +1 -1
- package/dist/plugins/html/HTMLPlugin.js +4 -4
- package/dist/plugins/typescript/DocumentSnapshot.js +17 -16
- package/dist/plugins/typescript/LanguageServiceManager.js +7 -7
- package/dist/plugins/typescript/SnapshotManager.js +3 -3
- package/dist/plugins/typescript/TypeScriptPlugin.js +11 -11
- package/dist/plugins/typescript/astro-sys.js +5 -5
- package/dist/plugins/typescript/astro2tsx.js +1 -1
- package/dist/plugins/typescript/features/CompletionsProvider.js +6 -5
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +12 -11
- package/dist/plugins/typescript/features/HoverProvider.js +4 -4
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +4 -4
- package/dist/plugins/typescript/features/utils.js +2 -1
- package/dist/plugins/typescript/languageService.js +8 -8
- package/dist/plugins/typescript/module-loader.js +6 -6
- package/dist/plugins/typescript/previewer.js +1 -1
- package/dist/plugins/typescript/utils.js +3 -3
- package/dist/server.js +15 -13
- package/dist/utils.js +2 -1
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @astrojs/language-server
|
|
2
2
|
|
|
3
|
+
## 0.8.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 481e009: Add Node v12 support, testing
|
|
8
|
+
|
|
9
|
+
## 0.8.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fef3091: Updates `typescript` from 4.5.1-rc to 4.5.2 (stable)
|
|
14
|
+
|
|
15
|
+
## 0.8.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 528c6bd: Adds missing dependencies
|
|
20
|
+
|
|
21
|
+
## 0.8.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- b20db6e: Bump TypeScript from 4.3.1-rc to 4.5.1-rc
|
|
26
|
+
|
|
3
27
|
## 0.7.19
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
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
|
-
this.config = lodash_1.merge({}, defaultLSConfig, this.config, config);
|
|
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));
|
|
@@ -99,7 +100,7 @@ class ConfigManager {
|
|
|
99
100
|
* @param key a string which is a path. Example: 'astro.diagnostics.enable'.
|
|
100
101
|
*/
|
|
101
102
|
get(key) {
|
|
102
|
-
return lodash_1.get(this.config, key);
|
|
103
|
+
return (0, lodash_1.get)(this.config, key);
|
|
103
104
|
}
|
|
104
105
|
/**
|
|
105
106
|
* Register a listener which is invoked when the config changed.
|
|
@@ -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
|
}
|
|
@@ -16,9 +16,9 @@ class Document {
|
|
|
16
16
|
this.updateDocInfo();
|
|
17
17
|
}
|
|
18
18
|
updateDocInfo() {
|
|
19
|
-
this.html = parseHtml_1.parseHtml(this.content);
|
|
20
|
-
this.astro = parseAstro_1.parseAstro(this.content);
|
|
21
|
-
this.styleInfo = utils_2.extractStyleTag(this.content, this.html);
|
|
19
|
+
this.html = (0, parseHtml_1.parseHtml)(this.content);
|
|
20
|
+
this.astro = (0, parseAstro_1.parseAstro)(this.content);
|
|
21
|
+
this.styleInfo = (0, utils_2.extractStyleTag)(this.content, this.html);
|
|
22
22
|
if (this.styleInfo) {
|
|
23
23
|
this.styleInfo.attributes.lang = 'css';
|
|
24
24
|
}
|
|
@@ -46,7 +46,7 @@ class Document {
|
|
|
46
46
|
* @param offset The index of the position
|
|
47
47
|
*/
|
|
48
48
|
positionAt(offset) {
|
|
49
|
-
offset = utils_1.clamp(offset, 0, this.getTextLength());
|
|
49
|
+
offset = (0, utils_1.clamp)(offset, 0, this.getTextLength());
|
|
50
50
|
const lineOffsets = this.getLineOffsets();
|
|
51
51
|
let low = 0;
|
|
52
52
|
let high = lineOffsets.length;
|
|
@@ -81,7 +81,7 @@ class Document {
|
|
|
81
81
|
}
|
|
82
82
|
const lineOffset = lineOffsets[position.line];
|
|
83
83
|
const nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this.getTextLength();
|
|
84
|
-
return utils_1.clamp(nextLineOffset, lineOffset, lineOffset + position.character);
|
|
84
|
+
return (0, utils_1.clamp)(nextLineOffset, lineOffset, lineOffset + position.character);
|
|
85
85
|
}
|
|
86
86
|
getLineUntilOffset(offset) {
|
|
87
87
|
const { line, character } = this.positionAt(offset);
|
|
@@ -117,7 +117,7 @@ class Document {
|
|
|
117
117
|
* Returns the file path if the url scheme is file
|
|
118
118
|
*/
|
|
119
119
|
getFilePath() {
|
|
120
|
-
return utils_1.urlToPath(this.uri);
|
|
120
|
+
return (0, utils_1.urlToPath)(this.uri);
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
123
|
* Get URL file path.
|
|
@@ -24,7 +24,7 @@ class ReadableDocument {
|
|
|
24
24
|
* @param offset The index of the position
|
|
25
25
|
*/
|
|
26
26
|
positionAt(offset) {
|
|
27
|
-
offset = utils_1.clamp(offset, 0, this.getTextLength());
|
|
27
|
+
offset = (0, utils_1.clamp)(offset, 0, this.getTextLength());
|
|
28
28
|
const lineOffsets = this.getLineOffsets();
|
|
29
29
|
let low = 0;
|
|
30
30
|
let high = lineOffsets.length;
|
|
@@ -59,7 +59,7 @@ class ReadableDocument {
|
|
|
59
59
|
}
|
|
60
60
|
const lineOffset = lineOffsets[position.line];
|
|
61
61
|
const nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this.getTextLength();
|
|
62
|
-
return utils_1.clamp(nextLineOffset, lineOffset, lineOffset + position.character);
|
|
62
|
+
return (0, utils_1.clamp)(nextLineOffset, lineOffset, lineOffset + position.character);
|
|
63
63
|
}
|
|
64
64
|
getLineOffsets() {
|
|
65
65
|
const lineOffsets = [];
|
|
@@ -14,7 +14,7 @@ class DocumentManager {
|
|
|
14
14
|
this.deleteCandidates = new Set();
|
|
15
15
|
}
|
|
16
16
|
get(uri) {
|
|
17
|
-
return this.documents.get(utils_1.normalizeUri(uri));
|
|
17
|
+
return this.documents.get((0, utils_1.normalizeUri)(uri));
|
|
18
18
|
}
|
|
19
19
|
openDocument(textDocument) {
|
|
20
20
|
let document;
|
|
@@ -25,14 +25,14 @@ class DocumentManager {
|
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
document = this.createDocument(textDocument);
|
|
28
|
-
this.documents.set(utils_1.normalizeUri(textDocument.uri), document);
|
|
28
|
+
this.documents.set((0, utils_1.normalizeUri)(textDocument.uri), document);
|
|
29
29
|
this.notify('documentOpen', document);
|
|
30
30
|
}
|
|
31
31
|
this.notify('documentChange', document);
|
|
32
32
|
return document;
|
|
33
33
|
}
|
|
34
34
|
closeDocument(uri) {
|
|
35
|
-
uri = utils_1.normalizeUri(uri);
|
|
35
|
+
uri = (0, utils_1.normalizeUri)(uri);
|
|
36
36
|
const document = this.documents.get(uri);
|
|
37
37
|
if (!document) {
|
|
38
38
|
throw new Error('Cannot call methods on an unopened document');
|
|
@@ -48,7 +48,7 @@ class DocumentManager {
|
|
|
48
48
|
this.openedInClient.delete(uri);
|
|
49
49
|
}
|
|
50
50
|
releaseDocument(uri) {
|
|
51
|
-
uri = utils_1.normalizeUri(uri);
|
|
51
|
+
uri = (0, utils_1.normalizeUri)(uri);
|
|
52
52
|
this.locked.delete(uri);
|
|
53
53
|
this.openedInClient.delete(uri);
|
|
54
54
|
if (this.deleteCandidates.has(uri)) {
|
|
@@ -57,7 +57,7 @@ class DocumentManager {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
updateDocument(uri, changes) {
|
|
60
|
-
const document = this.documents.get(utils_1.normalizeUri(uri));
|
|
60
|
+
const document = this.documents.get((0, utils_1.normalizeUri)(uri));
|
|
61
61
|
if (!document) {
|
|
62
62
|
throw new Error('Cannot call methods on an unopened document');
|
|
63
63
|
}
|
|
@@ -76,7 +76,7 @@ class DocumentManager {
|
|
|
76
76
|
this.notify('documentChange', document);
|
|
77
77
|
}
|
|
78
78
|
markAsOpenedInClient(uri) {
|
|
79
|
-
this.openedInClient.add(utils_1.normalizeUri(uri));
|
|
79
|
+
this.openedInClient.add((0, utils_1.normalizeUri)(uri));
|
|
80
80
|
}
|
|
81
81
|
getAllOpenedByClient() {
|
|
82
82
|
return Array.from(this.documents.entries()).filter((doc) => this.openedInClient.has(doc[0]));
|
|
@@ -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;
|
|
@@ -47,18 +48,18 @@ class FragmentMapper {
|
|
|
47
48
|
this.url = url;
|
|
48
49
|
}
|
|
49
50
|
getOriginalPosition(generatedPosition) {
|
|
50
|
-
const parentOffset = this.offsetInParent(utils_1.offsetAt(generatedPosition, this.tagInfo.content));
|
|
51
|
-
return utils_1.positionAt(parentOffset, this.originalText);
|
|
51
|
+
const parentOffset = this.offsetInParent((0, utils_1.offsetAt)(generatedPosition, this.tagInfo.content));
|
|
52
|
+
return (0, utils_1.positionAt)(parentOffset, this.originalText);
|
|
52
53
|
}
|
|
53
54
|
offsetInParent(offset) {
|
|
54
55
|
return this.tagInfo.start + offset;
|
|
55
56
|
}
|
|
56
57
|
getGeneratedPosition(originalPosition) {
|
|
57
|
-
const fragmentOffset = utils_1.offsetAt(originalPosition, this.originalText) - this.tagInfo.start;
|
|
58
|
-
return utils_1.positionAt(fragmentOffset, this.tagInfo.content);
|
|
58
|
+
const fragmentOffset = (0, utils_1.offsetAt)(originalPosition, this.originalText) - this.tagInfo.start;
|
|
59
|
+
return (0, utils_1.positionAt)(fragmentOffset, this.tagInfo.content);
|
|
59
60
|
}
|
|
60
61
|
isInGenerated(pos) {
|
|
61
|
-
const offset = utils_1.offsetAt(pos, this.originalText);
|
|
62
|
+
const offset = (0, utils_1.offsetAt)(pos, this.originalText);
|
|
62
63
|
return offset >= this.tagInfo.start && offset <= this.tagInfo.end;
|
|
63
64
|
}
|
|
64
65
|
getURL() {
|
|
@@ -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
|
}
|
|
@@ -47,7 +47,7 @@ function getFrontmatter(content) {
|
|
|
47
47
|
function getContent(content, frontmatter) {
|
|
48
48
|
switch (frontmatter.state) {
|
|
49
49
|
case null: {
|
|
50
|
-
const offset = utils_1.getFirstNonWhitespaceIndex(content);
|
|
50
|
+
const offset = (0, utils_1.getFirstNonWhitespaceIndex)(content);
|
|
51
51
|
return { firstNonWhitespaceOffset: offset === -1 ? null : offset };
|
|
52
52
|
}
|
|
53
53
|
case 'open': {
|
|
@@ -55,8 +55,8 @@ function getContent(content, frontmatter) {
|
|
|
55
55
|
}
|
|
56
56
|
case 'closed': {
|
|
57
57
|
const { endOffset } = frontmatter;
|
|
58
|
-
const end = (endOffset
|
|
59
|
-
const offset = utils_1.getFirstNonWhitespaceIndex(content.slice(end));
|
|
58
|
+
const end = (endOffset !== null && endOffset !== void 0 ? endOffset : 0) + 3;
|
|
59
|
+
const offset = (0, utils_1.getFirstNonWhitespaceIndex)(content.slice(end));
|
|
60
60
|
return { firstNonWhitespaceOffset: end + offset };
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getAttributeContextAtPosition = exports.parseHtml = void 0;
|
|
4
4
|
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
-
const parser = vscode_html_languageservice_1.getLanguageService();
|
|
6
|
+
const parser = (0, vscode_html_languageservice_1.getLanguageService)();
|
|
7
7
|
/**
|
|
8
8
|
* Parses text as HTML
|
|
9
9
|
*/
|
|
@@ -48,7 +48,7 @@ function preprocess(text) {
|
|
|
48
48
|
return text;
|
|
49
49
|
function shouldBlankStartOrEndTagLike(offset) {
|
|
50
50
|
// not null rather than falsy, otherwise it won't work on first tag(0)
|
|
51
|
-
return currentStartTagStart !== null && utils_1.isInsideExpression(text, currentStartTagStart, offset);
|
|
51
|
+
return currentStartTagStart !== null && (0, utils_1.isInsideExpression)(text, currentStartTagStart, offset);
|
|
52
52
|
}
|
|
53
53
|
function blankStartOrEndTagLike(offset) {
|
|
54
54
|
text = text.substring(0, offset) + ' ' + text.substring(offset + 1);
|
|
@@ -73,7 +73,7 @@ function isInsideFrontmatter(text, offset) {
|
|
|
73
73
|
}
|
|
74
74
|
exports.isInsideFrontmatter = isInsideFrontmatter;
|
|
75
75
|
function isInTag(position, tagInfo) {
|
|
76
|
-
return !!tagInfo && utils_1.isInRange(position, vscode_languageserver_1.Range.create(tagInfo.startPos, tagInfo.endPos));
|
|
76
|
+
return !!tagInfo && (0, utils_1.isInRange)(position, vscode_languageserver_1.Range.create(tagInfo.startPos, tagInfo.endPos));
|
|
77
77
|
}
|
|
78
78
|
exports.isInTag = isInTag;
|
|
79
79
|
/**
|
|
@@ -82,7 +82,7 @@ exports.isInTag = isInTag;
|
|
|
82
82
|
* @param text The text for which the position should be retrived
|
|
83
83
|
*/
|
|
84
84
|
function positionAt(offset, text) {
|
|
85
|
-
offset = utils_1.clamp(offset, 0, text.length);
|
|
85
|
+
offset = (0, utils_1.clamp)(offset, 0, text.length);
|
|
86
86
|
const lineOffsets = getLineOffsets(text);
|
|
87
87
|
let low = 0;
|
|
88
88
|
let high = lineOffsets.length;
|
|
@@ -119,7 +119,7 @@ function offsetAt(position, text) {
|
|
|
119
119
|
}
|
|
120
120
|
const lineOffset = lineOffsets[position.line];
|
|
121
121
|
const nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : text.length;
|
|
122
|
-
return utils_1.clamp(nextLineOffset, lineOffset, lineOffset + position.character);
|
|
122
|
+
return (0, utils_1.clamp)(nextLineOffset, lineOffset, lineOffset + position.character);
|
|
123
123
|
}
|
|
124
124
|
exports.offsetAt = offsetAt;
|
|
125
125
|
function getLineOffsets(text) {
|
|
@@ -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 = {
|
|
@@ -30,7 +30,7 @@ class PluginHost {
|
|
|
30
30
|
throw new Error('Cannot call methods on an unopened document');
|
|
31
31
|
}
|
|
32
32
|
const completions = (await this.execute('getCompletions', [document, position, completionContext], ExecuteMode.Collect)).filter((completion) => completion != null);
|
|
33
|
-
let flattenedCompletions = utils_1.flatten(completions.map((completion) => completion.items));
|
|
33
|
+
let flattenedCompletions = (0, utils_1.flatten)(completions.map((completion) => completion.items));
|
|
34
34
|
const isIncomplete = completions.reduce((incomplete, completion) => incomplete || completion.isIncomplete, false);
|
|
35
35
|
return vscode_languageserver_1.CompletionList.create(flattenedCompletions, isIncomplete);
|
|
36
36
|
}
|
|
@@ -39,7 +39,7 @@ class PluginHost {
|
|
|
39
39
|
if (!document) {
|
|
40
40
|
throw new Error('Cannot call methods on an unopened document');
|
|
41
41
|
}
|
|
42
|
-
return utils_1.flatten(await this.execute('getDiagnostics', [document], ExecuteMode.Collect));
|
|
42
|
+
return (0, utils_1.flatten)(await this.execute('getDiagnostics', [document], ExecuteMode.Collect));
|
|
43
43
|
}
|
|
44
44
|
async resolveCompletion(textDocument, completionItem) {
|
|
45
45
|
const document = this.getDocument(textDocument.uri);
|
|
@@ -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);
|
|
@@ -68,7 +68,7 @@ class PluginHost {
|
|
|
68
68
|
if (!document) {
|
|
69
69
|
throw new Error('Cannot call methods on an unopened document');
|
|
70
70
|
}
|
|
71
|
-
const foldingRanges = utils_1.flatten(await this.execute('getFoldingRanges', [document], ExecuteMode.Collect)).filter((completion) => completion != null);
|
|
71
|
+
const foldingRanges = (0, utils_1.flatten)(await this.execute('getFoldingRanges', [document], ExecuteMode.Collect)).filter((completion) => completion != null);
|
|
72
72
|
return foldingRanges;
|
|
73
73
|
}
|
|
74
74
|
async getDefinitions(textDocument, position) {
|
|
@@ -76,7 +76,7 @@ class PluginHost {
|
|
|
76
76
|
if (!document) {
|
|
77
77
|
throw new Error('Cannot call methods on an unopened document');
|
|
78
78
|
}
|
|
79
|
-
const definitions = utils_1.flatten(await this.execute('getDefinitions', [document, position], ExecuteMode.Collect));
|
|
79
|
+
const definitions = (0, utils_1.flatten)(await this.execute('getDefinitions', [document, position], ExecuteMode.Collect));
|
|
80
80
|
if (this.pluginHostConfig.definitionLinkSupport) {
|
|
81
81
|
return definitions;
|
|
82
82
|
}
|
|
@@ -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) {
|
|
@@ -76,13 +76,13 @@ class AstroPlugin {
|
|
|
76
76
|
}
|
|
77
77
|
const startRange = vscode_languageserver_1.Range.create(vscode_languageserver_1.Position.create(0, 0), vscode_languageserver_1.Position.create(0, 0));
|
|
78
78
|
const links = defs.map((def) => {
|
|
79
|
-
const defFilePath = utils_4.ensureRealFilePath(def.fileName);
|
|
80
|
-
return vscode_languageserver_1.LocationLink.create(utils_1.pathToUrl(defFilePath), startRange, startRange);
|
|
79
|
+
const defFilePath = (0, utils_4.ensureRealFilePath)(def.fileName);
|
|
80
|
+
return vscode_languageserver_1.LocationLink.create((0, utils_1.pathToUrl)(defFilePath), startRange, startRange);
|
|
81
81
|
});
|
|
82
82
|
return links;
|
|
83
83
|
}
|
|
84
84
|
isInsideFrontmatter(document, position) {
|
|
85
|
-
return utils_3.isInsideFrontmatter(document.getText(), document.offsetAt(position));
|
|
85
|
+
return (0, utils_3.isInsideFrontmatter)(document.getText(), document.offsetAt(position));
|
|
86
86
|
}
|
|
87
87
|
isComponentTag(node) {
|
|
88
88
|
if (!node.tag) {
|
|
@@ -92,10 +92,10 @@ class AstroPlugin {
|
|
|
92
92
|
return /[A-Z]/.test(firstChar);
|
|
93
93
|
}
|
|
94
94
|
getDefinitionsForComponentName(document, lang, componentName) {
|
|
95
|
-
const filePath = utils_1.urlToPath(document.uri);
|
|
96
|
-
const tsFilePath = utils_2.toVirtualAstroFilePath(filePath);
|
|
95
|
+
const filePath = (0, utils_1.urlToPath)(document.uri);
|
|
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);
|
|
@@ -55,7 +55,7 @@ class CompletionProvider {
|
|
|
55
55
|
}
|
|
56
56
|
getClientHintCompletion(document, position, completionContext) {
|
|
57
57
|
const node = document.html.findNodeAt(document.offsetAt(position));
|
|
58
|
-
if (!utils_2.isPossibleClientComponent(node))
|
|
58
|
+
if (!(0, utils_2.isPossibleClientComponent)(node))
|
|
59
59
|
return null;
|
|
60
60
|
return [
|
|
61
61
|
{
|
|
@@ -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.
|
|
@@ -128,11 +129,11 @@ class CompletionProvider {
|
|
|
128
129
|
const componentName = node.tag;
|
|
129
130
|
const { lang: thisLang } = await this.tsLanguageServiceManager.getTypeScriptDoc(document);
|
|
130
131
|
// Get the source file
|
|
131
|
-
const filePath = utils_2.urlToPath(document.uri);
|
|
132
|
-
const tsFilePath = utils_3.toVirtualAstroFilePath(filePath);
|
|
132
|
+
const filePath = (0, utils_2.urlToPath)(document.uri);
|
|
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,13 +191,13 @@ 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
|
-
if (utils_3.isVirtualAstroFilePath(fileName)) {
|
|
200
|
+
if ((0, utils_3.isVirtualAstroFilePath)(fileName)) {
|
|
200
201
|
if (!ts.isFunctionDeclaration(decl)) {
|
|
201
202
|
console.error(`Unexpected: .astro files should export a default function for the component definition.`);
|
|
202
203
|
continue;
|
|
@@ -251,7 +252,7 @@ class CompletionProvider {
|
|
|
251
252
|
return /[A-Z]/.test(firstChar);
|
|
252
253
|
}
|
|
253
254
|
isInsideFrontmatter(document, position) {
|
|
254
|
-
return utils_1.isInsideFrontmatter(document.getText(), document.offsetAt(position));
|
|
255
|
+
return (0, utils_1.isInsideFrontmatter)(document.getText(), document.offsetAt(position));
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
258
|
exports.CompletionProvider = CompletionProvider;
|
|
@@ -19,7 +19,7 @@ class CSSDocument extends index_1.ReadableDocument {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
this.languageId = this.language;
|
|
22
|
-
this.stylesheet = service_1.getLanguageService(this.language).parseStylesheet(this);
|
|
22
|
+
this.stylesheet = (0, service_1.getLanguageService)(this.language).parseStylesheet(this);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Get the fragment position relative to the parent
|
|
@@ -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;
|
|
@@ -35,7 +35,7 @@ class CSSPlugin {
|
|
|
35
35
|
if (cssDocument.isInGenerated(position)) {
|
|
36
36
|
return this.getCompletionsInternal(document, position, cssDocument);
|
|
37
37
|
}
|
|
38
|
-
const attributeContext = parseHtml_1.getAttributeContextAtPosition(document, position);
|
|
38
|
+
const attributeContext = (0, parseHtml_1.getAttributeContextAtPosition)(document, position);
|
|
39
39
|
if (!attributeContext) {
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
@@ -44,28 +44,28 @@ class CSSPlugin {
|
|
|
44
44
|
return this.getCompletionsInternal(document, position, new StyleAttributeDocument_1.StyleAttributeDocument(document, start, end));
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
return getIdClassCompletion_1.getIdClassCompletion(cssDocument, attributeContext);
|
|
47
|
+
return (0, getIdClassCompletion_1.getIdClassCompletion)(cssDocument, attributeContext);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
getCompletionsInternal(document, position, cssDocument) {
|
|
51
51
|
if (isSASS(cssDocument)) {
|
|
52
52
|
// the css language service does not support sass, still we can use
|
|
53
53
|
// the emmet helper directly to at least get emmet completions
|
|
54
|
-
return vscode_emmet_helper_1.doComplete(document, position, 'sass', this.configManager.getEmmetConfig());
|
|
54
|
+
return (0, vscode_emmet_helper_1.doComplete)(document, position, 'sass', this.configManager.getEmmetConfig());
|
|
55
55
|
}
|
|
56
56
|
const type = extractLanguage(cssDocument);
|
|
57
|
-
const lang = service_1.getLanguageService(type);
|
|
57
|
+
const lang = (0, service_1.getLanguageService)(type);
|
|
58
58
|
const emmetResults = {
|
|
59
59
|
isIncomplete: true,
|
|
60
60
|
items: [],
|
|
61
61
|
};
|
|
62
62
|
if (false /* this.configManager.getConfig().css.completions.emmet */) {
|
|
63
63
|
lang.setCompletionParticipants([
|
|
64
|
-
vscode_emmet_helper_1.getEmmetCompletionParticipants(cssDocument, cssDocument.getGeneratedPosition(position), service_1.getLanguage(type), this.configManager.getEmmetConfig(), emmetResults),
|
|
64
|
+
(0, vscode_emmet_helper_1.getEmmetCompletionParticipants)(cssDocument, cssDocument.getGeneratedPosition(position), (0, service_1.getLanguage)(type), this.configManager.getEmmetConfig(), emmetResults),
|
|
65
65
|
]);
|
|
66
66
|
}
|
|
67
67
|
const results = lang.doComplete(cssDocument, cssDocument.getGeneratedPosition(position), cssDocument.stylesheet);
|
|
68
|
-
return vscode_languageserver_1.CompletionList.create([...(results ? results.items : []), ...emmetResults.items].map((completionItem) => documents_1.mapCompletionItemToOriginal(cssDocument, completionItem)),
|
|
68
|
+
return vscode_languageserver_1.CompletionList.create([...(results ? results.items : []), ...emmetResults.items].map((completionItem) => (0, documents_1.mapCompletionItemToOriginal)(cssDocument, completionItem)),
|
|
69
69
|
// Emmet completions change on every keystroke, so they are never complete
|
|
70
70
|
emmetResults.items.length > 0);
|
|
71
71
|
}
|
|
@@ -81,7 +81,7 @@ class CSSPlugin {
|
|
|
81
81
|
return cssDoc;
|
|
82
82
|
}
|
|
83
83
|
isInsideFrontmatter(document, position) {
|
|
84
|
-
return utils_1.isInsideFrontmatter(document.getText(), document.offsetAt(position));
|
|
84
|
+
return (0, utils_1.isInsideFrontmatter)(document.getText(), document.offsetAt(position));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
exports.CSSPlugin = CSSPlugin;
|
|
@@ -13,7 +13,7 @@ class StyleAttributeDocument extends documents_1.ReadableDocument {
|
|
|
13
13
|
this.attrEnd = attrEnd;
|
|
14
14
|
this.version = this.parent.version;
|
|
15
15
|
this.languageId = 'css';
|
|
16
|
-
this.stylesheet = service_1.getLanguageService(this.languageId).parseStylesheet(this);
|
|
16
|
+
this.stylesheet = (0, service_1.getLanguageService)(this.languageId).parseStylesheet(this);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Get the fragment position relative to the parent
|
|
@@ -7,7 +7,7 @@ const vscode_languageserver_1 = require("vscode-languageserver");
|
|
|
7
7
|
const utils_1 = require("../../core/documents/utils");
|
|
8
8
|
class HTMLPlugin {
|
|
9
9
|
constructor(docManager, configManager) {
|
|
10
|
-
this.lang = vscode_html_languageservice_1.getLanguageService();
|
|
10
|
+
this.lang = (0, vscode_html_languageservice_1.getLanguageService)();
|
|
11
11
|
this.documents = new WeakMap();
|
|
12
12
|
this.styleScriptTemplate = new Set(['template', 'style', 'script']);
|
|
13
13
|
this.pluginName = 'HTML';
|
|
@@ -33,7 +33,7 @@ class HTMLPlugin {
|
|
|
33
33
|
isIncomplete: true,
|
|
34
34
|
items: [],
|
|
35
35
|
};
|
|
36
|
-
this.lang.setCompletionParticipants([vscode_emmet_helper_1.getEmmetCompletionParticipants(document, position, 'html', this.configManager.getEmmetConfig(), emmetResults)]);
|
|
36
|
+
this.lang.setCompletionParticipants([(0, vscode_emmet_helper_1.getEmmetCompletionParticipants)(document, position, 'html', this.configManager.getEmmetConfig(), emmetResults)]);
|
|
37
37
|
const results = this.lang.doComplete(document, position, html);
|
|
38
38
|
const items = this.toCompletionItems(results.items);
|
|
39
39
|
return vscode_languageserver_1.CompletionList.create([...this.toCompletionItems(items), ...this.getLangCompletions(items), ...emmetResults.items],
|
|
@@ -99,10 +99,10 @@ class HTMLPlugin {
|
|
|
99
99
|
isInsideExpression(html, document, position) {
|
|
100
100
|
const offset = document.offsetAt(position);
|
|
101
101
|
const node = html.findNodeAt(offset);
|
|
102
|
-
return utils_1.isInsideExpression(document.getText(), node.start, offset);
|
|
102
|
+
return (0, utils_1.isInsideExpression)(document.getText(), node.start, offset);
|
|
103
103
|
}
|
|
104
104
|
isInsideFrontmatter(document, position) {
|
|
105
|
-
return utils_1.isInsideFrontmatter(document.getText(), document.offsetAt(position));
|
|
105
|
+
return (0, utils_1.isInsideFrontmatter)(document.getText(), document.offsetAt(position));
|
|
106
106
|
}
|
|
107
107
|
isComponentTag(node) {
|
|
108
108
|
if (!node.tag) {
|