Skip to content

Commit

Permalink
post-rebase corrections, works in a few langium-sprotty diffs too
Browse files Browse the repository at this point in the history
  • Loading branch information
montymxb committed Dec 14, 2023
1 parent 2ea63ab commit 09e88e3
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions examples/domainmodel/test/refs-index.test.ts
Expand Up @@ -30,9 +30,9 @@ describe('Cross references indexed after affected process', () => {
'entity SuperEntity {}'
)
);
await shared.shared.workspace.DocumentBuilder.update([superDoc.uri], []);
await shared.workspace.DocumentBuilder.update([superDoc.uri], []);

const updatedSuperDoc = await shared.workspace.LangiumDocuments.getOrCreateDocument(superDoc.uri);
const updatedSuperDoc = shared.workspace.LangiumDocuments.getOrCreateDocument(superDoc.uri);
const superEntity = (updatedSuperDoc.parseResult.value as Domainmodel).elements[0];
allRefs = await getReferences(superEntity);
expect(allRefs.length).toEqual(1); // re-linked
Expand Down
3 changes: 2 additions & 1 deletion packages/langium-sprotty/src/default-module.ts
Expand Up @@ -4,7 +4,8 @@
* terms of the MIT License, which is available in the project root.
******************************************************************************/

import type { Module, PartialLangiumServices } from 'langium';
import type { Module } from 'langium';
import type { PartialLangiumServices } from 'langium/lsp';
import type { DiagramOptions } from 'sprotty-protocol';
import type { LangiumSprottyServices, LangiumSprottySharedServices, SprottyDefaultServices, SprottySharedServices } from './sprotty-services.js';
import { DiagramServer } from 'sprotty-protocol';
Expand Down
2 changes: 1 addition & 1 deletion packages/langium-sprotty/src/position-tracker.ts
Expand Up @@ -8,7 +8,7 @@ import type { LangiumDocument, MaybePromise } from 'langium';
import type { Position } from 'vscode-languageserver';
import type { DocumentHighlight, DocumentHighlightParams } from 'vscode-languageserver';
import type { LangiumSprottyServices } from './sprotty-services.js';
import { DefaultDocumentHighlightProvider } from 'langium';
import { DefaultDocumentHighlightProvider } from 'langium/lsp';

/**
* This service provides access to the user's current cursor position.
Expand Down
5 changes: 2 additions & 3 deletions packages/langium-sprotty/src/sprotty-services.ts
Expand Up @@ -4,8 +4,7 @@
* terms of the MIT License, which is available in the project root.
******************************************************************************/

import type { LangiumCoreServices } from 'langium';
import type { LangiumSharedServices } from 'langium/lsp';
import type { LangiumServices, LangiumSharedServices } from 'langium/lsp';
import type { DiagramOptions, DiagramServer, DiagramServices } from 'sprotty-protocol';
import type { ServerActionHandlerRegistry } from 'sprotty-protocol/lib/action-handler.js';
import type { DiagnosticMarkerProvider } from './diagnostic-marker-provider.js';
Expand Down Expand Up @@ -35,7 +34,7 @@ export type SprottyDefaultServices = {
/**
* Extension of the `LangiumServices` with the diagram-related services.
*/
export type LangiumSprottyServices = LangiumCoreServices & SprottyDiagramServices & SprottyDefaultServices & {
export type LangiumSprottyServices = LangiumServices & SprottyDiagramServices & SprottyDefaultServices & {
shared: LangiumSprottySharedServices
}

Expand Down
4 changes: 2 additions & 2 deletions packages/langium-sprotty/test/trace-provider.test.ts
Expand Up @@ -5,7 +5,7 @@
******************************************************************************/

import type { AstNode } from 'langium';
import type { TracedModelElement } from 'langium-sprotty';
import type { LangiumSprottyServices, LangiumSprottySharedServices, TracedModelElement } from 'langium-sprotty';
import type { SModelRoot } from 'sprotty-protocol';
import { beforeEach, describe, expect, test } from 'vitest';
import { createServicesForGrammar } from 'langium/grammar';
Expand All @@ -22,7 +22,7 @@ describe('DefaultTraceProvider', async () => {
hidden terminal WS: /\\s+/;
terminal ID: /[_a-zA-Z][\\w_]*/;
`;
const services = await createServicesForGrammar({
const services = await createServicesForGrammar<LangiumSprottyServices, LangiumSprottySharedServices>({
grammar,
module: SprottyDefaultModule,
sharedModule: SprottySharedModule
Expand Down
2 changes: 1 addition & 1 deletion packages/langium/src/lsp/document-update-handler.ts
Expand Up @@ -6,7 +6,7 @@

import type { DidChangeWatchedFilesParams, DidChangeWatchedFilesRegistrationOptions, TextDocumentChangeEvent } from 'vscode-languageserver';
import type { TextDocument } from 'vscode-languageserver-textdocument';
import type { LangiumSharedServices } from '../services.js';
import type { LangiumSharedServices } from './lsp-services.js';
import type { WorkspaceLock } from '../workspace/workspace-lock.js';
import type { DocumentBuilder } from '../workspace/document-builder.js';
import { DidChangeWatchedFilesNotification, FileChangeType } from 'vscode-languageserver';
Expand Down
7 changes: 7 additions & 0 deletions packages/langium/src/lsp/language-server.ts
Expand Up @@ -225,8 +225,15 @@ export function startLanguageServer(services: LangiumSharedServices): void {
connection.listen();
}

/**
* Adds a handler for document updates when content changes, or watch catches a change.
* In the case there is no handler service registered, this function does nothing.
*/
export function addDocumentUpdateHandler(connection: Connection, services: LangiumSharedServices): void {
const handler = services.lsp.DocumentUpdateHandler;
if (!handler) {
return;
}
const documents = services.workspace.TextDocuments;
documents.onDidChangeContent(change => handler.didChangeContent(change));
connection.onDidChangeWatchedFiles(params => handler.didChangeWatchedFiles(params));
Expand Down
3 changes: 2 additions & 1 deletion packages/langium/test/workspace/document-factory.test.ts
Expand Up @@ -4,7 +4,8 @@
* terms of the MIT License, which is available in the project root.
******************************************************************************/

import type { Grammar, LangiumServices } from 'langium';
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';
Expand Down

0 comments on commit 09e88e3

Please sign in to comment.