@astrojs/language-server 0.11.0 → 0.13.0
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 +23 -0
- package/bin/browserServer.js +3 -0
- package/bin/nodeServer.js +3 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +8 -0
- package/dist/check.js +2 -5
- package/dist/core/DiagnosticsManager.d.ts +3 -3
- package/dist/core/DiagnosticsManager.js +2 -2
- package/dist/core/config/ConfigManager.d.ts +19 -164
- package/dist/core/config/ConfigManager.js +62 -101
- package/dist/core/config/index.d.ts +1 -0
- package/dist/core/config/index.js +1 -0
- package/dist/core/config/interfaces.d.ts +123 -0
- package/dist/core/config/interfaces.js +2 -0
- package/dist/core/documents/AstroDocument.d.ts +18 -0
- package/dist/core/documents/AstroDocument.js +42 -0
- package/dist/core/documents/DocumentBase.d.ts +10 -2
- package/dist/core/documents/DocumentBase.js +15 -50
- package/dist/core/documents/DocumentManager.d.ts +12 -16
- package/dist/core/documents/DocumentManager.js +32 -26
- package/dist/core/documents/DocumentMapper.js +3 -1
- package/dist/core/documents/index.d.ts +1 -1
- package/dist/core/documents/index.js +1 -1
- package/dist/core/documents/parseAstro.d.ts +2 -2
- package/dist/core/documents/parseHtml.d.ts +2 -2
- package/dist/core/documents/parseHtml.js +4 -1
- package/dist/core/documents/utils.d.ts +22 -26
- package/dist/core/documents/utils.js +96 -134
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/node.d.ts +1 -0
- package/dist/node.js +29 -0
- package/dist/plugins/PluginHost.d.ts +11 -9
- package/dist/plugins/PluginHost.js +34 -36
- package/dist/plugins/astro/AstroPlugin.d.ts +11 -12
- package/dist/plugins/astro/AstroPlugin.js +17 -42
- package/dist/plugins/astro/features/{CompletionProvider.d.ts → CompletionsProvider.d.ts} +5 -5
- package/dist/plugins/astro/features/{CompletionProvider.js → CompletionsProvider.js} +33 -58
- package/dist/plugins/css/CSSDocument.d.ts +3 -3
- package/dist/plugins/css/CSSDocument.js +7 -16
- package/dist/plugins/css/CSSPlugin.d.ts +31 -12
- package/dist/plugins/css/CSSPlugin.js +174 -41
- package/dist/plugins/css/StyleAttributeDocument.d.ts +2 -2
- package/dist/plugins/css/StyleAttributeDocument.js +2 -2
- package/dist/plugins/css/features/astro-selectors.d.ts +2 -0
- package/dist/plugins/css/features/astro-selectors.js +16 -0
- package/dist/plugins/css/features/{getIdClassCompletion.d.ts → getIdClassCompletions.d.ts} +3 -3
- package/dist/plugins/css/features/{getIdClassCompletion.js → getIdClassCompletions.js} +10 -9
- package/dist/plugins/css/{service.d.ts → language-service.d.ts} +0 -0
- package/dist/plugins/css/{service.js → language-service.js} +2 -1
- package/dist/plugins/html/HTMLPlugin.d.ts +18 -17
- package/dist/plugins/html/HTMLPlugin.js +69 -41
- package/dist/plugins/html/features/astro-attributes.d.ts +2 -0
- package/dist/plugins/html/features/astro-attributes.js +126 -0
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/index.js +2 -2
- package/dist/plugins/interfaces.d.ts +35 -48
- package/dist/plugins/typescript/LanguageServiceManager.d.ts +33 -14
- package/dist/plugins/typescript/LanguageServiceManager.js +57 -32
- package/dist/plugins/typescript/TypeScriptPlugin.d.ts +18 -23
- package/dist/plugins/typescript/TypeScriptPlugin.js +58 -55
- package/dist/plugins/typescript/astro-sys.d.ts +5 -3
- package/dist/plugins/typescript/astro-sys.js +24 -45
- package/dist/plugins/typescript/features/CompletionsProvider.d.ts +6 -6
- package/dist/plugins/typescript/features/CompletionsProvider.js +18 -38
- package/dist/plugins/typescript/features/DiagnosticsProvider.d.ts +4 -4
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +27 -87
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.d.ts +10 -0
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.js +69 -0
- package/dist/plugins/typescript/features/HoverProvider.d.ts +4 -5
- package/dist/plugins/typescript/features/HoverProvider.js +9 -10
- package/dist/plugins/typescript/features/SignatureHelpProvider.d.ts +4 -5
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +15 -11
- package/dist/plugins/typescript/features/utils.d.ts +1 -12
- package/dist/plugins/typescript/features/utils.js +2 -22
- package/dist/plugins/typescript/language-service.d.ts +38 -0
- package/dist/plugins/typescript/language-service.js +230 -0
- package/dist/plugins/typescript/module-loader.d.ts +5 -8
- package/dist/plugins/typescript/module-loader.js +43 -23
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.d.ts +90 -0
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.js +135 -0
- package/dist/plugins/typescript/snapshots/SnapshotManager.d.ts +42 -0
- package/dist/plugins/typescript/snapshots/SnapshotManager.js +197 -0
- package/dist/plugins/typescript/snapshots/utils.d.ts +28 -0
- package/dist/plugins/typescript/snapshots/utils.js +84 -0
- package/dist/plugins/typescript/utils.d.ts +10 -13
- package/dist/plugins/typescript/utils.js +154 -158
- package/dist/server.d.ts +2 -4
- package/dist/server.js +93 -54
- package/dist/utils.d.ts +20 -16
- package/dist/utils.js +35 -24
- package/package.json +18 -12
- package/types/astro-jsx.d.ts +1077 -0
- package/bin/server.js +0 -7
- package/dist/core/documents/Document.d.ts +0 -51
- package/dist/core/documents/Document.js +0 -135
- package/dist/plugins/typescript/DocumentSnapshot.d.ts +0 -99
- package/dist/plugins/typescript/DocumentSnapshot.js +0 -259
- package/dist/plugins/typescript/SnapshotManager.d.ts +0 -24
- package/dist/plugins/typescript/SnapshotManager.js +0 -103
- package/dist/plugins/typescript/languageService.d.ts +0 -17
- package/dist/plugins/typescript/languageService.js +0 -173
- package/types/index.d.ts +0 -4
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.astroDirectives = exports.astroAttributes = void 0;
|
|
4
|
+
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
5
|
+
exports.astroAttributes = (0, vscode_html_languageservice_1.newHTMLDataProvider)('astro-attributes', {
|
|
6
|
+
version: 1,
|
|
7
|
+
globalAttributes: [
|
|
8
|
+
{
|
|
9
|
+
name: 'class:list',
|
|
10
|
+
description: 'Utility to provide a list of class',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'set:html',
|
|
14
|
+
description: 'Inject unescaped HTML into this tag',
|
|
15
|
+
references: [
|
|
16
|
+
{
|
|
17
|
+
name: 'Astro documentation',
|
|
18
|
+
url: 'https://docs.astro.build/en/migrate/#deprecated-unescaped-html',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'set:text',
|
|
24
|
+
description: 'Inject escaped text into this tag',
|
|
25
|
+
references: [
|
|
26
|
+
{
|
|
27
|
+
name: 'Astro documentation',
|
|
28
|
+
url: 'https://docs.astro.build/en/migrate/#deprecated-unescaped-html',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
tags: [
|
|
34
|
+
{
|
|
35
|
+
name: 'script',
|
|
36
|
+
attributes: [
|
|
37
|
+
{
|
|
38
|
+
// The VS Code tag definitions does not provide a description for the deprecated `charset` attribute on script tags
|
|
39
|
+
// Which mean that since we get no hover info for this, we instead get JSX hover info. So we'll just specify a description ourselves for this specific case
|
|
40
|
+
name: 'charset',
|
|
41
|
+
description: "(Deprecated) It's unnecessary to specify the charset attribute, because documents must use UTF-8, and the script element inherits its character encoding from the document.",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'define:vars',
|
|
45
|
+
description: 'Passes serializable server-side variables into a client-side script element',
|
|
46
|
+
references: [
|
|
47
|
+
{
|
|
48
|
+
name: 'Astro documentation',
|
|
49
|
+
url: 'https://docs.astro.build/en/guides/styling/#variables-in-scripts--styles',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'style',
|
|
57
|
+
attributes: [
|
|
58
|
+
{
|
|
59
|
+
name: 'define:vars',
|
|
60
|
+
description: 'Passes serializable server-side variables into a client-side style element',
|
|
61
|
+
references: [
|
|
62
|
+
{
|
|
63
|
+
name: 'Astro documentation',
|
|
64
|
+
url: 'https://docs.astro.build/en/guides/styling/#variables-in-scripts--styles',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
exports.astroDirectives = (0, vscode_html_languageservice_1.newHTMLDataProvider)('astro-directives', {
|
|
73
|
+
version: 1,
|
|
74
|
+
globalAttributes: [
|
|
75
|
+
{
|
|
76
|
+
name: 'client:load',
|
|
77
|
+
description: 'Start importing the component JS at page load. Hydrate the component when import completes.',
|
|
78
|
+
references: [
|
|
79
|
+
{
|
|
80
|
+
name: 'Astro documentation',
|
|
81
|
+
url: 'https://docs.astro.build/en/core-concepts/component-hydration/#hydrate-interactive-components',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'client:idle',
|
|
87
|
+
description: 'Start importing the component JS as soon as main thread is free (uses requestIdleCallback()). Hydrate the component when import completes.',
|
|
88
|
+
references: [
|
|
89
|
+
{
|
|
90
|
+
name: 'Astro documentation',
|
|
91
|
+
url: 'https://docs.astro.build/en/core-concepts/component-hydration/#hydrate-interactive-components',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'client:visible',
|
|
97
|
+
description: 'Start importing the component JS as soon as the element enters the viewport (uses IntersectionObserver). Hydrate the component when import completes. Useful for content lower down on the page.',
|
|
98
|
+
references: [
|
|
99
|
+
{
|
|
100
|
+
name: 'Astro documentation',
|
|
101
|
+
url: 'https://docs.astro.build/en/core-concepts/component-hydration/#hydrate-interactive-components',
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'client:media',
|
|
107
|
+
description: 'Start importing the component JS as soon as the browser matches the given media query (uses matchMedia). Hydrate the component when import completes. Useful for sidebar toggles, or other elements that should only display on mobile or desktop devices.',
|
|
108
|
+
references: [
|
|
109
|
+
{
|
|
110
|
+
name: 'Astro documentation',
|
|
111
|
+
url: 'https://docs.astro.build/en/core-concepts/component-hydration/#hydrate-interactive-components',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'client:only',
|
|
117
|
+
description: 'Start importing the component JS at page load and hydrate when the import completes, similar to client:load. The component will be skipped at build time, useful for components that are entirely dependent on client-side APIs. This is best avoided unless absolutely needed, in most cases it is best to render placeholder content on the server and delay any browser API calls until the component hydrates in the browser.',
|
|
118
|
+
references: [
|
|
119
|
+
{
|
|
120
|
+
name: 'Astro documentation',
|
|
121
|
+
url: 'https://docs.astro.build/en/core-concepts/component-hydration/#hydrate-interactive-components',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
});
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './PluginHost';
|
|
2
|
-
export * from './astro/AstroPlugin';
|
|
3
2
|
export * from './html/HTMLPlugin';
|
|
3
|
+
export * from './css/CSSPlugin';
|
|
4
4
|
export * from './typescript/TypeScriptPlugin';
|
|
5
|
+
export * from './astro/AstroPlugin';
|
|
5
6
|
export * from './interfaces';
|
|
6
|
-
export * from './css/CSSPlugin';
|
package/dist/plugins/index.js
CHANGED
|
@@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./PluginHost"), exports);
|
|
18
|
-
__exportStar(require("./astro/AstroPlugin"), exports);
|
|
19
18
|
__exportStar(require("./html/HTMLPlugin"), exports);
|
|
19
|
+
__exportStar(require("./css/CSSPlugin"), exports);
|
|
20
20
|
__exportStar(require("./typescript/TypeScriptPlugin"), exports);
|
|
21
|
+
__exportStar(require("./astro/AstroPlugin"), exports);
|
|
21
22
|
__exportStar(require("./interfaces"), exports);
|
|
22
|
-
__exportStar(require("./css/CSSPlugin"), exports);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { CompletionContext, FileChangeType, LinkedEditingRanges, SemanticTokens, SignatureHelpContext, TextDocumentContentChangeEvent } from 'vscode-languageserver';
|
|
2
|
-
import {
|
|
3
|
-
import { Document } from '../core/documents';
|
|
1
|
+
import { CodeAction, CodeActionContext, Color, ColorInformation, ColorPresentation, CompletionContext, CompletionItem, CompletionList, DefinitionLink, Diagnostic, FileChangeType, FoldingRange, FormattingOptions, Hover, LinkedEditingRanges, Position, Range, ReferenceContext, SelectionRange, SemanticTokens, SignatureHelp, SignatureHelpContext, SymbolInformation, TextDocumentContentChangeEvent, TextDocumentIdentifier, TextEdit, WorkspaceEdit } from 'vscode-languageserver';
|
|
2
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
3
|
export declare type Resolvable<T> = T | Promise<T>;
|
|
5
4
|
export interface AppCompletionItem<T extends TextDocumentIdentifier = any> extends CompletionItem {
|
|
6
5
|
data?: T;
|
|
@@ -9,42 +8,42 @@ export interface AppCompletionList<T extends TextDocumentIdentifier = any> exten
|
|
|
9
8
|
items: Array<AppCompletionItem<T>>;
|
|
10
9
|
}
|
|
11
10
|
export interface DiagnosticsProvider {
|
|
12
|
-
getDiagnostics(document:
|
|
11
|
+
getDiagnostics(document: TextDocument): Resolvable<Diagnostic[]>;
|
|
13
12
|
}
|
|
14
13
|
export interface HoverProvider {
|
|
15
|
-
doHover(document:
|
|
14
|
+
doHover(document: TextDocument, position: Position): Resolvable<Hover | null>;
|
|
16
15
|
}
|
|
17
16
|
export interface FoldingRangeProvider {
|
|
18
|
-
getFoldingRanges(document:
|
|
17
|
+
getFoldingRanges(document: TextDocument): Resolvable<FoldingRange[] | null>;
|
|
19
18
|
}
|
|
20
19
|
export interface CompletionsProvider<T extends TextDocumentIdentifier = any> {
|
|
21
|
-
getCompletions(document:
|
|
22
|
-
resolveCompletion?(document:
|
|
20
|
+
getCompletions(document: TextDocument, position: Position, completionContext?: CompletionContext): Resolvable<AppCompletionList<T> | null>;
|
|
21
|
+
resolveCompletion?(document: TextDocument, completionItem: AppCompletionItem<T>): Resolvable<AppCompletionItem<T>>;
|
|
23
22
|
}
|
|
24
23
|
export interface FormattingProvider {
|
|
25
|
-
formatDocument(document:
|
|
24
|
+
formatDocument(document: TextDocument, options: FormattingOptions): Resolvable<TextEdit[]>;
|
|
26
25
|
}
|
|
27
26
|
export interface TagCompleteProvider {
|
|
28
|
-
doTagComplete(document:
|
|
27
|
+
doTagComplete(document: TextDocument, position: Position): Resolvable<string | null>;
|
|
29
28
|
}
|
|
30
29
|
export interface DocumentColorsProvider {
|
|
31
|
-
getDocumentColors(document:
|
|
30
|
+
getDocumentColors(document: TextDocument): Resolvable<ColorInformation[]>;
|
|
32
31
|
}
|
|
33
32
|
export interface ColorPresentationsProvider {
|
|
34
|
-
getColorPresentations(document:
|
|
33
|
+
getColorPresentations(document: TextDocument, range: Range, color: Color): Resolvable<ColorPresentation[]>;
|
|
35
34
|
}
|
|
36
35
|
export interface DocumentSymbolsProvider {
|
|
37
|
-
getDocumentSymbols(document:
|
|
36
|
+
getDocumentSymbols(document: TextDocument): Resolvable<SymbolInformation[]>;
|
|
38
37
|
}
|
|
39
38
|
export interface DefinitionsProvider {
|
|
40
|
-
getDefinitions(document:
|
|
39
|
+
getDefinitions(document: TextDocument, position: Position): Resolvable<DefinitionLink[]>;
|
|
41
40
|
}
|
|
42
41
|
export interface BackwardsCompatibleDefinitionsProvider {
|
|
43
|
-
getDefinitions(document:
|
|
42
|
+
getDefinitions(document: TextDocument, position: Position): Resolvable<DefinitionLink[] | Location[]>;
|
|
44
43
|
}
|
|
45
44
|
export interface CodeActionsProvider {
|
|
46
|
-
getCodeActions(document:
|
|
47
|
-
executeCommand?(document:
|
|
45
|
+
getCodeActions(document: TextDocument, range: Range, context: CodeActionContext): Resolvable<CodeAction[]>;
|
|
46
|
+
executeCommand?(document: TextDocument, command: string, args?: any[]): Resolvable<WorkspaceEdit | string | null>;
|
|
48
47
|
}
|
|
49
48
|
export interface FileRename {
|
|
50
49
|
oldUri: string;
|
|
@@ -54,49 +53,37 @@ export interface UpdateImportsProvider {
|
|
|
54
53
|
updateImports(fileRename: FileRename): Resolvable<WorkspaceEdit | null>;
|
|
55
54
|
}
|
|
56
55
|
export interface RenameProvider {
|
|
57
|
-
rename(document:
|
|
58
|
-
prepareRename(document:
|
|
56
|
+
rename(document: TextDocument, position: Position, newName: string): Resolvable<WorkspaceEdit | null>;
|
|
57
|
+
prepareRename(document: TextDocument, position: Position): Resolvable<Range | null>;
|
|
59
58
|
}
|
|
60
59
|
export interface FindReferencesProvider {
|
|
61
|
-
findReferences(document:
|
|
60
|
+
findReferences(document: TextDocument, position: Position, context: ReferenceContext): Promise<Location[] | null>;
|
|
62
61
|
}
|
|
63
62
|
export interface SignatureHelpProvider {
|
|
64
|
-
getSignatureHelp(document:
|
|
63
|
+
getSignatureHelp(document: TextDocument, position: Position, context: SignatureHelpContext | undefined): Resolvable<SignatureHelp | null>;
|
|
65
64
|
}
|
|
66
65
|
export interface SelectionRangeProvider {
|
|
67
|
-
getSelectionRange(document:
|
|
66
|
+
getSelectionRange(document: TextDocument, position: Position): Resolvable<SelectionRange | null>;
|
|
68
67
|
}
|
|
69
68
|
export interface SemanticTokensProvider {
|
|
70
|
-
getSemanticTokens(textDocument:
|
|
69
|
+
getSemanticTokens(textDocument: TextDocument, range?: Range): Resolvable<SemanticTokens | null>;
|
|
71
70
|
}
|
|
72
71
|
export interface LinkedEditingRangesProvider {
|
|
73
|
-
getLinkedEditingRanges(document:
|
|
72
|
+
getLinkedEditingRanges(document: TextDocument, position: Position): Resolvable<LinkedEditingRanges | null>;
|
|
74
73
|
}
|
|
75
|
-
export interface
|
|
74
|
+
export interface OnWatchFileChangesParam {
|
|
76
75
|
fileName: string;
|
|
77
76
|
changeType: FileChangeType;
|
|
78
77
|
}
|
|
79
|
-
export interface
|
|
80
|
-
onWatchFileChanges(
|
|
81
|
-
}
|
|
82
|
-
export interface
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
declare type ProviderBase = DiagnosticsProvider & HoverProvider & CompletionsProvider & FormattingProvider & FoldingRangeProvider & TagCompleteProvider & DocumentColorsProvider & ColorPresentationsProvider & DocumentSymbolsProvider & UpdateImportsProvider & CodeActionsProvider & FindReferencesProvider & RenameProvider & SignatureHelpProvider & SemanticTokensProvider & LinkedEditingRangesProvider;
|
|
86
|
-
export declare type LSProvider = ProviderBase
|
|
87
|
-
export
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* should be filtered server side.
|
|
91
|
-
*/
|
|
92
|
-
filterIncompleteCompletions: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Whether or not getDefinitions supports the LocationLink interface.
|
|
95
|
-
*/
|
|
96
|
-
definitionLinkSupport: boolean;
|
|
97
|
-
}
|
|
98
|
-
interface NamedPlugin {
|
|
99
|
-
pluginName: string;
|
|
100
|
-
}
|
|
101
|
-
export declare type Plugin = Partial<NamedPlugin & ProviderBase & DefinitionsProvider & OnWatchFileChanges & SelectionRangeProvider & UpdateTsOrJsFile>;
|
|
78
|
+
export interface OnWatchFileChangesProvider {
|
|
79
|
+
onWatchFileChanges(onWatchFileChangesParams: OnWatchFileChangesParam[]): void;
|
|
80
|
+
}
|
|
81
|
+
export interface UpdateNonAstroFile {
|
|
82
|
+
updateNonAstroFile(fileName: string, changes: TextDocumentContentChangeEvent[]): void;
|
|
83
|
+
}
|
|
84
|
+
declare type ProviderBase = DiagnosticsProvider & HoverProvider & CompletionsProvider & DefinitionsProvider & FormattingProvider & FoldingRangeProvider & TagCompleteProvider & DocumentColorsProvider & ColorPresentationsProvider & DocumentSymbolsProvider & UpdateImportsProvider & CodeActionsProvider & FindReferencesProvider & RenameProvider & SignatureHelpProvider & SemanticTokensProvider & SelectionRangeProvider & OnWatchFileChangesProvider & LinkedEditingRangesProvider & UpdateNonAstroFile;
|
|
85
|
+
export declare type LSProvider = ProviderBase;
|
|
86
|
+
export declare type Plugin = Partial<ProviderBase> & {
|
|
87
|
+
__name: string;
|
|
88
|
+
};
|
|
102
89
|
export {};
|
|
@@ -1,23 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { TextDocumentContentChangeEvent } from 'vscode-languageserver';
|
|
3
|
+
import { ConfigManager } from '../../core/config';
|
|
4
|
+
import { AstroDocument, DocumentManager } from '../../core/documents';
|
|
5
|
+
import { LanguageServiceContainer } from './language-service';
|
|
6
|
+
import { DocumentSnapshot } from './snapshots/DocumentSnapshot';
|
|
6
7
|
export declare class LanguageServiceManager {
|
|
7
8
|
private readonly docManager;
|
|
8
|
-
private readonly configManager;
|
|
9
9
|
private readonly workspaceUris;
|
|
10
|
+
private readonly configManager;
|
|
10
11
|
private docContext;
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
private globalSnapshotManager;
|
|
13
|
+
constructor(docManager: DocumentManager, workspaceUris: string[], configManager: ConfigManager);
|
|
14
|
+
/**
|
|
15
|
+
* Create an AstroDocument (only for astro files)
|
|
16
|
+
*/
|
|
13
17
|
private createDocument;
|
|
14
|
-
getSnapshot(document:
|
|
15
|
-
getSnapshot(pathOrDoc: string |
|
|
16
|
-
|
|
18
|
+
getSnapshot(document: AstroDocument): Promise<DocumentSnapshot>;
|
|
19
|
+
getSnapshot(pathOrDoc: string | AstroDocument): Promise<DocumentSnapshot>;
|
|
20
|
+
/**
|
|
21
|
+
* Updates snapshot path in all existing ts services and retrieves snapshot
|
|
22
|
+
*/
|
|
23
|
+
updateSnapshotPath(oldPath: string, newPath: string): Promise<DocumentSnapshot>;
|
|
24
|
+
/**
|
|
25
|
+
* Deletes snapshot in all existing ts services
|
|
26
|
+
*/
|
|
27
|
+
deleteSnapshot(filePath: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Updates project files in all existing ts services
|
|
30
|
+
*/
|
|
31
|
+
updateProjectFiles(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Updates file in all ts services where it exists
|
|
34
|
+
*/
|
|
35
|
+
updateExistingNonAstroFile(path: string, changes?: TextDocumentContentChangeEvent[]): Promise<void>;
|
|
36
|
+
getLSAndTSDoc(document: AstroDocument): Promise<{
|
|
17
37
|
tsDoc: DocumentSnapshot;
|
|
18
38
|
lang: ts.LanguageService;
|
|
19
39
|
}>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
private getTypeScriptLanguageService;
|
|
40
|
+
getLSForPath(path: string): Promise<ts.LanguageService>;
|
|
41
|
+
getTypeScriptLanguageService(filePath: string): Promise<LanguageServiceContainer>;
|
|
23
42
|
}
|
|
@@ -2,62 +2,87 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LanguageServiceManager = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
|
-
const
|
|
5
|
+
const language_service_1 = require("./language-service");
|
|
6
|
+
const SnapshotManager_1 = require("./snapshots/SnapshotManager");
|
|
6
7
|
class LanguageServiceManager {
|
|
7
|
-
constructor(docManager,
|
|
8
|
-
this.
|
|
8
|
+
constructor(docManager, workspaceUris, configManager) {
|
|
9
|
+
this.docManager = docManager;
|
|
10
|
+
this.workspaceUris = workspaceUris;
|
|
11
|
+
this.configManager = configManager;
|
|
12
|
+
this.globalSnapshotManager = new SnapshotManager_1.GlobalSnapshotManager();
|
|
13
|
+
/**
|
|
14
|
+
* Create an AstroDocument (only for astro files)
|
|
15
|
+
*/
|
|
16
|
+
this.createDocument = (fileName, content) => {
|
|
9
17
|
const uri = (0, utils_1.pathToUrl)(fileName);
|
|
10
18
|
const document = this.docManager.openDocument({
|
|
11
|
-
languageId: 'astro',
|
|
12
|
-
version: 0,
|
|
13
19
|
text: content,
|
|
14
20
|
uri,
|
|
15
|
-
overrideText,
|
|
16
21
|
});
|
|
22
|
+
this.docManager.lockDocument(uri);
|
|
17
23
|
return document;
|
|
18
24
|
};
|
|
19
|
-
this.docManager = docManager;
|
|
20
|
-
this.configManager = configManager;
|
|
21
|
-
this.workspaceUris = workspaceUris;
|
|
22
25
|
this.docContext = {
|
|
23
|
-
getWorkspaceRoot: (fileName) => this.getWorkspaceRoot(fileName),
|
|
24
26
|
createDocument: this.createDocument,
|
|
27
|
+
globalSnapshotManager: this.globalSnapshotManager,
|
|
25
28
|
};
|
|
26
29
|
const handleDocumentChange = (document) => {
|
|
27
|
-
|
|
28
|
-
this.getTypeScriptDoc(document);
|
|
30
|
+
this.getSnapshot(document);
|
|
29
31
|
};
|
|
30
32
|
docManager.on('documentChange', (0, utils_1.debounceSameArg)(handleDocumentChange, (newDoc, prevDoc) => newDoc.uri === (prevDoc === null || prevDoc === void 0 ? void 0 : prevDoc.uri), 1000));
|
|
31
33
|
docManager.on('documentOpen', handleDocumentChange);
|
|
32
34
|
}
|
|
33
|
-
getWorkspaceRoot(fileName) {
|
|
34
|
-
if (this.workspaceUris.length === 1)
|
|
35
|
-
return (0, utils_1.urlToPath)(this.workspaceUris[0]);
|
|
36
|
-
return this.workspaceUris.reduce((found, curr) => {
|
|
37
|
-
const url = (0, utils_1.urlToPath)(curr);
|
|
38
|
-
if (fileName.startsWith(url) && curr.length < url.length)
|
|
39
|
-
return url;
|
|
40
|
-
return found;
|
|
41
|
-
}, '');
|
|
42
|
-
}
|
|
43
35
|
async getSnapshot(pathOrDoc) {
|
|
44
36
|
const filePath = typeof pathOrDoc === 'string' ? pathOrDoc : pathOrDoc.getFilePath() || '';
|
|
45
37
|
const tsService = await this.getTypeScriptLanguageService(filePath);
|
|
46
|
-
return tsService.
|
|
38
|
+
return tsService.updateSnapshot(pathOrDoc);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Updates snapshot path in all existing ts services and retrieves snapshot
|
|
42
|
+
*/
|
|
43
|
+
async updateSnapshotPath(oldPath, newPath) {
|
|
44
|
+
await this.deleteSnapshot(oldPath);
|
|
45
|
+
return this.getSnapshot(newPath);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Deletes snapshot in all existing ts services
|
|
49
|
+
*/
|
|
50
|
+
async deleteSnapshot(filePath) {
|
|
51
|
+
await (0, language_service_1.forAllLanguageServices)((service) => service.deleteSnapshot(filePath));
|
|
52
|
+
this.docManager.releaseDocument((0, utils_1.pathToUrl)(filePath));
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Updates project files in all existing ts services
|
|
56
|
+
*/
|
|
57
|
+
async updateProjectFiles() {
|
|
58
|
+
await (0, language_service_1.forAllLanguageServices)((service) => service.updateProjectFiles());
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Updates file in all ts services where it exists
|
|
62
|
+
*/
|
|
63
|
+
async updateExistingNonAstroFile(path, changes) {
|
|
64
|
+
path = (0, utils_1.normalizePath)(path);
|
|
65
|
+
// Only update once because all snapshots are shared between
|
|
66
|
+
// services. Since we don't have a current version of TS/JS
|
|
67
|
+
// files, the operation wouldn't be idempotent.
|
|
68
|
+
let didUpdate = false;
|
|
69
|
+
await (0, language_service_1.forAllLanguageServices)((service) => {
|
|
70
|
+
if (service.hasFile(path) && !didUpdate) {
|
|
71
|
+
didUpdate = true;
|
|
72
|
+
service.updateNonAstroFile(path, changes);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async getLSAndTSDoc(document) {
|
|
77
|
+
const lang = await this.getLSForPath(document.getFilePath() || '');
|
|
50
78
|
const tsDoc = await this.getSnapshot(document);
|
|
51
79
|
return { tsDoc, lang };
|
|
52
80
|
}
|
|
53
|
-
async
|
|
54
|
-
return (
|
|
55
|
-
}
|
|
56
|
-
async getSnapshotManager(filePath) {
|
|
57
|
-
return (await this.getTypeScriptLanguageService(filePath)).snapshotManager;
|
|
81
|
+
async getLSForPath(path) {
|
|
82
|
+
return (await this.getTypeScriptLanguageService(path)).getService();
|
|
58
83
|
}
|
|
59
|
-
getTypeScriptLanguageService(filePath) {
|
|
60
|
-
return (0,
|
|
84
|
+
async getTypeScriptLanguageService(filePath) {
|
|
85
|
+
return (0, language_service_1.getLanguageService)(filePath, this.workspaceUris, this.docContext);
|
|
61
86
|
}
|
|
62
87
|
}
|
|
63
88
|
exports.LanguageServiceManager = LanguageServiceManager;
|
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { CompletionContext, DefinitionLink, Position } from 'vscode-languageserver';
|
|
6
|
-
import { SnapshotManager } from './SnapshotManager';
|
|
1
|
+
import { CancellationToken, CompletionContext, DefinitionLink, Diagnostic, Hover, Position, SignatureHelp, SignatureHelpContext, SymbolInformation, TextDocumentContentChangeEvent, WorkspaceEdit } from 'vscode-languageserver';
|
|
2
|
+
import { ConfigManager } from '../../core/config';
|
|
3
|
+
import { AstroDocument, DocumentManager } from '../../core/documents';
|
|
4
|
+
import { AppCompletionItem, AppCompletionList, OnWatchFileChangesParam, Plugin } from '../interfaces';
|
|
7
5
|
import { CompletionEntryWithIdentifer } from './features/CompletionsProvider';
|
|
8
|
-
export declare class TypeScriptPlugin implements
|
|
9
|
-
|
|
10
|
-
private
|
|
6
|
+
export declare class TypeScriptPlugin implements Plugin {
|
|
7
|
+
__name: string;
|
|
8
|
+
private configManager;
|
|
11
9
|
private readonly languageServiceManager;
|
|
12
|
-
pluginName: string;
|
|
13
10
|
private readonly completionProvider;
|
|
14
11
|
private readonly hoverProvider;
|
|
15
12
|
private readonly signatureHelpProvider;
|
|
16
13
|
private readonly diagnosticsProvider;
|
|
14
|
+
private readonly documentSymbolsProvider;
|
|
17
15
|
constructor(docManager: DocumentManager, configManager: ConfigManager, workspaceUris: string[]);
|
|
18
|
-
doHover(document:
|
|
19
|
-
rename(document:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
getSnapshotManager(fileName: string): Promise<SnapshotManager>;
|
|
16
|
+
doHover(document: AstroDocument, position: Position): Promise<Hover | null>;
|
|
17
|
+
rename(document: AstroDocument, position: Position, newName: string): Promise<WorkspaceEdit | null>;
|
|
18
|
+
getDocumentSymbols(document: AstroDocument): Promise<SymbolInformation[]>;
|
|
19
|
+
getCompletions(document: AstroDocument, position: Position, completionContext?: CompletionContext): Promise<AppCompletionList<CompletionEntryWithIdentifer> | null>;
|
|
20
|
+
resolveCompletion(document: AstroDocument, completionItem: AppCompletionItem<CompletionEntryWithIdentifer>): Promise<AppCompletionItem<CompletionEntryWithIdentifer>>;
|
|
21
|
+
getDefinitions(document: AstroDocument, position: Position): Promise<DefinitionLink[]>;
|
|
22
|
+
getDiagnostics(document: AstroDocument, cancellationToken?: CancellationToken): Promise<Diagnostic[]>;
|
|
23
|
+
onWatchFileChanges(onWatchFileChangesParas: OnWatchFileChangesParam[]): Promise<void>;
|
|
24
|
+
updateNonAstroFile(fileName: string, changes: TextDocumentContentChangeEvent[]): Promise<void>;
|
|
25
|
+
getSignatureHelp(document: AstroDocument, position: Position, context: SignatureHelpContext | undefined, cancellationToken?: CancellationToken): Promise<SignatureHelp | null>;
|
|
31
26
|
private goToDefinitionFoundOnlyAlias;
|
|
32
27
|
private getGoToDefinitionRefsForImportSpecifier;
|
|
33
28
|
private featureEnabled;
|