@astrojs/language-server 2.16.1-alpha.0 → 2.16.1
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/dist/check.js
CHANGED
|
@@ -128,7 +128,7 @@ class AstroCheck {
|
|
|
128
128
|
(0, svelte_js_1.getSvelteLanguagePlugin)(),
|
|
129
129
|
(0, vue_js_1.getVueLanguagePlugin)(),
|
|
130
130
|
];
|
|
131
|
-
const services = [...(0, index_js_2.create)(this.ts), (0, astro_js_1.create)()];
|
|
131
|
+
const services = [...(0, index_js_2.create)(this.ts), (0, astro_js_1.create)(this.ts)];
|
|
132
132
|
if (tsconfigPath) {
|
|
133
133
|
const includeProjectReference = false; // #920
|
|
134
134
|
this.linter = kit.createTypeScriptChecker(languagePlugins, services, tsconfigPath, includeProjectReference, ({ project }) => {
|
package/dist/core/astro2tsx.js
CHANGED
|
@@ -18,7 +18,7 @@ function safeConvertToTSX(content, options) {
|
|
|
18
18
|
return tsx;
|
|
19
19
|
}
|
|
20
20
|
catch (e) {
|
|
21
|
-
console.error(`There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/
|
|
21
|
+
console.error(`There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/astro/issues\nError: ${e}.`);
|
|
22
22
|
return {
|
|
23
23
|
code: '',
|
|
24
24
|
map: {
|
|
@@ -34,7 +34,7 @@ function safeConvertToTSX(content, options) {
|
|
|
34
34
|
code: 1000,
|
|
35
35
|
location: { file: options.filename, line: 1, column: 1, length: content.length },
|
|
36
36
|
severity: 1,
|
|
37
|
-
text: `The Astro compiler encountered an unknown error while transform this file to TSX. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/
|
|
37
|
+
text: `The Astro compiler encountered an unknown error while transform this file to TSX. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/astro/issues`,
|
|
38
38
|
},
|
|
39
39
|
],
|
|
40
40
|
metaRanges: {
|
package/dist/core/parseAstro.js
CHANGED
|
@@ -15,7 +15,7 @@ function safeParseAst(fileName, input, parseOptions) {
|
|
|
15
15
|
return parseResult;
|
|
16
16
|
}
|
|
17
17
|
catch (e) {
|
|
18
|
-
console.error(`There was an error parsing ${fileName}'s AST. An empty AST will be returned instead to avoid breaking the server. Please create an issue: https://github.com/withastro/
|
|
18
|
+
console.error(`There was an error parsing ${fileName}'s AST. An empty AST will be returned instead to avoid breaking the server. Please create an issue: https://github.com/withastro/astro/issues\nError: ${e}.`);
|
|
19
19
|
return {
|
|
20
20
|
ast: {
|
|
21
21
|
type: 'root',
|
|
@@ -31,7 +31,7 @@ function safeParseAst(fileName, input, parseOptions) {
|
|
|
31
31
|
length: input.length,
|
|
32
32
|
},
|
|
33
33
|
severity: 1,
|
|
34
|
-
text: `The Astro compiler encountered an unknown error while parsing this file's AST. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/
|
|
34
|
+
text: `The Astro compiler encountered an unknown error while parsing this file's AST. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/astro/issues`,
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
37
|
};
|
|
@@ -38,7 +38,7 @@ function getLanguageServicePlugins(connection, ts, collectionConfig, initializeP
|
|
|
38
38
|
}),
|
|
39
39
|
(0, volar_service_typescript_twoslash_queries_1.create)(ts),
|
|
40
40
|
(0, index_js_2.create)(),
|
|
41
|
-
(0, astro_js_1.create)(),
|
|
41
|
+
(0, astro_js_1.create)(ts),
|
|
42
42
|
getPrettierService(),
|
|
43
43
|
(0, yaml_js_1.create)(collectionConfig),
|
|
44
44
|
];
|
package/dist/plugins/astro.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LanguageServicePlugin } from '@volar/language-server';
|
|
2
|
-
export declare const create: () => LanguageServicePlugin;
|
|
2
|
+
export declare const create: (ts: typeof import("typescript")) => LanguageServicePlugin;
|
package/dist/plugins/astro.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.create = void 0;
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
4
8
|
const language_server_1 = require("@volar/language-server");
|
|
9
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
5
10
|
const vscode_uri_1 = require("vscode-uri");
|
|
6
11
|
const index_js_1 = require("../core/index.js");
|
|
7
|
-
const
|
|
12
|
+
const utils_js_1 = require("./utils.js");
|
|
13
|
+
const create = (ts) => {
|
|
8
14
|
return {
|
|
9
15
|
capabilities: {
|
|
10
16
|
completionProvider: {
|
|
@@ -14,6 +20,7 @@ const create = () => {
|
|
|
14
20
|
interFileDependencies: false,
|
|
15
21
|
workspaceDiagnostics: false,
|
|
16
22
|
},
|
|
23
|
+
codeLensProvider: {},
|
|
17
24
|
},
|
|
18
25
|
create(context) {
|
|
19
26
|
return {
|
|
@@ -57,11 +64,54 @@ const create = () => {
|
|
|
57
64
|
};
|
|
58
65
|
}
|
|
59
66
|
},
|
|
67
|
+
provideCodeLenses(document, token) {
|
|
68
|
+
if (token.isCancellationRequested)
|
|
69
|
+
return;
|
|
70
|
+
if (!(0, utils_js_1.isJSDocument)(document.languageId))
|
|
71
|
+
return;
|
|
72
|
+
if (!context.project.typescript)
|
|
73
|
+
return;
|
|
74
|
+
const { uriConverter } = context.project.typescript;
|
|
75
|
+
const languageService = context.inject('typescript/languageService');
|
|
76
|
+
if (!languageService)
|
|
77
|
+
return;
|
|
78
|
+
const tsProgram = languageService.getProgram();
|
|
79
|
+
if (!tsProgram)
|
|
80
|
+
return;
|
|
81
|
+
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
|
82
|
+
if (!decoded)
|
|
83
|
+
return;
|
|
84
|
+
const globcodeLens = [];
|
|
85
|
+
const sourceFile = tsProgram.getSourceFile(decoded[0].fsPath);
|
|
86
|
+
function walk() {
|
|
87
|
+
return ts.forEachChild(sourceFile, function cb(node) {
|
|
88
|
+
if (ts.isCallExpression(node) && node.expression.getText() === 'Astro.glob') {
|
|
89
|
+
const globArgument = node.arguments.at(0);
|
|
90
|
+
if (globArgument && decoded) {
|
|
91
|
+
globcodeLens.push(getGlobResultAsCodeLens(globArgument.getText().slice(1, -1), (0, node_path_1.dirname)(uriConverter.asFileName(decoded[0])), document.positionAt(node.arguments.pos)));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return ts.forEachChild(node, cb);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
walk();
|
|
98
|
+
return globcodeLens;
|
|
99
|
+
},
|
|
60
100
|
};
|
|
61
101
|
},
|
|
62
102
|
};
|
|
63
103
|
};
|
|
64
104
|
exports.create = create;
|
|
105
|
+
function getGlobResultAsCodeLens(globText, dir, position) {
|
|
106
|
+
const globResult = fast_glob_1.default.sync(globText, {
|
|
107
|
+
cwd: dir,
|
|
108
|
+
onlyFiles: true,
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
range: language_server_1.Range.create(position, position),
|
|
112
|
+
command: { title: `Matches ${globResult.length} files`, command: '' },
|
|
113
|
+
};
|
|
114
|
+
}
|
|
65
115
|
function getFrontmatterCompletion(file, document, position) {
|
|
66
116
|
const base = {
|
|
67
117
|
kind: language_server_1.CompletionItemKind.Snippet,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "2.16.1
|
|
3
|
+
"version": "2.16.1",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -64,7 +64,8 @@
|
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsc",
|
|
66
66
|
"dev": "tsc --watch",
|
|
67
|
-
"
|
|
67
|
+
"sync-fixture": "pnpm --dir ./test/fixture sync",
|
|
68
|
+
"test": "pnpm sync-fixture && astro-scripts test \"**/*.test.ts\" --teardown-test ./test/misc/teardown.ts --tsx true",
|
|
68
69
|
"test:match": "pnpm run test --match"
|
|
69
70
|
}
|
|
70
71
|
}
|