Skip to content

Commit

Permalink
Add support for Delta documents
Browse files Browse the repository at this point in the history
  • Loading branch information
ddaspit committed Dec 13, 2024
1 parent 920740b commit bfd11a4
Show file tree
Hide file tree
Showing 49 changed files with 2,247 additions and 439 deletions.
100 changes: 98 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/core/src/diagnostic/diagnostic-fix.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TextEdit } from '../common/text-edit';
import { Diagnostic } from './diagnostic';

export interface DiagnosticFix {
export interface DiagnosticFix<T = TextEdit> {
title: string;
diagnostic: Diagnostic;
isPreferred?: boolean;
edits: TextEdit[];
edits: T[];
}
5 changes: 3 additions & 2 deletions packages/core/src/diagnostic/diagnostic-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Observable } from 'rxjs';

import { TextEdit } from '../common/text-edit';
import { Diagnostic } from './diagnostic';
import { DiagnosticFix } from './diagnostic-fix';

Expand All @@ -9,10 +10,10 @@ export interface DiagnosticsChanged {
diagnostics: Diagnostic[];
}

export interface DiagnosticProvider {
export interface DiagnosticProvider<T = TextEdit> {
readonly id: string;
readonly diagnosticsChanged$: Observable<DiagnosticsChanged>;
init(): Promise<void>;
getDiagnostics(uri: string): Promise<Diagnostic[]>;
getDiagnosticFixes(uri: string, diagnostic: Diagnostic): Promise<DiagnosticFix[]>;
getDiagnosticFixes(uri: string, diagnostic: Diagnostic): Promise<DiagnosticFix<T>[]>;
}
35 changes: 35 additions & 0 deletions packages/core/src/document/document-accessor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Observable } from 'rxjs';

import { Document } from './document';

export interface DocumentCreated<T extends Document> {
document: T;
}

export interface DocumentClosed {
uri: string;
}

export interface DocumentOpened<T extends Document> {
document: T;
}

export interface DocumentDeleted {
uri: string;
}

export interface DocumentChanged<T extends Document> {
document: T;
}

export interface DocumentAccessor<T extends Document = Document> {
readonly created$: Observable<DocumentCreated<T>>;
readonly closed$: Observable<DocumentClosed>;
readonly opened$: Observable<DocumentOpened<T>>;
readonly deleted$: Observable<DocumentDeleted>;
readonly changed$: Observable<DocumentChanged<T>>;

get(uri: string): Promise<T | undefined>;
all(): Promise<T[]>;
active(): Promise<T[]>;
}
13 changes: 4 additions & 9 deletions packages/core/src/document/document-factory.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Range } from '../common/range';
import { Document } from './document';
import { TextDocumentChange } from './text-document-change';

export interface DocumentChange {
range?: Range;
text: string;
}

export interface DocumentFactory<T extends Document> {
create(uri: string, format: string, version: number, content: string): T;
update(document: T, changes: readonly DocumentChange[], version: number): T;
export interface DocumentFactory<TDoc extends Document = Document, TChange = TextDocumentChange> {
create(uri: string, format: string, version: number, content: string): TDoc;
update(document: TDoc, changes: readonly TChange[], version: number): TDoc;
}
Loading

0 comments on commit bfd11a4

Please sign in to comment.