diff --git a/examples/domainmodel/test/refs-index.test.ts b/examples/domainmodel/test/refs-index.test.ts index 749a46087..3c621bfc6 100644 --- a/examples/domainmodel/test/refs-index.test.ts +++ b/examples/domainmodel/test/refs-index.test.ts @@ -5,10 +5,9 @@ ******************************************************************************/ import type { AstNode, LangiumDocument, ReferenceDescription, URI } from 'langium'; -import { AstUtils, EmptyFileSystem } from 'langium'; +import { AstUtils, EmptyFileSystem, TextDocument } from 'langium'; import { parseDocument, setTextDocument } from 'langium/test'; import { describe, expect, test } from 'vitest'; -import { TextDocument } from 'vscode-languageserver-textdocument'; import { createDomainModelServices } from '../src/language-server/domain-model-module.js'; import type { Domainmodel } from '../src/language-server/generated/ast.js'; diff --git a/packages/langium/src/lsp/completion/completion-provider.ts b/packages/langium/src/lsp/completion/completion-provider.ts index 4d181d224..ef698b7c3 100644 --- a/packages/langium/src/lsp/completion/completion-provider.ts +++ b/packages/langium/src/lsp/completion/completion-provider.ts @@ -4,22 +4,21 @@ * terms of the MIT License, which is available in the project root. ******************************************************************************/ -import type { CancellationToken, CompletionItem, CompletionParams } from 'vscode-languageserver'; -import type { TextDocument, TextEdit } from 'vscode-languageserver-textdocument'; +import type { CompletionItem, CompletionParams, TextEdit } from 'vscode-languageserver-protocol'; import type { LangiumCompletionParser } from '../../parser/langium-parser.js'; import type { NameProvider } from '../../references/name-provider.js'; import type { ScopeProvider } from '../../references/scope-provider.js'; import type { LangiumServices } from '../lsp-services.js'; import type { AstNode, AstNodeDescription, AstReflection, CstNode, ReferenceInfo } from '../../syntax-tree.js'; import type { MaybePromise } from '../../utils/promise-utils.js'; -import type { LangiumDocument } from '../../workspace/documents.js'; +import type { LangiumDocument, TextDocument } from '../../workspace/documents.js'; import type { NextFeature } from './follow-element-computation.js'; import type { NodeKindProvider } from '../node-kind-provider.js'; import type { FuzzyMatcher } from '../fuzzy-matcher.js'; import type { GrammarConfig } from '../../languages/grammar-config.js'; import type { Lexer } from '../../parser/lexer.js'; import type { IToken } from 'chevrotain'; -import { CompletionItemKind, CompletionList, Position } from 'vscode-languageserver'; +import { CancellationToken, CompletionItemKind, CompletionList, Position } from 'vscode-languageserver'; import * as ast from '../../languages/generated/ast.js'; import { assignMandatoryProperties, getContainerOfType } from '../../utils/ast-utils.js'; import { findDeclarationNodeAtOffset, findLeafNodeBeforeOffset } from '../../utils/cst-utils.js'; diff --git a/packages/langium/src/lsp/default-lsp-module.ts b/packages/langium/src/lsp/default-lsp-module.ts index 1fb68530a..2a11efe36 100644 --- a/packages/langium/src/lsp/default-lsp-module.ts +++ b/packages/langium/src/lsp/default-lsp-module.ts @@ -5,10 +5,10 @@ ******************************************************************************/ import { type Connection, TextDocuments } from 'vscode-languageserver'; -import { TextDocument } from 'vscode-languageserver-textdocument'; import { createDefaultCoreModule, createDefaultSharedCoreModule, type DefaultCoreModuleContext, type DefaultSharedCoreModuleContext } from '../default-module.js'; import { Module } from '../dependency-injection.js'; import type { LangiumDefaultCoreServices, LangiumDefaultSharedCoreServices } from '../services.js'; +import { TextDocument } from '../workspace/documents.js'; import { DefaultCompletionProvider } from './completion/completion-provider.js'; import { DefaultDefinitionProvider } from './definition-provider.js'; import { DefaultDocumentHighlightProvider } from './document-highlight-provider.js'; diff --git a/packages/langium/src/lsp/document-update-handler.ts b/packages/langium/src/lsp/document-update-handler.ts index feac8c506..19d75c434 100644 --- a/packages/langium/src/lsp/document-update-handler.ts +++ b/packages/langium/src/lsp/document-update-handler.ts @@ -5,10 +5,10 @@ ******************************************************************************/ import { DidChangeWatchedFilesNotification, FileChangeType, type DidChangeWatchedFilesParams, type DidChangeWatchedFilesRegistrationOptions, type TextDocumentChangeEvent } from 'vscode-languageserver'; -import type { TextDocument } from 'vscode-languageserver-textdocument'; import { stream } from '../utils/stream.js'; import { URI } from '../utils/uri-utils.js'; import type { DocumentBuilder } from '../workspace/document-builder.js'; +import type { TextDocument } from '../workspace/documents.js'; import type { WorkspaceLock } from '../workspace/workspace-lock.js'; import type { LangiumSharedServices } from './lsp-services.js'; diff --git a/packages/langium/src/lsp/formatter.ts b/packages/langium/src/lsp/formatter.ts index c90d87778..5006298a3 100644 --- a/packages/langium/src/lsp/formatter.ts +++ b/packages/langium/src/lsp/formatter.ts @@ -4,12 +4,11 @@ * terms of the MIT License, which is available in the project root. ******************************************************************************/ -import type { CancellationToken, DocumentFormattingParams, DocumentOnTypeFormattingOptions, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, FormattingOptions, Range, TextEdit } from 'vscode-languageserver'; -import type { TextDocument } from 'vscode-languageserver-textdocument'; +import type { CancellationToken, DocumentFormattingParams, DocumentOnTypeFormattingOptions, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, FormattingOptions, Range, TextEdit } from 'vscode-languageserver-protocol'; import type { AstNode, CstNode, Properties } from '../syntax-tree.js'; import type { MaybePromise } from '../utils/promise-utils.js'; import type { Stream } from '../utils/stream.js'; -import type { LangiumDocument } from '../workspace/documents.js'; +import type { LangiumDocument, TextDocument } from '../workspace/documents.js'; import { findNodeForKeyword, findNodesForKeyword, findNodeForProperty, findNodesForProperty } from '../utils/grammar-utils.js'; import { isCompositeCstNode, isLeafCstNode } from '../syntax-tree.js'; import { streamAllContents } from '../utils/ast-utils.js'; diff --git a/packages/langium/src/lsp/language-server.ts b/packages/langium/src/lsp/language-server.ts index 4ead30527..6df5f8bfa 100644 --- a/packages/langium/src/lsp/language-server.ts +++ b/packages/langium/src/lsp/language-server.ts @@ -28,7 +28,7 @@ import type { TypeHierarchySubtypesParams, TypeHierarchySupertypesParams } from 'vscode-languageserver'; -import { DidChangeConfigurationNotification, Emitter, LSPErrorCodes, ResponseError, TextDocumentSyncKind } from 'vscode-languageserver'; +import { DidChangeConfigurationNotification, Emitter, LSPErrorCodes, ResponseError, TextDocumentSyncKind } from 'vscode-languageserver-protocol'; import { eagerLoad } from '../dependency-injection.js'; import type { LangiumCoreServices } from '../services.js'; import { isOperationCancelled } from '../utils/promise-utils.js'; diff --git a/packages/langium/src/lsp/lsp-services.ts b/packages/langium/src/lsp/lsp-services.ts index c12bbad3f..21b32f9a7 100644 --- a/packages/langium/src/lsp/lsp-services.ts +++ b/packages/langium/src/lsp/lsp-services.ts @@ -5,8 +5,8 @@ ******************************************************************************/ import type { Connection, TextDocuments } from 'vscode-languageserver'; -import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { DeepPartial, LangiumCoreServices, LangiumSharedCoreServices } from '../services.js'; +import type { TextDocument } from '../workspace/documents.js'; import type { CallHierarchyProvider } from './call-hierarchy-provider.js'; import type { CodeActionProvider } from './code-action.js'; import type { CodeLensProvider } from './code-lens-provider.js'; diff --git a/packages/langium/src/lsp/rename-provider.ts b/packages/langium/src/lsp/rename-provider.ts index 0433397e0..551f1d4ec 100644 --- a/packages/langium/src/lsp/rename-provider.ts +++ b/packages/langium/src/lsp/rename-provider.ts @@ -4,7 +4,7 @@ * terms of the MIT License, which is available in the project root. ******************************************************************************/ -import type { CancellationToken, Position, Range, RenameParams, TextDocumentPositionParams, WorkspaceEdit } from 'vscode-languageserver'; +import type { CancellationToken, Position, Range, RenameParams, TextDocumentPositionParams, WorkspaceEdit } from 'vscode-languageserver-protocol'; import type { GrammarConfig } from '../languages/grammar-config.js'; import type { NameProvider } from '../references/name-provider.js'; import type { References } from '../references/references.js'; @@ -12,7 +12,7 @@ import type { LangiumServices } from './lsp-services.js'; import type { CstNode } from '../syntax-tree.js'; import type { MaybePromise } from '../utils/promise-utils.js'; import type { LangiumDocument } from '../workspace/documents.js'; -import { TextEdit } from 'vscode-languageserver'; +import { TextEdit } from 'vscode-languageserver-types'; import { isNamed } from '../references/name-provider.js'; import { findDeclarationNodeAtOffset } from '../utils/cst-utils.js'; diff --git a/packages/langium/src/test/langium-test.ts b/packages/langium/src/test/langium-test.ts index b446eae6b..b523c3f8e 100644 --- a/packages/langium/src/test/langium-test.ts +++ b/packages/langium/src/test/langium-test.ts @@ -4,17 +4,16 @@ * terms of the MIT License, which is available in the project root. ******************************************************************************/ -import type { CompletionItem, CompletionList, Diagnostic, DocumentSymbol, FoldingRange, FormattingOptions, Range, ReferenceParams, SemanticTokensParams, SemanticTokenTypes, TextDocumentIdentifier, TextDocumentPositionParams, WorkspaceSymbol } from 'vscode-languageserver'; +import type { CompletionItem, CompletionList, Diagnostic, DocumentSymbol, FoldingRange, FormattingOptions, Range, ReferenceParams, SemanticTokensParams, SemanticTokenTypes, TextDocumentIdentifier, TextDocumentPositionParams, WorkspaceSymbol } from 'vscode-languageserver-protocol'; import type { LangiumCoreServices, LangiumSharedCoreServices } from '../services.js'; import type { AstNode, CstNode, Properties } from '../syntax-tree.js'; -import type { LangiumDocument } from '../workspace/documents.js'; +import { type LangiumDocument, TextDocument } from '../workspace/documents.js'; import type { BuildOptions } from '../workspace/document-builder.js'; -import { DiagnosticSeverity, MarkupContent } from 'vscode-languageserver'; +import { DiagnosticSeverity, MarkupContent } from 'vscode-languageserver-types'; import { escapeRegExp } from '../utils/regexp-utils.js'; import { URI } from '../utils/uri-utils.js'; import { findNodeForProperty } from '../utils/grammar-utils.js'; import { SemanticTokensDecoder } from '../lsp/semantic-token-provider.js'; -import { TextDocument } from 'vscode-languageserver-textdocument'; import * as assert from 'node:assert'; import { stream } from '../utils/stream.js'; import type { AsyncDisposable } from '../utils/disposable.js'; diff --git a/packages/langium/src/workspace/documents.ts b/packages/langium/src/workspace/documents.ts index f7bdd29d5..ffe3aec92 100644 --- a/packages/langium/src/workspace/documents.ts +++ b/packages/langium/src/workspace/documents.ts @@ -4,18 +4,27 @@ * terms of the MIT License, which is available in the project root. ******************************************************************************/ +/** + * Re-export 'TextDocument' from 'vscode-languageserver-textdocument' for convenience, + * including both type _and_ symbol (namespace), as we here and there also refer to the symbol, + * the overhead is very small, just a few kilobytes. + * Everything else of that package (at the time contributing) is also defined + * in 'vscode-languageserver-protocol' or 'vscode-languageserver-types'. + */ +export { TextDocument } from 'vscode-languageserver-textdocument'; + import { CancellationToken } from 'vscode-jsonrpc'; -import { TextDocument } from 'vscode-languageserver-textdocument'; import type { Diagnostic, Range } from 'vscode-languageserver-types'; +import type { FileSystemProvider } from './file-system-provider.js'; import type { ParseResult } from '../parser/langium-parser.js'; import type { ServiceRegistry } from '../service-registry.js'; import type { LangiumSharedCoreServices } from '../services.js'; import type { AstNode, AstNodeDescription, Mutable, Reference } from '../syntax-tree.js'; import type { MultiMap } from '../utils/collections.js'; import type { Stream } from '../utils/stream.js'; +import { TextDocument } from './documents.js'; import { stream } from '../utils/stream.js'; import { URI } from '../utils/uri-utils.js'; -import type { FileSystemProvider } from './file-system-provider.js'; /** * A Langium document holds the parse result (AST and CST) and any additional state that is derived diff --git a/packages/langium/test/workspace/document-builder.test.ts b/packages/langium/test/workspace/document-builder.test.ts index 93a37e93f..a332b3780 100644 --- a/packages/langium/test/workspace/document-builder.test.ts +++ b/packages/langium/test/workspace/document-builder.test.ts @@ -5,12 +5,11 @@ ******************************************************************************/ import type { AstNode, Reference, ValidationChecks } from 'langium'; +import { DocumentState, TextDocument, URI, isOperationCancelled } from 'langium'; +import { createServicesForGrammar } from 'langium/grammar'; +import { setTextDocument } from 'langium/test'; import { describe, expect, test } from 'vitest'; import { CancellationTokenSource } from 'vscode-languageserver'; -import { TextDocument } from 'vscode-languageserver-textdocument'; -import { setTextDocument } from 'langium/test'; -import { isOperationCancelled, DocumentState, URI } from 'langium'; -import { createServicesForGrammar } from 'langium/grammar'; describe('DefaultDocumentBuilder', () => { async function createServices() { diff --git a/packages/langium/test/workspace/document-factory.test.ts b/packages/langium/test/workspace/document-factory.test.ts index bb1c52129..7e8c5c126 100644 --- a/packages/langium/test/workspace/document-factory.test.ts +++ b/packages/langium/test/workspace/document-factory.test.ts @@ -7,8 +7,7 @@ import type { Grammar } from 'langium'; import type { LangiumServices } from 'langium/lsp'; import { describe, expect, test } from 'vitest'; -import { TextDocument } from 'vscode-languageserver-textdocument'; -import { DocumentState, EmptyFileSystem } from 'langium'; +import { DocumentState, EmptyFileSystem, TextDocument } from 'langium'; import { createLangiumGrammarServices } from 'langium/grammar'; import { setTextDocument } from 'langium/test'; import { CancellationToken } from 'vscode-languageserver';