@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,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DocumentSymbolsProviderImpl = void 0;
|
|
4
|
-
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
class DocumentSymbolsProviderImpl {
|
|
7
|
-
constructor(languageServiceManager) {
|
|
8
|
-
this.languageServiceManager = languageServiceManager;
|
|
9
|
-
this.ts = languageServiceManager.docContext.ts;
|
|
10
|
-
}
|
|
11
|
-
async getDocumentSymbols(document) {
|
|
12
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
13
|
-
const navTree = lang.getNavigationTree(tsDoc.filePath + '?documentSymbols');
|
|
14
|
-
if (!navTree) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
const symbols = [];
|
|
18
|
-
this.collectSymbols(navTree, document, undefined, (symbol) => symbols.push(symbol));
|
|
19
|
-
const originalContainerName = symbols[0].name;
|
|
20
|
-
const result = [];
|
|
21
|
-
// Add a "Frontmatter" namespace for the frontmatter if we have a closed one
|
|
22
|
-
if (document.astroMeta.frontmatter.state === 'closed') {
|
|
23
|
-
result.push(vscode_languageserver_types_1.SymbolInformation.create('Frontmatter', vscode_languageserver_types_1.SymbolKind.Namespace, vscode_languageserver_types_1.Range.create(document.positionAt(document.astroMeta.frontmatter.startOffset), document.positionAt(document.astroMeta.frontmatter.endOffset)), document.getURL()));
|
|
24
|
-
}
|
|
25
|
-
// Add a "Template" namespace for everything under the frontmatter
|
|
26
|
-
result.push(vscode_languageserver_types_1.SymbolInformation.create('Template', vscode_languageserver_types_1.SymbolKind.Namespace, vscode_languageserver_types_1.Range.create(document.positionAt(document.astroMeta.frontmatter.endOffset ?? 0), document.positionAt(document.getTextLength())), document.getURL()));
|
|
27
|
-
for (let symbol of symbols.splice(1)) {
|
|
28
|
-
if (document.offsetAt(symbol.location.range.end) >= (document.astroMeta.content.firstNonWhitespaceOffset ?? 0)) {
|
|
29
|
-
if (symbol.containerName === originalContainerName) {
|
|
30
|
-
symbol.containerName = 'Template';
|
|
31
|
-
}
|
|
32
|
-
// For some reason, it seems like TypeScript thinks that the "class" attribute is a real class, weird
|
|
33
|
-
if (symbol.kind === vscode_languageserver_types_1.SymbolKind.Class && symbol.name === '<class>') {
|
|
34
|
-
const node = document.html.findNodeAt(document.offsetAt(symbol.location.range.start));
|
|
35
|
-
if (node.attributes?.class) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// Remove the exported function in our TSX output from the symbols
|
|
41
|
-
if (document.offsetAt(symbol.location.range.start) >= document.getTextLength()) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
result.push(symbol);
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
collectSymbols(item, document, container, cb) {
|
|
49
|
-
for (const span of item.spans) {
|
|
50
|
-
const symbol = vscode_languageserver_types_1.SymbolInformation.create(item.text, (0, utils_1.symbolKindFromString)(item.kind), vscode_languageserver_types_1.Range.create(document.positionAt(span.start), document.positionAt(span.start + span.length)), document.getURL(), container);
|
|
51
|
-
// TypeScript gives us kind modifiers as a string instead of an array
|
|
52
|
-
const kindModifiers = new Set(item.kindModifiers.split(/,|\s+/g));
|
|
53
|
-
if (kindModifiers.has(this.ts.ScriptElementKindModifier.deprecatedModifier)) {
|
|
54
|
-
if (!symbol.tags)
|
|
55
|
-
symbol.tags = [];
|
|
56
|
-
symbol.tags.push(vscode_languageserver_types_1.SymbolTag.Deprecated);
|
|
57
|
-
}
|
|
58
|
-
cb(symbol);
|
|
59
|
-
}
|
|
60
|
-
if (item.childItems) {
|
|
61
|
-
for (const child of item.childItems) {
|
|
62
|
-
this.collectSymbols(child, document, item.text, cb);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.DocumentSymbolsProviderImpl = DocumentSymbolsProviderImpl;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Location } from 'vscode-languageserver';
|
|
2
|
-
import { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import { FileReferencesProvider } from '../../interfaces';
|
|
4
|
-
import { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
|
-
export declare class FileReferencesProviderImpl implements FileReferencesProvider {
|
|
6
|
-
private languageServiceManager;
|
|
7
|
-
constructor(languageServiceManager: LanguageServiceManager);
|
|
8
|
-
fileReferences(document: AstroDocument): Promise<Location[] | null>;
|
|
9
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileReferencesProviderImpl = void 0;
|
|
4
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
5
|
-
const utils_1 = require("../../../utils");
|
|
6
|
-
const utils_2 = require("../utils");
|
|
7
|
-
const utils_3 = require("./utils");
|
|
8
|
-
class FileReferencesProviderImpl {
|
|
9
|
-
constructor(languageServiceManager) {
|
|
10
|
-
this.languageServiceManager = languageServiceManager;
|
|
11
|
-
}
|
|
12
|
-
async fileReferences(document) {
|
|
13
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
14
|
-
const references = lang.getFileReferences(tsDoc.filePath);
|
|
15
|
-
if (!references) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const snapshots = new utils_3.SnapshotMap(this.languageServiceManager);
|
|
19
|
-
snapshots.set(tsDoc.filePath, tsDoc);
|
|
20
|
-
const locations = await Promise.all(references.map(async (ref) => {
|
|
21
|
-
const snapshot = await snapshots.retrieve(ref.fileName);
|
|
22
|
-
return vscode_languageserver_1.Location.create((0, utils_1.pathToUrl)(ref.fileName), (0, utils_2.convertToLocationRange)(snapshot, ref.textSpan));
|
|
23
|
-
}));
|
|
24
|
-
return locations;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.FileReferencesProviderImpl = FileReferencesProviderImpl;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type ts from 'typescript';
|
|
2
|
-
import { FoldingRange } from 'vscode-languageserver';
|
|
3
|
-
import type { AstroDocument } from '../../../core/documents';
|
|
4
|
-
import type { FoldingRangesProvider } from '../../interfaces';
|
|
5
|
-
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
6
|
-
export declare class FoldingRangesProviderImpl implements FoldingRangesProvider {
|
|
7
|
-
private languageServiceManager;
|
|
8
|
-
private ts;
|
|
9
|
-
constructor(languageServiceManager: LanguageServiceManager);
|
|
10
|
-
getFoldingRanges(document: AstroDocument): Promise<FoldingRange[] | null>;
|
|
11
|
-
transformFoldingRangeKind(tsKind: ts.OutliningSpanKind): "imports" | "comment" | "region" | undefined;
|
|
12
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FoldingRangesProviderImpl = void 0;
|
|
4
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
class FoldingRangesProviderImpl {
|
|
7
|
-
constructor(languageServiceManager) {
|
|
8
|
-
this.languageServiceManager = languageServiceManager;
|
|
9
|
-
this.ts = languageServiceManager.docContext.ts;
|
|
10
|
-
}
|
|
11
|
-
async getFoldingRanges(document) {
|
|
12
|
-
const html = document.html;
|
|
13
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
14
|
-
const outliningSpans = lang.getOutliningSpans(tsDoc.filePath).filter((span) => {
|
|
15
|
-
const node = html.findNodeAt(span.textSpan.start);
|
|
16
|
-
// Due to how our TSX output transform those tags into function calls or template literals
|
|
17
|
-
// TypeScript thinks of those as outlining spans, which is fine but we don't want folding ranges for those
|
|
18
|
-
return node.tag !== 'script' && node.tag !== 'style';
|
|
19
|
-
});
|
|
20
|
-
const scriptOutliningSpans = [];
|
|
21
|
-
document.scriptTags.forEach((scriptTag) => {
|
|
22
|
-
const { snapshot: scriptTagSnapshot, filePath: scriptFilePath } = (0, utils_1.getScriptTagSnapshot)(tsDoc, document, scriptTag.container);
|
|
23
|
-
scriptOutliningSpans.push(...lang.getOutliningSpans(scriptFilePath).map((span) => {
|
|
24
|
-
span.textSpan.start = document.offsetAt(scriptTagSnapshot.getOriginalPosition(scriptTagSnapshot.positionAt(span.textSpan.start)));
|
|
25
|
-
return span;
|
|
26
|
-
}));
|
|
27
|
-
});
|
|
28
|
-
const foldingRanges = [];
|
|
29
|
-
for (const span of [...outliningSpans, ...scriptOutliningSpans]) {
|
|
30
|
-
const start = tsDoc.getOriginalPosition(tsDoc.positionAt(span.textSpan.start));
|
|
31
|
-
const end = adjustFoldingEnd(start, document.positionAt(document.offsetAt(start) + span.textSpan.length), document);
|
|
32
|
-
// When using this method for generating folding ranges, TypeScript tend to return some
|
|
33
|
-
// one line / one character ones that we should be able to safely ignore
|
|
34
|
-
if (start.line === end.line && start.character === end.character) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
// Ignore folding ranges that are from unmapped regions
|
|
38
|
-
if (start.line < 0 || end.line < 0) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
foldingRanges.push(vscode_languageserver_1.FoldingRange.create(start.line, end.line, start.character, end.character, this.transformFoldingRangeKind(span.kind)));
|
|
42
|
-
}
|
|
43
|
-
return foldingRanges;
|
|
44
|
-
}
|
|
45
|
-
transformFoldingRangeKind(tsKind) {
|
|
46
|
-
switch (tsKind) {
|
|
47
|
-
case this.ts.OutliningSpanKind.Comment:
|
|
48
|
-
return vscode_languageserver_1.FoldingRangeKind.Comment;
|
|
49
|
-
case this.ts.OutliningSpanKind.Imports:
|
|
50
|
-
return vscode_languageserver_1.FoldingRangeKind.Imports;
|
|
51
|
-
case this.ts.OutliningSpanKind.Region:
|
|
52
|
-
return vscode_languageserver_1.FoldingRangeKind.Region;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.FoldingRangesProviderImpl = FoldingRangesProviderImpl;
|
|
57
|
-
// https://github.com/microsoft/vscode/blob/bed61166fb604e519e82e4d1d1ed839bc45d65f8/extensions/typescript-language-features/src/languageFeatures/folding.ts#L61-L73
|
|
58
|
-
function adjustFoldingEnd(start, end, document) {
|
|
59
|
-
// workaround for #47240
|
|
60
|
-
if (end.character > 0) {
|
|
61
|
-
const foldEndCharacter = document.getText({
|
|
62
|
-
start: { line: end.line, character: end.character - 1 },
|
|
63
|
-
end,
|
|
64
|
-
});
|
|
65
|
-
if (['}', ']', ')', '`'].includes(foldEndCharacter)) {
|
|
66
|
-
const endOffset = Math.max(document.offsetAt({ line: end.line, character: 0 }) - 1, document.offsetAt(start));
|
|
67
|
-
return document.positionAt(endOffset);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return end;
|
|
71
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Hover, Position } from 'vscode-languageserver';
|
|
2
|
-
import { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import type { HoverProvider } from '../../interfaces';
|
|
4
|
-
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
|
-
export declare class HoverProviderImpl implements HoverProvider {
|
|
6
|
-
private languageServiceManager;
|
|
7
|
-
private ts;
|
|
8
|
-
constructor(languageServiceManager: LanguageServiceManager);
|
|
9
|
-
doHover(document: AstroDocument, position: Position): Promise<Hover | null>;
|
|
10
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HoverProviderImpl = void 0;
|
|
4
|
-
const documents_1 = require("../../../core/documents");
|
|
5
|
-
const previewer_1 = require("../previewer");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const partsMap = new Map([['JSX attribute', 'HTML attribute']]);
|
|
8
|
-
class HoverProviderImpl {
|
|
9
|
-
constructor(languageServiceManager) {
|
|
10
|
-
this.languageServiceManager = languageServiceManager;
|
|
11
|
-
this.ts = languageServiceManager.docContext.ts;
|
|
12
|
-
}
|
|
13
|
-
async doHover(document, position) {
|
|
14
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
15
|
-
const offset = tsDoc.offsetAt(tsDoc.getGeneratedPosition(position));
|
|
16
|
-
const html = document.html;
|
|
17
|
-
const documentOffset = document.offsetAt(position);
|
|
18
|
-
const node = html.findNodeAt(documentOffset);
|
|
19
|
-
let info;
|
|
20
|
-
if (node.tag === 'script') {
|
|
21
|
-
const { snapshot: scriptTagSnapshot, filePath: scriptFilePath, offset: scriptOffset, } = (0, utils_1.getScriptTagSnapshot)(tsDoc, document, node, position);
|
|
22
|
-
info = lang.getQuickInfoAtPosition(scriptFilePath, scriptOffset);
|
|
23
|
-
if (info) {
|
|
24
|
-
info.textSpan.start = (0, documents_1.mapScriptSpanStartToSnapshot)(info.textSpan, scriptTagSnapshot, tsDoc);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
info = lang.getQuickInfoAtPosition(tsDoc.filePath, offset);
|
|
29
|
-
}
|
|
30
|
-
if (!info) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const textSpan = info.textSpan;
|
|
34
|
-
const displayParts = (info.displayParts || []).map((value) => ({
|
|
35
|
-
text: partsMap.has(value.text) ? partsMap.get(value.text) : value.text,
|
|
36
|
-
kind: value.kind,
|
|
37
|
-
}));
|
|
38
|
-
const declaration = this.ts.displayPartsToString(displayParts);
|
|
39
|
-
const documentation = (0, previewer_1.getMarkdownDocumentation)(info.documentation, info.tags, this.ts);
|
|
40
|
-
// https://microsoft.github.io/language-server-protocol/specification#textDocument_hover
|
|
41
|
-
const contents = ['```typescript', declaration, '```']
|
|
42
|
-
.concat(documentation ? ['---', documentation] : [])
|
|
43
|
-
.join('\n');
|
|
44
|
-
return (0, documents_1.mapObjWithRangeToOriginal)(tsDoc, {
|
|
45
|
-
range: (0, utils_1.convertRange)(tsDoc, textSpan),
|
|
46
|
-
contents,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.HoverProviderImpl = HoverProviderImpl;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Location, Position } from 'vscode-languageserver-types';
|
|
2
|
-
import { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import { ImplementationProvider } from '../../interfaces';
|
|
4
|
-
import { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
|
-
export declare class ImplementationsProviderImpl implements ImplementationProvider {
|
|
6
|
-
private languageServiceManager;
|
|
7
|
-
constructor(languageServiceManager: LanguageServiceManager);
|
|
8
|
-
getImplementation(document: AstroDocument, position: Position): Promise<Location[] | null>;
|
|
9
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImplementationsProviderImpl = void 0;
|
|
4
|
-
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
5
|
-
const documents_1 = require("../../../core/documents");
|
|
6
|
-
const utils_1 = require("../../../utils");
|
|
7
|
-
const utils_2 = require("../utils");
|
|
8
|
-
const utils_3 = require("./utils");
|
|
9
|
-
class ImplementationsProviderImpl {
|
|
10
|
-
constructor(languageServiceManager) {
|
|
11
|
-
this.languageServiceManager = languageServiceManager;
|
|
12
|
-
}
|
|
13
|
-
async getImplementation(document, position) {
|
|
14
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
15
|
-
const fragmentPosition = tsDoc.getGeneratedPosition(position);
|
|
16
|
-
const fragmentOffset = tsDoc.offsetAt(fragmentPosition);
|
|
17
|
-
const html = document.html;
|
|
18
|
-
const offset = document.offsetAt(position);
|
|
19
|
-
const node = document.html.findNodeAt(offset);
|
|
20
|
-
let implementations;
|
|
21
|
-
if (node.tag === 'script') {
|
|
22
|
-
const { snapshot: scriptTagSnapshot, filePath: scriptFilePath, offset: scriptOffset, } = (0, utils_2.getScriptTagSnapshot)(tsDoc, document, node, position);
|
|
23
|
-
implementations = lang.getImplementationAtPosition(scriptFilePath, scriptOffset);
|
|
24
|
-
if (implementations) {
|
|
25
|
-
implementations = implementations.map((impl) => {
|
|
26
|
-
const isInSameFile = impl.fileName === scriptFilePath;
|
|
27
|
-
impl.fileName = isInSameFile ? tsDoc.filePath : impl.fileName;
|
|
28
|
-
if (isInSameFile) {
|
|
29
|
-
impl.textSpan.start = (0, documents_1.mapScriptSpanStartToSnapshot)(impl.textSpan, scriptTagSnapshot, tsDoc);
|
|
30
|
-
}
|
|
31
|
-
return impl;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
implementations = lang.getImplementationAtPosition(tsDoc.filePath, fragmentOffset);
|
|
37
|
-
}
|
|
38
|
-
const snapshots = new utils_3.SnapshotMap(this.languageServiceManager);
|
|
39
|
-
snapshots.set(tsDoc.filePath, tsDoc);
|
|
40
|
-
if (!implementations) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const result = await Promise.all(implementations.map(async (implementation) => {
|
|
44
|
-
const snapshot = await snapshots.retrieve(implementation.fileName);
|
|
45
|
-
const range = (0, documents_1.mapRangeToOriginal)(snapshot, (0, utils_2.convertRange)(snapshot, implementation.textSpan));
|
|
46
|
-
if (range.start.line >= 0 && range.end.line >= 0) {
|
|
47
|
-
return vscode_languageserver_types_1.Location.create((0, utils_1.pathToUrl)(implementation.fileName), range);
|
|
48
|
-
}
|
|
49
|
-
}));
|
|
50
|
-
return result.filter(utils_1.isNotNullOrUndefined);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.ImplementationsProviderImpl = ImplementationsProviderImpl;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { InlayHint } from 'vscode-languageserver';
|
|
2
|
-
import { Range } from 'vscode-languageserver-types';
|
|
3
|
-
import type { ConfigManager } from '../../../core/config';
|
|
4
|
-
import type { AstroDocument } from '../../../core/documents';
|
|
5
|
-
import type { InlayHintsProvider } from '../../interfaces';
|
|
6
|
-
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
7
|
-
export declare class InlayHintsProviderImpl implements InlayHintsProvider {
|
|
8
|
-
private languageServiceManager;
|
|
9
|
-
private configManager;
|
|
10
|
-
private ts;
|
|
11
|
-
constructor(languageServiceManager: LanguageServiceManager, configManager: ConfigManager);
|
|
12
|
-
getInlayHints(document: AstroDocument, range: Range): Promise<InlayHint[]>;
|
|
13
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InlayHintsProviderImpl = void 0;
|
|
4
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
5
|
-
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
6
|
-
class InlayHintsProviderImpl {
|
|
7
|
-
constructor(languageServiceManager, configManager) {
|
|
8
|
-
this.languageServiceManager = languageServiceManager;
|
|
9
|
-
this.configManager = configManager;
|
|
10
|
-
this.ts = languageServiceManager.docContext.ts;
|
|
11
|
-
}
|
|
12
|
-
async getInlayHints(document, range) {
|
|
13
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
14
|
-
const start = tsDoc.offsetAt(tsDoc.getGeneratedPosition(range.start));
|
|
15
|
-
const end = tsDoc.offsetAt(tsDoc.getGeneratedPosition(range.end));
|
|
16
|
-
const tsPreferences = await this.configManager.getTSPreferences(document);
|
|
17
|
-
const inlayHints = lang.provideInlayHints(tsDoc.filePath, { start, length: end - start }, tsPreferences);
|
|
18
|
-
return inlayHints.map((hint) => {
|
|
19
|
-
const result = vscode_languageserver_1.InlayHint.create(tsDoc.getOriginalPosition(tsDoc.positionAt(hint.position)), hint.text, hint.kind === this.ts.InlayHintKind.Type
|
|
20
|
-
? vscode_languageserver_types_1.InlayHintKind.Type
|
|
21
|
-
: hint.kind === this.ts.InlayHintKind.Parameter
|
|
22
|
-
? vscode_languageserver_types_1.InlayHintKind.Parameter
|
|
23
|
-
: undefined);
|
|
24
|
-
result.paddingLeft = hint.whitespaceBefore;
|
|
25
|
-
result.paddingRight = hint.whitespaceAfter;
|
|
26
|
-
return result;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.InlayHintsProviderImpl = InlayHintsProviderImpl;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Location, Position, ReferenceContext } from 'vscode-languageserver-types';
|
|
2
|
-
import { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import type { FindReferencesProvider } from '../../interfaces';
|
|
4
|
-
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
|
-
export declare class FindReferencesProviderImpl implements FindReferencesProvider {
|
|
6
|
-
private languageServiceManager;
|
|
7
|
-
constructor(languageServiceManager: LanguageServiceManager);
|
|
8
|
-
findReferences(document: AstroDocument, position: Position, context: ReferenceContext): Promise<Location[] | null>;
|
|
9
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FindReferencesProviderImpl = void 0;
|
|
4
|
-
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
5
|
-
const documents_1 = require("../../../core/documents");
|
|
6
|
-
const utils_1 = require("../../../utils");
|
|
7
|
-
const utils_2 = require("../utils");
|
|
8
|
-
const utils_3 = require("./utils");
|
|
9
|
-
class FindReferencesProviderImpl {
|
|
10
|
-
constructor(languageServiceManager) {
|
|
11
|
-
this.languageServiceManager = languageServiceManager;
|
|
12
|
-
}
|
|
13
|
-
async findReferences(document, position, context) {
|
|
14
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
15
|
-
const fragmentPosition = tsDoc.getGeneratedPosition(position);
|
|
16
|
-
const fragmentOffset = tsDoc.offsetAt(fragmentPosition);
|
|
17
|
-
const offset = document.offsetAt(position);
|
|
18
|
-
const node = document.html.findNodeAt(offset);
|
|
19
|
-
let references;
|
|
20
|
-
if (node.tag === 'script') {
|
|
21
|
-
const { snapshot: scriptTagSnapshot, filePath: scriptFilePath, offset: scriptOffset, } = (0, utils_2.getScriptTagSnapshot)(tsDoc, document, node, position);
|
|
22
|
-
references = lang.getReferencesAtPosition(scriptFilePath, scriptOffset);
|
|
23
|
-
if (references) {
|
|
24
|
-
references = references.map((ref) => {
|
|
25
|
-
const isInSameFile = ref.fileName === scriptFilePath;
|
|
26
|
-
ref.fileName = isInSameFile ? tsDoc.filePath : ref.fileName;
|
|
27
|
-
if (isInSameFile) {
|
|
28
|
-
ref.textSpan.start = (0, documents_1.mapScriptSpanStartToSnapshot)(ref.textSpan, scriptTagSnapshot, tsDoc);
|
|
29
|
-
}
|
|
30
|
-
return ref;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
references = lang.getReferencesAtPosition(tsDoc.filePath, fragmentOffset);
|
|
36
|
-
}
|
|
37
|
-
if (!references) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const snapshots = new utils_3.SnapshotMap(this.languageServiceManager);
|
|
41
|
-
snapshots.set(tsDoc.filePath, tsDoc);
|
|
42
|
-
const result = await Promise.all(references.map(async (reference) => {
|
|
43
|
-
if (!context.includeDeclaration) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const snapshot = await snapshots.retrieve(reference.fileName);
|
|
47
|
-
const range = (0, documents_1.mapRangeToOriginal)(snapshot, (0, utils_2.convertRange)(snapshot, reference.textSpan));
|
|
48
|
-
if (range.start.line >= 0 && range.end.line >= 0) {
|
|
49
|
-
return vscode_languageserver_types_1.Location.create((0, utils_1.pathToUrl)(reference.fileName), range);
|
|
50
|
-
}
|
|
51
|
-
}));
|
|
52
|
-
return result.filter(utils_1.isNotNullOrUndefined);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.FindReferencesProviderImpl = FindReferencesProviderImpl;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Position, Range, WorkspaceEdit } from 'vscode-languageserver-types';
|
|
2
|
-
import type { ConfigManager } from '../../../core/config';
|
|
3
|
-
import { AstroDocument } from '../../../core/documents';
|
|
4
|
-
import type { RenameProvider } from '../../interfaces';
|
|
5
|
-
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
6
|
-
export declare class RenameProviderImpl implements RenameProvider {
|
|
7
|
-
private languageServiceManager;
|
|
8
|
-
private configManager;
|
|
9
|
-
private ts;
|
|
10
|
-
constructor(languageServiceManager: LanguageServiceManager, configManager: ConfigManager);
|
|
11
|
-
prepareRename(document: AstroDocument, position: Position): Promise<Range | null>;
|
|
12
|
-
rename(document: AstroDocument, position: Position, newName: string): Promise<WorkspaceEdit | null>;
|
|
13
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RenameProviderImpl = void 0;
|
|
4
|
-
const documents_1 = require("../../../core/documents");
|
|
5
|
-
const utils_1 = require("../../../utils");
|
|
6
|
-
const utils_2 = require("../utils");
|
|
7
|
-
const utils_3 = require("./utils");
|
|
8
|
-
class RenameProviderImpl {
|
|
9
|
-
constructor(languageServiceManager, configManager) {
|
|
10
|
-
this.languageServiceManager = languageServiceManager;
|
|
11
|
-
this.configManager = configManager;
|
|
12
|
-
this.ts = languageServiceManager.docContext.ts;
|
|
13
|
-
}
|
|
14
|
-
async prepareRename(document, position) {
|
|
15
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
16
|
-
const offset = tsDoc.offsetAt(tsDoc.getGeneratedPosition(position));
|
|
17
|
-
// If our TSX isn't valid, we can't rename safely, so let's abort
|
|
18
|
-
if (tsDoc.isInErrorState) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
// TODO: Allow renaming of import paths
|
|
22
|
-
// This requires a bit of work, because we need to create files for the new import paths
|
|
23
|
-
const renameInfo = lang.getRenameInfo(tsDoc.filePath, offset, { allowRenameOfImportPath: false });
|
|
24
|
-
if (!renameInfo.canRename) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return (0, documents_1.mapRangeToOriginal)(tsDoc, (0, utils_2.convertRange)(tsDoc, renameInfo.triggerSpan));
|
|
28
|
-
}
|
|
29
|
-
async rename(document, position, newName) {
|
|
30
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
31
|
-
const offset = tsDoc.offsetAt(tsDoc.getGeneratedPosition(position));
|
|
32
|
-
const { providePrefixAndSuffixTextForRename } = await this.configManager.getTSPreferences(document);
|
|
33
|
-
let renames = lang.findRenameLocations(tsDoc.filePath, offset, false, false, providePrefixAndSuffixTextForRename);
|
|
34
|
-
if (!renames) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
const docs = new utils_3.SnapshotMap(this.languageServiceManager);
|
|
38
|
-
docs.set(tsDoc.filePath, tsDoc);
|
|
39
|
-
const mappedRenames = await Promise.all(renames.map(async (rename) => {
|
|
40
|
-
const snapshot = await docs.retrieve(rename.fileName);
|
|
41
|
-
return {
|
|
42
|
-
...rename,
|
|
43
|
-
range: (0, documents_1.mapRangeToOriginal)(snapshot, (0, utils_2.convertRange)(snapshot, rename.textSpan)),
|
|
44
|
-
newName,
|
|
45
|
-
};
|
|
46
|
-
}));
|
|
47
|
-
return mappedRenames.reduce((acc, loc) => {
|
|
48
|
-
const uri = (0, utils_1.pathToUrl)(loc.fileName);
|
|
49
|
-
if (!acc.changes[uri]) {
|
|
50
|
-
acc.changes[uri] = [];
|
|
51
|
-
}
|
|
52
|
-
acc.changes[uri].push({
|
|
53
|
-
newText: (loc.prefixText || '') + (loc.newName || newName) + (loc.suffixText || ''),
|
|
54
|
-
range: loc.range,
|
|
55
|
-
});
|
|
56
|
-
return acc;
|
|
57
|
-
}, { changes: {} });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.RenameProviderImpl = RenameProviderImpl;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CancellationToken, Range, SemanticTokens } from 'vscode-languageserver';
|
|
2
|
-
import { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import type { SemanticTokensProvider } from '../../interfaces';
|
|
4
|
-
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
|
-
export declare class SemanticTokensProviderImpl implements SemanticTokensProvider {
|
|
6
|
-
private languageServiceManager;
|
|
7
|
-
private ts;
|
|
8
|
-
constructor(languageServiceManager: LanguageServiceManager);
|
|
9
|
-
getSemanticTokens(document: AstroDocument, range?: Range, cancellationToken?: CancellationToken): Promise<SemanticTokens | null>;
|
|
10
|
-
private mapToOrigin;
|
|
11
|
-
/**
|
|
12
|
-
* TSClassification = (TokenType + 1) << TokenEncodingConsts.typeOffset + TokenModifier
|
|
13
|
-
*/
|
|
14
|
-
private getTokenTypeFromClassification;
|
|
15
|
-
private getTokenModifierFromClassification;
|
|
16
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SemanticTokensProviderImpl = void 0;
|
|
4
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
5
|
-
const documents_1 = require("../../../core/documents");
|
|
6
|
-
class SemanticTokensProviderImpl {
|
|
7
|
-
constructor(languageServiceManager) {
|
|
8
|
-
this.languageServiceManager = languageServiceManager;
|
|
9
|
-
this.ts = languageServiceManager.docContext.ts;
|
|
10
|
-
}
|
|
11
|
-
async getSemanticTokens(document, range, cancellationToken) {
|
|
12
|
-
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
13
|
-
if (cancellationToken?.isCancellationRequested) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const start = range ? tsDoc.offsetAt(tsDoc.getGeneratedPosition(range.start)) : 0;
|
|
17
|
-
const { spans } = lang.getEncodedSemanticClassifications(tsDoc.filePath, {
|
|
18
|
-
start,
|
|
19
|
-
length: range
|
|
20
|
-
? tsDoc.offsetAt(tsDoc.getGeneratedPosition(range.end)) - start
|
|
21
|
-
: // We don't want tokens for things added by astro2tsx
|
|
22
|
-
tsDoc.getFullText().lastIndexOf('export default function ') || tsDoc.getLength(),
|
|
23
|
-
}, this.ts.SemanticClassificationFormat.TwentyTwenty);
|
|
24
|
-
const tokens = [];
|
|
25
|
-
let i = 0;
|
|
26
|
-
while (i < spans.length) {
|
|
27
|
-
const offset = spans[i++];
|
|
28
|
-
const generatedLength = spans[i++];
|
|
29
|
-
const classification = spans[i++];
|
|
30
|
-
const originalPosition = this.mapToOrigin(document, tsDoc, offset, generatedLength);
|
|
31
|
-
if (!originalPosition) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
const [line, character, length] = originalPosition;
|
|
35
|
-
const classificationType = this.getTokenTypeFromClassification(classification);
|
|
36
|
-
if (classificationType < 0) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
const modifier = this.getTokenModifierFromClassification(classification);
|
|
40
|
-
tokens.push([line, character, length, classificationType, modifier]);
|
|
41
|
-
}
|
|
42
|
-
const sorted = tokens.sort((a, b) => {
|
|
43
|
-
const [lineA, charA] = a;
|
|
44
|
-
const [lineB, charB] = b;
|
|
45
|
-
return lineA - lineB || charA - charB;
|
|
46
|
-
});
|
|
47
|
-
const builder = new vscode_languageserver_1.SemanticTokensBuilder();
|
|
48
|
-
sorted.forEach((tokenData) => builder.push(...tokenData));
|
|
49
|
-
const build = builder.build();
|
|
50
|
-
return build;
|
|
51
|
-
}
|
|
52
|
-
mapToOrigin(document, snapshot, generatedOffset, generatedLength) {
|
|
53
|
-
const range = {
|
|
54
|
-
start: snapshot.positionAt(generatedOffset),
|
|
55
|
-
end: snapshot.positionAt(generatedOffset + generatedLength),
|
|
56
|
-
};
|
|
57
|
-
const { start: startPosition, end: endPosition } = (0, documents_1.mapRangeToOriginal)(snapshot, range);
|
|
58
|
-
if (startPosition.line < 0 || endPosition.line < 0) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const startOffset = document.offsetAt(startPosition);
|
|
62
|
-
const endOffset = document.offsetAt(endPosition);
|
|
63
|
-
return [startPosition.line, startPosition.character, endOffset - startOffset, startOffset];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* TSClassification = (TokenType + 1) << TokenEncodingConsts.typeOffset + TokenModifier
|
|
67
|
-
*/
|
|
68
|
-
getTokenTypeFromClassification(tsClassification) {
|
|
69
|
-
return (tsClassification >> 8 /* TokenEncodingConsts.typeOffset */) - 1;
|
|
70
|
-
}
|
|
71
|
-
getTokenModifierFromClassification(tsClassification) {
|
|
72
|
-
return tsClassification & 255 /* TokenEncodingConsts.modifierMask */;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.SemanticTokensProviderImpl = SemanticTokensProviderImpl;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { CancellationToken, Position, SignatureHelp, SignatureHelpContext } from 'vscode-languageserver';
|
|
2
|
-
import type { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import type { SignatureHelpProvider } from '../../interfaces';
|
|
4
|
-
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
|
-
export declare class SignatureHelpProviderImpl implements SignatureHelpProvider {
|
|
6
|
-
private languageServiceManager;
|
|
7
|
-
private ts;
|
|
8
|
-
constructor(languageServiceManager: LanguageServiceManager);
|
|
9
|
-
private static readonly triggerCharacters;
|
|
10
|
-
private static readonly retriggerCharacters;
|
|
11
|
-
getSignatureHelp(document: AstroDocument, position: Position, context: SignatureHelpContext | undefined, cancellationToken?: CancellationToken): Promise<SignatureHelp | null>;
|
|
12
|
-
private isReTrigger;
|
|
13
|
-
private isTriggerCharacter;
|
|
14
|
-
/**
|
|
15
|
-
* adopted from https://github.com/microsoft/vscode/blob/265a2f6424dfbd3a9788652c7d376a7991d049a3/extensions/typescript-language-features/src/languageFeatures/signatureHelp.ts#L103
|
|
16
|
-
*/
|
|
17
|
-
private toTsTriggerReason;
|
|
18
|
-
/**
|
|
19
|
-
* adopted from https://github.com/microsoft/vscode/blob/265a2f6424dfbd3a9788652c7d376a7991d049a3/extensions/typescript-language-features/src/languageFeatures/signatureHelp.ts#L73
|
|
20
|
-
*/
|
|
21
|
-
private toSignatureHelpInformation;
|
|
22
|
-
}
|