1 import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';
2 import { JSONSchema } from './jsonSchema';
3 import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions as LSPFormattingOptions, DefinitionLink } from 'vscode-languageserver-types';
4 import { TextDocument } from 'vscode-languageserver-textdocument';
5 export { TextDocument, Range, TextEdit, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString };
7 * Error codes used by diagnostics
9 export declare enum ErrorCode {
11 EnumValueMismatch = 1,
13 UnexpectedEndOfComment = 257,
14 UnexpectedEndOfString = 258,
15 UnexpectedEndOfNumber = 259,
17 InvalidEscapeCharacter = 261,
18 InvalidCharacter = 262,
19 PropertyExpected = 513,
23 CommaOrCloseBacketExpected = 517,
24 CommaOrCloseBraceExpected = 518,
27 CommentNotPermitted = 521,
28 SchemaResolveError = 768
30 export declare type ASTNode = ObjectASTNode | PropertyASTNode | ArrayASTNode | StringASTNode | NumberASTNode | BooleanASTNode | NullASTNode;
31 export interface BaseASTNode {
32 readonly type: 'object' | 'array' | 'property' | 'string' | 'number' | 'boolean' | 'null';
33 readonly parent?: ASTNode;
34 readonly offset: number;
35 readonly length: number;
36 readonly children?: ASTNode[];
37 readonly value?: string | boolean | number | null;
39 export interface ObjectASTNode extends BaseASTNode {
40 readonly type: 'object';
41 readonly properties: PropertyASTNode[];
42 readonly children: ASTNode[];
44 export interface PropertyASTNode extends BaseASTNode {
45 readonly type: 'property';
46 readonly keyNode: StringASTNode;
47 readonly valueNode?: ASTNode;
48 readonly colonOffset?: number;
49 readonly children: ASTNode[];
51 export interface ArrayASTNode extends BaseASTNode {
52 readonly type: 'array';
53 readonly items: ASTNode[];
54 readonly children: ASTNode[];
56 export interface StringASTNode extends BaseASTNode {
57 readonly type: 'string';
58 readonly value: string;
60 export interface NumberASTNode extends BaseASTNode {
61 readonly type: 'number';
62 readonly value: number;
63 readonly isInteger: boolean;
65 export interface BooleanASTNode extends BaseASTNode {
66 readonly type: 'boolean';
67 readonly value: boolean;
69 export interface NullASTNode extends BaseASTNode {
70 readonly type: 'null';
73 export interface MatchingSchema {
77 export interface LanguageSettings {
79 * If set, the validator will return syntax and semantic errors.
83 * Defines whether comments are allowed or not. If set to false, comments will be reported as errors.
84 * DocumentLanguageSettings.allowComments will override this setting.
86 allowComments?: boolean;
88 * A list of known schemas and/or associations of schemas to file names.
90 schemas?: SchemaConfiguration[];
92 export declare type SeverityLevel = 'error' | 'warning' | 'ignore';
93 export interface DocumentLanguageSettings {
95 * The severity of reported comments. If not set, 'LanguageSettings.allowComments' defines whether comments are ignored or reported as errors.
97 comments?: SeverityLevel;
99 * The severity of reported trailing commas. If not set, trailing commas will be reported as errors.
101 trailingCommas?: SeverityLevel;
103 * The severity of problems from schema validation. If set to 'ignore', schema validation will be skipped. If not set, 'warning' is used.
105 schemaValidation?: SeverityLevel;
107 * The severity of problems that occurred when resolving and loading schemas. If set to 'ignore', schema resolving problems are not reported. If not set, 'warning' is used.
109 schemaRequest?: SeverityLevel;
111 export interface SchemaConfiguration {
113 * The URI of the schema, which is also the identifier of the schema.
117 * A list of file path glob patterns that are associated to the schema. The '*' and '**' wildcards can be used.
118 * Exclusion patterns starting with '!'.
119 * For example: '*.schema.json', 'package.json', '!foo*.schema.json', 'foo/**\/BADRESP.json'.
120 * A match succeeds when there is at least one pattern matching and last matching patter`n does not start with '!'.
122 fileMatch?: string[];
124 * The schema for the given URI.
125 * If no schema is provided, the schema will be fetched with the schema request service (if available).
129 export interface WorkspaceContextService {
130 resolveRelativePath(relativePath: string, resource: string): string;
133 * The schema request service is used to fetch schemas. If successful, returns a resolved promise with the content of the schema.
134 * In case of an error, returns a rejected promise with a displayable error string.
136 export interface SchemaRequestService {
137 (uri: string): Thenable<string>;
139 export interface PromiseConstructor {
141 * Creates a new Promise.
142 * @param executor A callback used to initialize the promise. This callback is passed two arguments:
143 * a resolve callback used resolve the promise with a value or the result of another promise,
144 * and a reject callback used to reject the promise with a provided reason or error.
146 new <T>(executor: (resolve: (value?: T | Thenable<T | undefined>) => void, reject: (reason?: any) => void) => void): Thenable<T | undefined>;
148 * Creates a Promise that is resolved with an array of results when all of the provided Promises
149 * resolve, or rejected when any Promise is rejected.
150 * @param values An array of Promises.
151 * @returns A new Promise.
153 all<T>(values: Array<T | Thenable<T>>): Thenable<T[]>;
155 * Creates a new rejected promise for the provided reason.
156 * @param reason The reason the promise was rejected.
157 * @returns A new rejected Promise.
159 reject<T>(reason: any): Thenable<T>;
161 * Creates a new resolved promise for the provided value.
162 * @param value A promise.
163 * @returns A promise whose internal state matches the provided promise.
165 resolve<T>(value: T | Thenable<T>): Thenable<T>;
167 export interface Thenable<R> {
169 * Attaches callbacks for the resolution and/or rejection of the Promise.
170 * @param onfulfilled The callback to execute when the Promise is resolved.
171 * @param onrejected The callback to execute when the Promise is rejected.
172 * @returns A Promise for the completion of which ever callback is executed.
174 then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
175 then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
177 export interface LanguageServiceParams {
179 * The schema request service is used to fetch schemas from a URI. The provider returns the schema file content, or,
180 * in case of an error, a displayable error string
182 schemaRequestService?: SchemaRequestService;
184 * The workspace context is used to resolve relative paths for relative schema references.
186 workspaceContext?: WorkspaceContextService;
188 * An optional set of completion and hover participants.
190 contributions?: JSONWorkerContribution[];
192 * A promise constructor. If not set, the ES5 Promise will be used.
194 promiseConstructor?: PromiseConstructor;
196 * Describes the LSP capabilities the client supports.
198 clientCapabilities?: ClientCapabilities;
201 * Describes what LSP capabilities the client supports
203 export interface ClientCapabilities {
205 * The text document client capabilities
209 * Capabilities specific to completions.
213 * The client supports the following `CompletionItem` specific
218 * Client supports the follow content formats for the documentation
219 * property. The order describes the preferred format of the client.
221 documentationFormat?: MarkupKind[];
223 * The client supports commit characters on a completion item.
225 commitCharactersSupport?: boolean;
229 * Capabilities specific to hovers.
233 * Client supports the follow content formats for the content
234 * property. The order describes the preferred format of the client.
236 contentFormat?: MarkupKind[];
240 export declare namespace ClientCapabilities {
241 const LATEST: ClientCapabilities;
243 export interface FoldingRangesContext {
245 * The maximal number of ranges returned.
249 * Called when the result was cropped.
251 onRangeLimitExceeded?: (uri: string) => void;
253 export interface DocumentSymbolsContext {
255 * The maximal number of document symbols returned.
257 resultLimit?: number;
259 * Called when the result was cropped.
261 onResultLimitExceeded?: (uri: string) => void;
263 export interface ColorInformationContext {
265 * The maximal number of color informations returned.
267 resultLimit?: number;
269 * Called when the result was cropped.
271 onResultLimitExceeded?: (uri: string) => void;
273 export interface FormattingOptions extends LSPFormattingOptions {
274 insertFinalNewline?: boolean;