diff options
author | 2021-04-30 16:33:35 -0500 | |
---|---|---|
committer | 2021-04-30 16:33:35 -0500 | |
commit | 4df1347156cf2632ea2f3475d3a5f8f08d197cc3 (patch) | |
tree | 9d50de89dfe62827c32a8a4046120af4ab61dc0c /tools/vscode/packages/server/src/plugins/interfaces.ts | |
parent | 1d498facc8f78a3ffbfecd05cc6ecd45e8a4a1ae (diff) | |
download | astro-4df1347156cf2632ea2f3475d3a5f8f08d197cc3.tar.gz astro-4df1347156cf2632ea2f3475d3a5f8f08d197cc3.tar.zst astro-4df1347156cf2632ea2f3475d3a5f8f08d197cc3.zip |
Migrate to `yarn` monorepo (#157)
* chore: use monorepo
* chore: scaffold astro-scripts
* chore: move tests inside packages/astro
* chore: refactor tests, add scripts
* chore: move parser to own module
* chore: move runtime to packages/astro
* fix: move parser to own package
* test: fix prettier-plugin-astro tests
* fix: tests
* chore: update package-lock
* chore: add changesets
* fix: cleanup examples
* fix: starter example
* chore: update changeset config
* chore: update changeset config
* chore: setup changeset release workflow
* chore: bump lockfiles
* chore: prism => astro-prism
* fix: tsc --emitDeclarationOnly
* chore: final cleanup, switch to yarn
* chore: add lerna
* chore: update workflows to yarn
* chore: update workflows
* chore: remove lint workflow
* chore: add astro-dev script
* chore: add symlinked README
Diffstat (limited to 'tools/vscode/packages/server/src/plugins/interfaces.ts')
-rw-r--r-- | tools/vscode/packages/server/src/plugins/interfaces.ts | 217 |
1 files changed, 217 insertions, 0 deletions
diff --git a/tools/vscode/packages/server/src/plugins/interfaces.ts b/tools/vscode/packages/server/src/plugins/interfaces.ts new file mode 100644 index 000000000..31aafdc3e --- /dev/null +++ b/tools/vscode/packages/server/src/plugins/interfaces.ts @@ -0,0 +1,217 @@ +import { + CompletionContext, + FileChangeType, + LinkedEditingRanges, + SemanticTokens, + SignatureHelpContext, + TextDocumentContentChangeEvent +} from 'vscode-languageserver'; +import { + CodeAction, + CodeActionContext, + Color, + ColorInformation, + ColorPresentation, + CompletionItem, + CompletionList, + DefinitionLink, + Diagnostic, + FormattingOptions, + Hover, + Location, + Position, + Range, + ReferenceContext, + SymbolInformation, + TextDocumentIdentifier, + TextEdit, + WorkspaceEdit, + SelectionRange, + SignatureHelp, + FoldingRange +} from 'vscode-languageserver-types'; +import { Document } from '../core/documents'; + +export type Resolvable<T> = T | Promise<T>; + +export interface AppCompletionItem<T extends TextDocumentIdentifier = any> extends CompletionItem { + data?: T; +} + +export interface AppCompletionList<T extends TextDocumentIdentifier = any> extends CompletionList { + items: Array<AppCompletionItem<T>>; +} + +export interface DiagnosticsProvider { + getDiagnostics(document: Document): Resolvable<Diagnostic[]>; +} + +export interface HoverProvider { + doHover(document: Document, position: Position): Resolvable<Hover | null>; +} + +export interface FoldingRangeProvider { + getFoldingRanges(document: Document): Resolvable<FoldingRange[]|null>; +} + +export interface CompletionsProvider<T extends TextDocumentIdentifier = any> { + getCompletions( + document: Document, + position: Position, + completionContext?: CompletionContext + ): Resolvable<AppCompletionList<T> | null>; + + resolveCompletion?( + document: Document, + completionItem: AppCompletionItem<T> + ): Resolvable<AppCompletionItem<T>>; +} + +export interface FormattingProvider { + formatDocument(document: Document, options: FormattingOptions): Resolvable<TextEdit[]>; +} + +export interface TagCompleteProvider { + doTagComplete(document: Document, position: Position): Resolvable<string | null>; +} + +export interface DocumentColorsProvider { + getDocumentColors(document: Document): Resolvable<ColorInformation[]>; +} + +export interface ColorPresentationsProvider { + getColorPresentations( + document: Document, + range: Range, + color: Color + ): Resolvable<ColorPresentation[]>; +} + +export interface DocumentSymbolsProvider { + getDocumentSymbols(document: Document): Resolvable<SymbolInformation[]>; +} + +export interface DefinitionsProvider { + getDefinitions(document: Document, position: Position): Resolvable<DefinitionLink[]>; +} + +export interface BackwardsCompatibleDefinitionsProvider { + getDefinitions( + document: Document, + position: Position + ): Resolvable<DefinitionLink[] | Location[]>; +} + +export interface CodeActionsProvider { + getCodeActions( + document: Document, + range: Range, + context: CodeActionContext + ): Resolvable<CodeAction[]>; + executeCommand?( + document: Document, + command: string, + args?: any[] + ): Resolvable<WorkspaceEdit | string | null>; +} + +export interface FileRename { + oldUri: string; + newUri: string; +} + +export interface UpdateImportsProvider { + updateImports(fileRename: FileRename): Resolvable<WorkspaceEdit | null>; +} + +export interface RenameProvider { + rename( + document: Document, + position: Position, + newName: string + ): Resolvable<WorkspaceEdit | null>; + prepareRename(document: Document, position: Position): Resolvable<Range | null>; +} + +export interface FindReferencesProvider { + findReferences( + document: Document, + position: Position, + context: ReferenceContext + ): Promise<Location[] | null>; +} + +export interface SignatureHelpProvider { + getSignatureHelp( + document: Document, + position: Position, + context: SignatureHelpContext | undefined + ): Resolvable<SignatureHelp | null>; +} + +export interface SelectionRangeProvider { + getSelectionRange(document: Document, position: Position): Resolvable<SelectionRange | null>; +} + +export interface SemanticTokensProvider { + getSemanticTokens(textDocument: Document, range?: Range): Resolvable<SemanticTokens | null>; +} + +export interface LinkedEditingRangesProvider { + getLinkedEditingRanges( + document: Document, + position: Position + ): Resolvable<LinkedEditingRanges | null>; +} + +export interface OnWatchFileChangesPara { + fileName: string; + changeType: FileChangeType; +} + +export interface OnWatchFileChanges { + onWatchFileChanges(onWatchFileChangesParas: OnWatchFileChangesPara[]): void; +} + +export interface UpdateTsOrJsFile { + updateTsOrJsFile(fileName: string, changes: TextDocumentContentChangeEvent[]): void; +} + +type ProviderBase = DiagnosticsProvider & + HoverProvider & + CompletionsProvider & + FormattingProvider & + FoldingRangeProvider & + TagCompleteProvider & + DocumentColorsProvider & + ColorPresentationsProvider & + DocumentSymbolsProvider & + UpdateImportsProvider & + CodeActionsProvider & + FindReferencesProvider & + RenameProvider & + SignatureHelpProvider & + SemanticTokensProvider & + LinkedEditingRangesProvider; + +export type LSProvider = ProviderBase & BackwardsCompatibleDefinitionsProvider; + +export interface LSPProviderConfig { + /** + * Whether or not completion lists that are marked as imcomplete + * should be filtered server side. + */ + filterIncompleteCompletions: boolean; + /** + * Whether or not getDefinitions supports the LocationLink interface. + */ + definitionLinkSupport: boolean; +} + +export type Plugin = Partial< + ProviderBase & + DefinitionsProvider & + OnWatchFileChanges & + SelectionRangeProvider & + UpdateTsOrJsFile +>; |