Skip to content

Commit

Permalink
Export IJSONWorker type
Browse files Browse the repository at this point in the history
  • Loading branch information
mevisioam committed Dec 13, 2023
1 parent c1dd3e1 commit 9821483
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/language/json/monaco.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/

import * as mode from './jsonMode';
import { Emitter, IEvent, languages, Uri } from '../../fillers/monaco-editor-core';
import type { JSONWorker } from './jsonWorker';
import { Emitter, IEvent, languages, Uri } from 'monaco-editor-core';
import * as jsonService from 'vscode-json-languageservice';

// --- JSON configuration and defaults ---------

Expand Down Expand Up @@ -198,9 +198,27 @@ export const jsonDefaults: LanguageServiceDefaults = new LanguageServiceDefaults
modeConfigurationDefault
);

export const getWorker = (): Promise<(...uris: Uri[]) => Promise<JSONWorker>> => {
return getMode().then((mode) => mode.getWorker());
};
export interface IJSONWorker {
findDocumentSymbols(uri: string): Promise<jsonService.SymbolInformation[]>;
getColorPresentations(
uri: string,
color: jsonService.Color,
range: jsonService.Range
): Promise<jsonService.ColorPresentation[]>;
getFoldingRanges(
uri: string,
context?: { rangeLimit?: number }
): Promise<jsonService.FoldingRange[]>;
getSelectionRanges(
uri: string,
positions: jsonService.Position[]
): Promise<jsonService.SelectionRange[]>;
parseJSONDocument(uri: string): Promise<jsonService.JSONDocument | null>;
getMatchingSchemas(uri: string): Promise<jsonService.MatchingSchema[]>;
}

export const getWorker = (): Promise<(...uris: Uri[]) => Promise<IJSONWorker>> =>
getMode().then((mode) => mode.getWorker());

// export to the global based API
(<any>languages).json = { jsonDefaults, getWorker };
Expand Down

0 comments on commit 9821483

Please sign in to comment.