Skip to content

Commit

Permalink
added an export * from 'vscode-languageserver-textdocument'; to 'do…
Browse files Browse the repository at this point in the history
…cuments.ts for convenience

* the overhead is just very few kilobytes
* changed all imports of 'TextDocument' to point to langium
  • Loading branch information
sailingKieler committed Feb 13, 2024
1 parent 08d9bad commit 06bd069
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 27 deletions.
3 changes: 1 addition & 2 deletions examples/domainmodel/test/refs-index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
7 changes: 3 additions & 4 deletions packages/langium/src/lsp/completion/completion-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/langium/src/lsp/default-lsp-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/langium/src/lsp/document-update-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
5 changes: 2 additions & 3 deletions packages/langium/src/lsp/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/langium/src/lsp/language-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/langium/src/lsp/lsp-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions packages/langium/src/lsp/rename-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* 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';
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';

Expand Down
7 changes: 3 additions & 4 deletions packages/langium/src/test/langium-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
13 changes: 11 additions & 2 deletions packages/langium/src/workspace/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions packages/langium/test/workspace/document-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions packages/langium/test/workspace/document-factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 06bd069

Please sign in to comment.