modes.ts 38.1 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

6 7 8
import { CancellationToken } from 'vs/base/common/cancellation';
import { Color } from 'vs/base/common/color';
import { Event } from 'vs/base/common/event';
9
import { IMarkdownString } from 'vs/base/common/htmlContent';
J
Johannes Rieken 已提交
10
import { IDisposable } from 'vs/base/common/lifecycle';
11
import { isObject } from 'vs/base/common/types';
12
import { URI } from 'vs/base/common/uri';
13 14 15
import { Position } from 'vs/editor/common/core/position';
import { IRange, Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
A
Tweaks  
Alex Dima 已提交
16
import { TokenizationResult, TokenizationResult2 } from 'vs/editor/common/core/token';
17
import * as model from 'vs/editor/common/model';
A
Alex Dima 已提交
18
import { LanguageFeatureRegistry } from 'vs/editor/common/modes/languageFeatureRegistry';
19
import { TokenizationRegistryImpl } from 'vs/editor/common/modes/tokenizationRegistry';
20
import { IMarkerData } from 'vs/platform/markers/common/markers';
E
Erich Gamma 已提交
21

22
/**
23
 * Open ended enum at runtime
24 25
 * @internal
 */
A
Alex Dima 已提交
26 27 28 29 30 31 32 33 34
export const enum LanguageId {
	Null = 0,
	PlainText = 1
}

/**
 * @internal
 */
export class LanguageIdentifier {
A
Alex Dima 已提交
35 36 37 38

	/**
	 * A string identifier. Unique across languages. e.g. 'javascript'.
	 */
39
	public readonly language: string;
A
Alex Dima 已提交
40 41 42 43 44

	/**
	 * A numeric identifier. Unique across languages. e.g. 5
	 * Will vary at runtime based on registration order, etc.
	 */
45
	public readonly id: LanguageId;
A
Alex Dima 已提交
46

A
Alex Dima 已提交
47 48 49
	constructor(language: string, id: LanguageId) {
		this.language = language;
		this.id = id;
A
Alex Dima 已提交
50
	}
E
Erich Gamma 已提交
51 52
}

A
Alex Dima 已提交
53 54
/**
 * A mode. Will soon be obsolete.
A
Alex Dima 已提交
55
 * @internal
A
Alex Dima 已提交
56
 */
E
Erich Gamma 已提交
57 58 59 60
export interface IMode {

	getId(): string;

A
Alex Dima 已提交
61 62
	getLanguageIdentifier(): LanguageIdentifier;

E
Erich Gamma 已提交
63 64
}

A
Alex Dima 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77
/**
 * A font style. Values are 2^x such that a bit mask can be used.
 * @internal
 */
export const enum FontStyle {
	NotSet = -1,
	None = 0,
	Italic = 1,
	Bold = 2,
	Underline = 4
}

/**
78
 * Open ended enum at runtime
A
Alex Dima 已提交
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
 * @internal
 */
export const enum ColorId {
	None = 0,
	DefaultForeground = 1,
	DefaultBackground = 2
}

/**
 * A standard token type. Values are 2^x such that a bit mask can be used.
 * @internal
 */
export const enum StandardTokenType {
	Other = 0,
	Comment = 1,
	String = 2,
	RegEx = 4
}

A
Alex Dima 已提交
98 99 100 101 102 103 104
/**
 * Helpers to manage the "collapsed" metadata of an entire StackElement stack.
 * The following assumptions have been made:
 *  - languageId < 256 => needs 8 bits
 *  - unique color count < 512 => needs 9 bits
 *
 * The binary format is:
A
Alex Dima 已提交
105 106 107 108 109 110 111 112 113 114 115 116
 * - -------------------------------------------
 *     3322 2222 2222 1111 1111 1100 0000 0000
 *     1098 7654 3210 9876 5432 1098 7654 3210
 * - -------------------------------------------
 *     xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
 *     bbbb bbbb bfff ffff ffFF FTTT LLLL LLLL
 * - -------------------------------------------
 *  - L = LanguageId (8 bits)
 *  - T = StandardTokenType (3 bits)
 *  - F = FontStyle (3 bits)
 *  - f = foreground color (9 bits)
 *  - b = background color (9 bits)
A
Alex Dima 已提交
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
 *
 * @internal
 */
export const enum MetadataConsts {
	LANGUAGEID_MASK = 0b00000000000000000000000011111111,
	TOKEN_TYPE_MASK = 0b00000000000000000000011100000000,
	FONT_STYLE_MASK = 0b00000000000000000011100000000000,
	FOREGROUND_MASK = 0b00000000011111111100000000000000,
	BACKGROUND_MASK = 0b11111111100000000000000000000000,

	LANGUAGEID_OFFSET = 0,
	TOKEN_TYPE_OFFSET = 8,
	FONT_STYLE_OFFSET = 11,
	FOREGROUND_OFFSET = 14,
	BACKGROUND_OFFSET = 23
}

A
Alex Dima 已提交
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
/**
 * @internal
 */
export class TokenMetadata {

	public static getLanguageId(metadata: number): LanguageId {
		return (metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET;
	}

	public static getTokenType(metadata: number): StandardTokenType {
		return (metadata & MetadataConsts.TOKEN_TYPE_MASK) >>> MetadataConsts.TOKEN_TYPE_OFFSET;
	}

	public static getFontStyle(metadata: number): FontStyle {
		return (metadata & MetadataConsts.FONT_STYLE_MASK) >>> MetadataConsts.FONT_STYLE_OFFSET;
	}

	public static getForeground(metadata: number): ColorId {
		return (metadata & MetadataConsts.FOREGROUND_MASK) >>> MetadataConsts.FOREGROUND_OFFSET;
	}

	public static getBackground(metadata: number): ColorId {
		return (metadata & MetadataConsts.BACKGROUND_MASK) >>> MetadataConsts.BACKGROUND_OFFSET;
	}

	public static getClassNameFromMetadata(metadata: number): string {
		let foreground = this.getForeground(metadata);
		let className = 'mtk' + foreground;

		let fontStyle = this.getFontStyle(metadata);
		if (fontStyle & FontStyle.Italic) {
			className += ' mtki';
		}
		if (fontStyle & FontStyle.Bold) {
			className += ' mtkb';
		}
		if (fontStyle & FontStyle.Underline) {
			className += ' mtku';
		}

		return className;
	}

	public static getInlineStyleFromMetadata(metadata: number, colorMap: string[]): string {
		const foreground = this.getForeground(metadata);
		const fontStyle = this.getFontStyle(metadata);

		let result = `color: ${colorMap[foreground]};`;
		if (fontStyle & FontStyle.Italic) {
			result += 'font-style: italic;';
		}
		if (fontStyle & FontStyle.Bold) {
			result += 'font-weight: bold;';
		}
		if (fontStyle & FontStyle.Underline) {
			result += 'text-decoration: underline;';
		}
		return result;
	}
}

195 196 197
/**
 * @internal
 */
E
Erich Gamma 已提交
198 199
export interface ITokenizationSupport {

J
Johannes Rieken 已提交
200
	getInitialState(): IState;
E
Erich Gamma 已提交
201 202

	// add offsetDelta to each of the returned indices
A
Alex Dima 已提交
203
	tokenize(line: string, state: IState, offsetDelta: number): TokenizationResult;
A
Alex Dima 已提交
204

A
Tweaks  
Alex Dima 已提交
205
	tokenize2(line: string, state: IState, offsetDelta: number): TokenizationResult2;
E
Erich Gamma 已提交
206 207
}

A
Alex Dima 已提交
208 209 210 211 212
/**
 * The state of the tokenizer between two lines.
 * It is useful to store flags such as in multiline comment, etc.
 * The model will clone the previous line's state and pass it in to tokenize the next line.
 */
A
Alex Dima 已提交
213 214 215
export interface IState {
	clone(): IState;
	equals(other: IState): boolean;
A
Alex Dima 已提交
216 217
}

218 219 220 221 222 223 224 225
/**
 * A provider result represents the values a provider, like the [`HoverProvider`](#HoverProvider),
 * may return. For once this is the actual result type `T`, like `Hover`, or a thenable that resolves
 * to that type `T`. In addition, `null` and `undefined` can be returned - either directly or from a
 * thenable.
 */
export type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;

E
Erich Gamma 已提交
226
/**
227 228
 * A hover represents additional information for a symbol or word. Hovers are
 * rendered in a tooltip-like widget.
E
Erich Gamma 已提交
229
 */
230
export interface Hover {
231 232 233
	/**
	 * The contents of this hover.
	 */
234
	contents: IMarkdownString[];
235 236 237 238 239 240

	/**
	 * The range to which this hover applies. When missing, the
	 * editor will use the range at the current position or the
	 * current position itself.
	 */
241
	range?: IRange;
E
Erich Gamma 已提交
242
}
243

A
Alex Dima 已提交
244 245
/**
 * The hover provider interface defines the contract between extensions and
G
Greg Van Liew 已提交
246
 * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
A
Alex Dima 已提交
247
 */
A
Alex Dima 已提交
248
export interface HoverProvider {
A
Alex Dima 已提交
249 250 251 252 253
	/**
	 * Provide a hover for the given position and document. Multiple hovers at the same
	 * position will be merged by the editor. A hover can have a range which defaults
	 * to the word range at the position when omitted.
	 */
254
	provideHover(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Hover>;
E
Erich Gamma 已提交
255 256
}

257
export const enum CompletionItemKind {
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
	Method,
	Function,
	Constructor,
	Field,
	Variable,
	Class,
	Struct,
	Interface,
	Module,
	Property,
	Event,
	Operator,
	Unit,
	Value,
	Constant,
	Enum,
	EnumMember,
	Keyword,
	Text,
	Color,
	File,
	Reference,
	Customcolor,
	Folder,
	TypeParameter,
J
Johannes Rieken 已提交
283
	Snippet, // <- highest value (used for compare!)
284 285 286 287 288
}

/**
 * @internal
 */
289
export let completionKindToCssClass = (function () {
290
	let data = Object.create(null);
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
	data[CompletionItemKind.Method] = 'method';
	data[CompletionItemKind.Function] = 'function';
	data[CompletionItemKind.Constructor] = 'constructor';
	data[CompletionItemKind.Field] = 'field';
	data[CompletionItemKind.Variable] = 'variable';
	data[CompletionItemKind.Class] = 'class';
	data[CompletionItemKind.Struct] = 'struct';
	data[CompletionItemKind.Interface] = 'interface';
	data[CompletionItemKind.Module] = 'module';
	data[CompletionItemKind.Property] = 'property';
	data[CompletionItemKind.Event] = 'event';
	data[CompletionItemKind.Operator] = 'operator';
	data[CompletionItemKind.Unit] = 'unit';
	data[CompletionItemKind.Value] = 'value';
	data[CompletionItemKind.Constant] = 'constant';
	data[CompletionItemKind.Enum] = 'enum';
	data[CompletionItemKind.EnumMember] = 'enum-member';
	data[CompletionItemKind.Keyword] = 'keyword';
	data[CompletionItemKind.Snippet] = 'snippet';
	data[CompletionItemKind.Text] = 'text';
	data[CompletionItemKind.Color] = 'color';
	data[CompletionItemKind.File] = 'file';
	data[CompletionItemKind.Reference] = 'reference';
	data[CompletionItemKind.Customcolor] = 'customcolor';
	data[CompletionItemKind.Folder] = 'folder';
	data[CompletionItemKind.TypeParameter] = 'type-parameter';

	return function (kind: CompletionItemKind) {
319 320 321 322 323 324 325
		return data[kind] || 'property';
	};
})();

/**
 * @internal
 */
326
export let completionKindFromLegacyString = (function () {
327
	let data = Object.create(null);
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
	data['method'] = CompletionItemKind.Method;
	data['function'] = CompletionItemKind.Function;
	data['constructor'] = CompletionItemKind.Constructor;
	data['field'] = CompletionItemKind.Field;
	data['variable'] = CompletionItemKind.Variable;
	data['class'] = CompletionItemKind.Class;
	data['struct'] = CompletionItemKind.Struct;
	data['interface'] = CompletionItemKind.Interface;
	data['module'] = CompletionItemKind.Module;
	data['property'] = CompletionItemKind.Property;
	data['event'] = CompletionItemKind.Event;
	data['operator'] = CompletionItemKind.Operator;
	data['unit'] = CompletionItemKind.Unit;
	data['value'] = CompletionItemKind.Value;
	data['constant'] = CompletionItemKind.Constant;
	data['enum'] = CompletionItemKind.Enum;
	data['enum-member'] = CompletionItemKind.EnumMember;
	data['keyword'] = CompletionItemKind.Keyword;
	data['snippet'] = CompletionItemKind.Snippet;
	data['text'] = CompletionItemKind.Text;
	data['color'] = CompletionItemKind.Color;
	data['file'] = CompletionItemKind.File;
	data['reference'] = CompletionItemKind.Reference;
	data['customcolor'] = CompletionItemKind.Customcolor;
	data['folder'] = CompletionItemKind.Folder;
	data['type-parameter'] = CompletionItemKind.TypeParameter;
354 355 356 357 358

	return function (value: string) {
		return data[value] || 'property';
	};
})();
J
Johannes Rieken 已提交
359

360
export const enum CompletionItemInsertTextRule {
361
	/**
362 363
	 * Adjust whitespace/indentation of multiline insert texts to
	 * match the current line indentation.
364
	 */
365
	KeepWhitespace = 0b001,
366 367

	/**
368
	 * `insertText` is a snippet.
369
	 */
370
	InsertAsSnippet = 0b100,
371 372
}

373
/**
374 375
 * A completion item represents a text snippet that is
 * proposed to complete text that is being typed.
376
 */
377
export interface CompletionItem {
378 379 380 381 382
	/**
	 * The label of this completion item. By default
	 * this is also the text that is inserted when selecting
	 * this completion.
	 */
E
Erich Gamma 已提交
383
	label: string;
384 385 386 387 388 389 390 391 392
	/**
	 * The kind of this completion item. Based on the kind
	 * an icon is chosen by the editor.
	 */
	kind: CompletionItemKind;
	/**
	 * A human-readable string with additional information
	 * about this item, like type or symbol information.
	 */
393
	detail?: string;
394 395 396
	/**
	 * A human-readable string that represents a doc-comment.
	 */
397
	documentation?: string | IMarkdownString;
398 399 400 401 402
	/**
	 * A string that should be used when comparing this item
	 * with other items. When `falsy` the [label](#CompletionItem.label)
	 * is used.
	 */
E
Erich Gamma 已提交
403
	sortText?: string;
404 405 406 407 408
	/**
	 * A string that should be used when filtering a set of
	 * completion items. When `falsy` the [label](#CompletionItem.label)
	 * is used.
	 */
409
	filterText?: string;
J
Johannes Rieken 已提交
410 411 412 413 414
	/**
	 * Select this item when showing. *Note* that only one completion item can be selected and
	 * that the editor decides which item that is. The rule is that the *first* item of those
	 * that match best is selected.
	 */
415
	preselect?: boolean;
416 417
	/**
	 * A string or snippet that should be inserted in a document when selecting
418
	 * this completion.
419 420
	 * is used.
	 */
421
	insertText: string;
422
	/**
423 424
	 * Addition rules (as bitmask) that should be applied when inserting
	 * this completion.
425
	 */
426
	insertTextRules?: CompletionItemInsertTextRule;
427 428 429 430 431 432 433 434 435
	/**
	 * A range of text that should be replaced by this completion item.
	 *
	 * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the
	 * current position.
	 *
	 * *Note:* The range must be a [single line](#Range.isSingleLine) and it must
	 * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems).
	 */
436
	range?: IRange;
437 438 439 440 441
	/**
	 * An optional set of characters that when pressed while this completion is active will accept it first and
	 * then type that character. *Note* that all commit characters should have `length=1` and that superfluous
	 * characters will be ignored.
	 */
442
	commitCharacters?: string[];
443 444 445 446 447
	/**
	 * An optional array of additional text edits that are applied when
	 * selecting this completion. Edits must not overlap with the main edit
	 * nor with themselves.
	 */
448
	additionalTextEdits?: model.ISingleEditOperation[];
449 450 451
	/**
	 * A command that should be run upon acceptance of this item.
	 */
452
	command?: Command;
453 454 455 456 457 458 459

	/**@internal*/
	_labelLow?: string;
	/**@internal*/
	_sortTextLow?: string;
	/**@internal*/
	_filterTextLow?: string;
E
Erich Gamma 已提交
460 461
}

462 463
export interface CompletionList {
	suggestions: CompletionItem[];
E
Erich Gamma 已提交
464
	incomplete?: boolean;
465
	dispose?(): void;
E
Erich Gamma 已提交
466 467
}

M
Matt Bierner 已提交
468 469 470
/**
 * How a suggest provider was triggered.
 */
471
export const enum CompletionTriggerKind {
M
Matt Bierner 已提交
472
	Invoke = 0,
473 474
	TriggerCharacter = 1,
	TriggerForIncompleteCompletions = 2
M
Matt Bierner 已提交
475
}
476
/**
477 478
 * Contains additional information about the context in which
 * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered.
479
 */
480
export interface CompletionContext {
481 482 483
	/**
	 * How the completion was triggered.
	 */
484
	triggerKind: CompletionTriggerKind;
485 486 487 488 489
	/**
	 * Character that triggered the completion item provider.
	 *
	 * `undefined` if provider was not triggered by a character.
	 */
490 491
	triggerCharacter?: string;
}
492
/**
493 494 495 496 497 498 499 500 501
 * The completion item provider interface defines the contract between extensions and
 * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense).
 *
 * When computing *complete* completion items is expensive, providers can optionally implement
 * the `resolveCompletionItem`-function. In that case it is enough to return completion
 * items with a [label](#CompletionItem.label) from the
 * [provideCompletionItems](#CompletionItemProvider.provideCompletionItems)-function. Subsequently,
 * when a completion item is shown in the UI and gains focus this provider is asked to resolve
 * the item, like adding [doc-comment](#CompletionItem.documentation) or [details](#CompletionItem.detail).
502
 */
503
export interface CompletionItemProvider {
E
Erich Gamma 已提交
504

505
	triggerCharacters?: string[];
506 507 508
	/**
	 * Provide completion items for the given position and document.
	 */
509
	provideCompletionItems(model: model.ITextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult<CompletionList>;
E
Erich Gamma 已提交
510

511 512 513 514 515 516
	/**
	 * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation)
	 * or [details](#CompletionItem.detail).
	 *
	 * The editor will only resolve a completion item once.
	 */
517
	resolveCompletionItem?(model: model.ITextModel, position: Position, item: CompletionItem, token: CancellationToken): ProviderResult<CompletionItem>;
E
Erich Gamma 已提交
518 519
}

520 521 522
export interface CodeAction {
	title: string;
	command?: Command;
523
	edit?: WorkspaceEdit;
524
	diagnostics?: IMarkerData[];
M
Matt Bierner 已提交
525 526 527
	kind?: string;
}

528 529 530
/**
 * @internal
 */
531
export const enum CodeActionTrigger {
532 533 534 535
	Automatic = 1,
	Manual = 2,
}

M
Matt Bierner 已提交
536 537 538 539 540
/**
 * @internal
 */
export interface CodeActionContext {
	only?: string;
541
	trigger: CodeActionTrigger;
542 543
}

A
Alex Dima 已提交
544 545 546
/**
 * The code action interface defines the contract between extensions and
 * the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
547
 * @internal
A
Alex Dima 已提交
548
 */
549
export interface CodeActionProvider {
A
Alex Dima 已提交
550 551 552
	/**
	 * Provide commands for the given document and range.
	 */
553
	provideCodeActions(model: model.ITextModel, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<CodeAction[]>;
554 555 556 557

	/**
	 * Optional list of of CodeActionKinds that this provider returns.
	 */
558
	providedCodeActionKinds?: ReadonlyArray<string>;
E
Erich Gamma 已提交
559 560
}

A
Alex Dima 已提交
561 562 563 564
/**
 * Represents a parameter of a callable-signature. A parameter can
 * have a label and a doc-comment.
 */
565
export interface ParameterInformation {
A
Alex Dima 已提交
566 567 568 569
	/**
	 * The label of this signature. Will be shown in
	 * the UI.
	 */
570
	label: string | [number, number];
A
Alex Dima 已提交
571 572 573 574
	/**
	 * The human-readable doc-comment of this signature. Will be shown
	 * in the UI but can be omitted.
	 */
575
	documentation?: string | IMarkdownString;
E
Erich Gamma 已提交
576
}
A
Alex Dima 已提交
577 578 579 580 581
/**
 * Represents the signature of something callable. A signature
 * can have a label, like a function-name, a doc-comment, and
 * a set of parameters.
 */
582
export interface SignatureInformation {
A
Alex Dima 已提交
583 584 585 586
	/**
	 * The label of this signature. Will be shown in
	 * the UI.
	 */
587
	label: string;
A
Alex Dima 已提交
588 589 590 591
	/**
	 * The human-readable doc-comment of this signature. Will be shown
	 * in the UI but can be omitted.
	 */
592
	documentation?: string | IMarkdownString;
A
Alex Dima 已提交
593 594 595
	/**
	 * The parameters of this signature.
	 */
596
	parameters: ParameterInformation[];
E
Erich Gamma 已提交
597
}
A
Alex Dima 已提交
598 599 600 601 602
/**
 * Signature help represents the signature of something
 * callable. There can be multiple signatures but only one
 * active and only one active parameter.
 */
603
export interface SignatureHelp {
A
Alex Dima 已提交
604 605 606
	/**
	 * One or more signatures.
	 */
607
	signatures: SignatureInformation[];
A
Alex Dima 已提交
608 609 610
	/**
	 * The active signature.
	 */
611
	activeSignature: number;
A
Alex Dima 已提交
612 613 614
	/**
	 * The active parameter of the active signature.
	 */
615
	activeParameter: number;
E
Erich Gamma 已提交
616
}
617 618 619 620

export enum SignatureHelpTriggerReason {
	Invoke = 1,
	TriggerCharacter = 2,
621
	ContentChange = 3,
622 623 624
}

export interface SignatureHelpContext {
625 626 627
	readonly triggerReason: SignatureHelpTriggerReason;
	readonly triggerCharacter?: string;
	readonly isRetrigger: boolean;
628 629
}

A
Alex Dima 已提交
630 631
/**
 * The signature help provider interface defines the contract between extensions and
G
Greg Van Liew 已提交
632
 * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature.
A
Alex Dima 已提交
633
 */
A
Alex Dima 已提交
634
export interface SignatureHelpProvider {
635

A
Alex Dima 已提交
636 637
	readonly signatureHelpTriggerCharacters?: ReadonlyArray<string>;
	readonly signatureHelpRetriggerCharacters?: ReadonlyArray<string>;
638

A
Alex Dima 已提交
639 640 641
	/**
	 * Provide help for the signature at the given position and document.
	 */
642
	provideSignatureHelp(model: model.ITextModel, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult<SignatureHelp>;
E
Erich Gamma 已提交
643 644
}

A
Alex Dima 已提交
645 646 647
/**
 * A document highlight kind.
 */
648
export enum DocumentHighlightKind {
A
Alex Dima 已提交
649 650 651
	/**
	 * A textual occurrence.
	 */
652
	Text,
A
Alex Dima 已提交
653 654 655
	/**
	 * Read-access of a symbol, like reading a variable.
	 */
656
	Read,
A
Alex Dima 已提交
657 658 659
	/**
	 * Write-access of a symbol, like writing to a variable.
	 */
660 661
	Write
}
A
Alex Dima 已提交
662 663 664 665 666
/**
 * A document highlight is a range inside a text document which deserves
 * special attention. Usually a document highlight is visualized by changing
 * the background color of its range.
 */
667
export interface DocumentHighlight {
A
Alex Dima 已提交
668 669 670
	/**
	 * The range this highlight applies to.
	 */
A
Alex Dima 已提交
671
	range: IRange;
A
Alex Dima 已提交
672 673 674
	/**
	 * The highlight kind, default is [text](#DocumentHighlightKind.Text).
	 */
675
	kind: DocumentHighlightKind;
E
Erich Gamma 已提交
676
}
A
Alex Dima 已提交
677 678 679 680
/**
 * The document highlight provider interface defines the contract between extensions and
 * the word-highlight-feature.
 */
681
export interface DocumentHighlightProvider {
A
Alex Dima 已提交
682 683 684 685
	/**
	 * Provide a set of document highlights, like all occurrences of a variable or
	 * all exit-points of a function.
	 */
686
	provideDocumentHighlights(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>;
E
Erich Gamma 已提交
687 688
}

A
Alex Dima 已提交
689 690 691 692
/**
 * Value-object that contains additional information when
 * requesting references.
 */
693
export interface ReferenceContext {
A
Alex Dima 已提交
694 695 696
	/**
	 * Include the declaration of the current symbol.
	 */
697 698
	includeDeclaration: boolean;
}
A
Alex Dima 已提交
699 700 701 702
/**
 * The reference provider interface defines the contract between extensions and
 * the [find references](https://code.visualstudio.com/docs/editor/editingevolved#_peek)-feature.
 */
703
export interface ReferenceProvider {
A
Alex Dima 已提交
704 705 706
	/**
	 * Provide a set of project-wide references for the given position and document.
	 */
707
	provideReferences(model: model.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult<Location[]>;
E
Erich Gamma 已提交
708 709
}

A
Alex Dima 已提交
710 711 712 713
/**
 * Represents a location inside a resource, such as a line
 * inside a text file.
 */
A
Alex Dima 已提交
714
export interface Location {
A
Alex Dima 已提交
715 716 717
	/**
	 * The resource identifier of this location.
	 */
718
	uri: URI;
A
Alex Dima 已提交
719 720 721
	/**
	 * The document range of this locations.
	 */
A
Alex Dima 已提交
722
	range: IRange;
E
Erich Gamma 已提交
723
}
A
Alex Dima 已提交
724 725 726 727 728
/**
 * The definition of a symbol represented as one or many [locations](#Location).
 * For most programming languages there is only one location at which a symbol is
 * defined.
 */
729
export type Definition = Location | Location[];
730

M
Matt Bierner 已提交
731 732 733 734 735 736 737
export interface DefinitionLink {
	origin?: IRange;
	uri: URI;
	range: IRange;
	selectionRange?: IRange;
}

A
Alex Dima 已提交
738 739 740 741 742
/**
 * The definition provider interface defines the contract between extensions and
 * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
 * and peek definition features.
 */
743
export interface DefinitionProvider {
A
Alex Dima 已提交
744 745 746
	/**
	 * Provide the definition of the symbol at the given position and document.
	 */
747
	provideDefinition(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
748 749
}

750 751 752 753 754 755 756 757 758 759 760 761
/**
 * The definition provider interface defines the contract between extensions and
 * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
 * and peek definition features.
 */
export interface DeclarationProvider {
	/**
	 * Provide the declaration of the symbol at the given position and document.
	 */
	provideDeclaration(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
}

762
/**
763
 * The implementation provider interface defines the contract between extensions and
764
 * the go to implementation feature.
765
 */
M
Matt Bierner 已提交
766
export interface ImplementationProvider {
767 768 769
	/**
	 * Provide the implementation of the symbol at the given position and document.
	 */
770
	provideImplementation(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
771
}
772

773 774 775 776 777 778 779 780
/**
 * The type definition provider interface defines the contract between extensions and
 * the go to type definition feature.
 */
export interface TypeDefinitionProvider {
	/**
	 * Provide the type definition of the symbol at the given position and document.
	 */
781
	provideTypeDefinition(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
782 783
}

A
Alex Dima 已提交
784 785 786
/**
 * A symbol kind.
 */
787
export const enum SymbolKind {
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
	File = 0,
	Module = 1,
	Namespace = 2,
	Package = 3,
	Class = 4,
	Method = 5,
	Property = 6,
	Field = 7,
	Constructor = 8,
	Enum = 9,
	Interface = 10,
	Function = 11,
	Variable = 12,
	Constant = 13,
	String = 14,
	Number = 15,
	Boolean = 16,
	Array = 17,
	Object = 18,
	Key = 19,
	Null = 20,
	EnumMember = 21,
810 811
	Struct = 22,
	Event = 23,
812 813
	Operator = 24,
	TypeParameter = 25
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845
}


/**
 * @internal
 */
export const symbolKindToCssClass = (function () {

	const _fromMapping: { [n: number]: string } = Object.create(null);
	_fromMapping[SymbolKind.File] = 'file';
	_fromMapping[SymbolKind.Module] = 'module';
	_fromMapping[SymbolKind.Namespace] = 'namespace';
	_fromMapping[SymbolKind.Package] = 'package';
	_fromMapping[SymbolKind.Class] = 'class';
	_fromMapping[SymbolKind.Method] = 'method';
	_fromMapping[SymbolKind.Property] = 'property';
	_fromMapping[SymbolKind.Field] = 'field';
	_fromMapping[SymbolKind.Constructor] = 'constructor';
	_fromMapping[SymbolKind.Enum] = 'enum';
	_fromMapping[SymbolKind.Interface] = 'interface';
	_fromMapping[SymbolKind.Function] = 'function';
	_fromMapping[SymbolKind.Variable] = 'variable';
	_fromMapping[SymbolKind.Constant] = 'constant';
	_fromMapping[SymbolKind.String] = 'string';
	_fromMapping[SymbolKind.Number] = 'number';
	_fromMapping[SymbolKind.Boolean] = 'boolean';
	_fromMapping[SymbolKind.Array] = 'array';
	_fromMapping[SymbolKind.Object] = 'object';
	_fromMapping[SymbolKind.Key] = 'key';
	_fromMapping[SymbolKind.Null] = 'null';
	_fromMapping[SymbolKind.EnumMember] = 'enum-member';
	_fromMapping[SymbolKind.Struct] = 'struct';
846 847
	_fromMapping[SymbolKind.Event] = 'event';
	_fromMapping[SymbolKind.Operator] = 'operator';
848
	_fromMapping[SymbolKind.TypeParameter] = 'type-parameter';
849 850

	return function toCssClassName(kind: SymbolKind): string {
851
		return `symbol-icon ${_fromMapping[kind] || 'property'}`;
852 853 854
	};
})();

855
export interface DocumentSymbol {
856
	name: string;
857
	detail: string;
858
	kind: SymbolKind;
859
	containerName?: string;
860 861
	range: IRange;
	selectionRange: IRange;
862
	children?: DocumentSymbol[];
863
}
864

A
Alex Dima 已提交
865 866 867 868
/**
 * The document symbol provider interface defines the contract between extensions and
 * the [go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_goto-symbol)-feature.
 */
869
export interface DocumentSymbolProvider {
870

871
	displayName?: string;
872

A
Alex Dima 已提交
873 874 875
	/**
	 * Provide symbol information for the given document.
	 */
876
	provideDocumentSymbols(model: model.ITextModel, token: CancellationToken): ProviderResult<DocumentSymbol[]>;
E
Erich Gamma 已提交
877 878
}

879
export type TextEdit = { range: IRange; text: string; eol?: model.EndOfLineSequence; };
880

E
Erich Gamma 已提交
881 882 883
/**
 * Interface used to format a model
 */
A
Alex Dima 已提交
884 885 886 887
export interface FormattingOptions {
	/**
	 * Size of a tab in spaces.
	 */
J
Johannes Rieken 已提交
888
	tabSize: number;
A
Alex Dima 已提交
889 890 891
	/**
	 * Prefer spaces over tabs.
	 */
J
Johannes Rieken 已提交
892
	insertSpaces: boolean;
E
Erich Gamma 已提交
893
}
A
Alex Dima 已提交
894 895 896 897
/**
 * The document formatting provider interface defines the contract between extensions and
 * the formatting-feature.
 */
898
export interface DocumentFormattingEditProvider {
A
Alex Dima 已提交
899 900 901
	/**
	 * Provide formatting edits for a whole document.
	 */
902
	provideDocumentFormattingEdits(model: model.ITextModel, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
903
}
A
Alex Dima 已提交
904 905 906 907
/**
 * The document formatting provider interface defines the contract between extensions and
 * the formatting-feature.
 */
908
export interface DocumentRangeFormattingEditProvider {
A
Alex Dima 已提交
909 910 911 912 913 914 915
	/**
	 * Provide formatting edits for a range in a document.
	 *
	 * The given range is a hint and providers can decide to format a smaller
	 * or larger range. Often this is done by adjusting the start and end
	 * of the range to full syntax nodes.
	 */
916
	provideDocumentRangeFormattingEdits(model: model.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
917
}
A
Alex Dima 已提交
918 919 920 921
/**
 * The document formatting provider interface defines the contract between extensions and
 * the formatting-feature.
 */
922 923
export interface OnTypeFormattingEditProvider {
	autoFormatTriggerCharacters: string[];
A
Alex Dima 已提交
924 925 926 927 928 929 930
	/**
	 * Provide formatting edits after a character has been typed.
	 *
	 * The given position and character should hint to the provider
	 * what range the position to expand to, like find the matching `{`
	 * when `}` has been entered.
	 */
931
	provideOnTypeFormattingEdits(model: model.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
E
Erich Gamma 已提交
932 933
}

934 935 936
/**
 * @internal
 */
E
Erich Gamma 已提交
937 938
export interface IInplaceReplaceSupportResult {
	value: string;
A
Alex Dima 已提交
939
	range: IRange;
E
Erich Gamma 已提交
940 941
}

A
Alex Dima 已提交
942 943 944
/**
 * A link inside the editor.
 */
945
export interface ILink {
A
Alex Dima 已提交
946
	range: IRange;
A
Alex Dima 已提交
947
	url?: string;
E
Erich Gamma 已提交
948
}
A
Alex Dima 已提交
949 950 951
/**
 * A provider of links.
 */
A
Alex Dima 已提交
952
export interface LinkProvider {
953 954
	provideLinks(model: model.ITextModel, token: CancellationToken): ProviderResult<ILink[]>;
	resolveLink?: (link: ILink, token: CancellationToken) => ProviderResult<ILink>;
E
Erich Gamma 已提交
955 956
}

J
Joao Moreno 已提交
957
/**
J
Joao Moreno 已提交
958
 * A color in RGBA format.
J
Joao Moreno 已提交
959
 */
J
Joao Moreno 已提交
960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
export interface IColor {

	/**
	 * The red component in the range [0-1].
	 */
	readonly red: number;

	/**
	 * The green component in the range [0-1].
	 */
	readonly green: number;

	/**
	 * The blue component in the range [0-1].
	 */
	readonly blue: number;

	/**
	 * The alpha component in the range [0-1].
	 */
	readonly alpha: number;
}

983
/**
984
 * String representations for a color
985
 */
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002
export interface IColorPresentation {
	/**
	 * The label of this color presentation. It will be shown on the color
	 * picker header. By default this is also the text that is inserted when selecting
	 * this color presentation.
	 */
	label: string;
	/**
	 * An [edit](#TextEdit) which is applied to a document when selecting
	 * this presentation for the color.
	 */
	textEdit?: TextEdit;
	/**
	 * An optional array of additional [text edits](#TextEdit) that are applied when
	 * selecting this color presentation.
	 */
	additionalTextEdits?: TextEdit[];
J
Joao Moreno 已提交
1003
}
J
Joao Moreno 已提交
1004 1005 1006 1007

/**
 * A color range is a range in a text model which represents a color.
 */
1008
export interface IColorInformation {
J
Joao Moreno 已提交
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018

	/**
	 * The range within the model.
	 */
	range: IRange;

	/**
	 * The color represented in this range.
	 */
	color: IColor;
J
Joao Moreno 已提交
1019
}
J
Joao Moreno 已提交
1020

J
Joao Moreno 已提交
1021
/**
J
Joao Moreno 已提交
1022
 * A provider of colors for editor models.
J
Joao Moreno 已提交
1023
 */
R
rebornix 已提交
1024
export interface DocumentColorProvider {
J
Joao Moreno 已提交
1025 1026 1027
	/**
	 * Provides the color ranges for a specific model.
	 */
1028
	provideDocumentColors(model: model.ITextModel, token: CancellationToken): ProviderResult<IColorInformation[]>;
1029
	/**
1030
	 * Provide the string representations for a color.
1031
	 */
1032
	provideColorPresentations(model: model.ITextModel, colorInfo: IColorInformation, token: CancellationToken): ProviderResult<IColorPresentation[]>;
J
Joao Moreno 已提交
1033
}
1034 1035
export interface FoldingContext {
}
1036 1037 1038
/**
 * A provider of colors for editor models.
 */
1039
export interface FoldingRangeProvider {
1040 1041 1042
	/**
	 * Provides the color ranges for a specific model.
	 */
1043
	provideFoldingRanges(model: model.ITextModel, context: FoldingContext, token: CancellationToken): ProviderResult<FoldingRange[]>;
1044 1045
}

1046
export interface FoldingRange {
1047 1048

	/**
1049
	 * The one-based start line of the range to fold. The folded area starts after the line's last character.
1050
	 */
1051
	start: number;
1052 1053

	/**
1054
	 * The one-based end line of the range to fold. The folded area ends with the line's last character.
1055
	 */
1056
	end: number;
1057 1058

	/**
1059 1060 1061 1062
	 * Describes the [Kind](#FoldingRangeKind) of the folding range such as [Comment](#FoldingRangeKind.Comment) or
	 * [Region](#FoldingRangeKind.Region). The kind is used to categorize folding ranges and used by commands
	 * like 'Fold all comments'. See
	 * [FoldingRangeKind](#FoldingRangeKind) for an enumeration of standardized kinds.
1063
	 */
1064
	kind?: FoldingRangeKind;
1065
}
1066
export class FoldingRangeKind {
1067
	/**
1068
	 * Kind for folding range representing a comment. The value of the kind is 'comment'.
1069
	 */
1070
	static readonly Comment = new FoldingRangeKind('comment');
1071
	/**
1072
	 * Kind for folding range representing a import. The value of the kind is 'imports'.
1073
	 */
1074
	static readonly Imports = new FoldingRangeKind('imports');
1075
	/**
1076 1077
	 * Kind for folding range representing regions (for example marked by `#region`, `#endregion`).
	 * The value of the kind is 'region'.
1078
	 */
1079 1080
	static readonly Region = new FoldingRangeKind('region');

1081
	/**
1082 1083 1084
	 * Creates a new [FoldingRangeKind](#FoldingRangeKind).
	 *
	 * @param value of the kind.
1085
	 */
1086 1087
	public constructor(public value: string) {
	}
1088 1089
}

1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101
/**
 * @internal
 */
export function isResourceFileEdit(thing: any): thing is ResourceFileEdit {
	return isObject(thing) && (Boolean((<ResourceFileEdit>thing).newUri) || Boolean((<ResourceFileEdit>thing).oldUri));
}

/**
 * @internal
 */
export function isResourceTextEdit(thing: any): thing is ResourceTextEdit {
	return isObject(thing) && (<ResourceTextEdit>thing).resource && Array.isArray((<ResourceTextEdit>thing).edits);
E
Erich Gamma 已提交
1102
}
1103

1104 1105 1106
export interface ResourceFileEdit {
	oldUri: URI;
	newUri: URI;
J
Johannes Rieken 已提交
1107
	options: { overwrite?: boolean, ignoreIfNotExists?: boolean, ignoreIfExists?: boolean, recursive?: boolean };
1108 1109
}

1110
export interface ResourceTextEdit {
E
Erich Gamma 已提交
1111
	resource: URI;
1112 1113
	modelVersionId?: number;
	edits: TextEdit[];
E
Erich Gamma 已提交
1114
}
1115

1116
export interface WorkspaceEdit {
J
Johannes Rieken 已提交
1117
	edits?: Array<ResourceTextEdit | ResourceFileEdit>;
E
Erich Gamma 已提交
1118
}
1119

1120
export interface Rejection {
1121
	rejectReason?: string;
1122
}
1123 1124 1125 1126 1127
export interface RenameLocation {
	range: IRange;
	text: string;
}

1128
export interface RenameProvider {
1129
	provideRenameEdits(model: model.ITextModel, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit & Rejection>;
1130
	resolveRenameLocation?(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<RenameLocation & Rejection>;
E
Erich Gamma 已提交
1131 1132
}

1133

A
Alex Dima 已提交
1134
export interface Command {
E
Erich Gamma 已提交
1135 1136
	id: string;
	title: string;
1137
	tooltip?: string;
E
Erich Gamma 已提交
1138 1139
	arguments?: any[];
}
M
Matt Bierner 已提交
1140

A
Alex Dima 已提交
1141 1142 1143
/**
 * @internal
 */
1144 1145 1146 1147 1148
export interface CommentInfo {
	threads: CommentThread[];
	commentingRanges?: IRange[];
	reply?: Command;
}
M
Matt Bierner 已提交
1149

A
Alex Dima 已提交
1150 1151 1152
/**
 * @internal
 */
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
export enum CommentThreadCollapsibleState {
	/**
	 * Determines an item is collapsed
	 */
	Collapsed = 0,
	/**
	 * Determines an item is expanded
	 */
	Expanded = 1
}

A
Alex Dima 已提交
1164 1165 1166
/**
 * @internal
 */
M
Matt Bierner 已提交
1167
export interface CommentThread {
1168 1169 1170 1171 1172 1173
	threadId: string;
	resource: string;
	range: IRange;
	comments: Comment[];
	collapsibleState?: CommentThreadCollapsibleState;
	reply?: Command;
M
Matt Bierner 已提交
1174 1175
}

A
Alex Dima 已提交
1176 1177 1178
/**
 * @internal
 */
P
Peng Lyu 已提交
1179 1180 1181 1182 1183
export interface NewCommentAction {
	ranges: IRange[];
	actions: Command[];
}

A
Alex Dima 已提交
1184 1185 1186
/**
 * @internal
 */
M
Matt Bierner 已提交
1187
export interface Comment {
P
Peng Lyu 已提交
1188
	readonly commentId: string;
M
Matt Bierner 已提交
1189 1190
	readonly body: IMarkdownString;
	readonly userName: string;
1191
	readonly userIconPath: string;
1192
	readonly canEdit?: boolean;
1193
	readonly canDelete?: boolean;
1194
	readonly command?: Command;
M
Matt Bierner 已提交
1195 1196
}

A
Alex Dima 已提交
1197 1198 1199
/**
 * @internal
 */
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216
export interface CommentThreadChangedEvent {
	/**
	 * Added comment threads.
	 */
	readonly added: CommentThread[];

	/**
	 * Removed comment threads.
	 */
	readonly removed: CommentThread[];

	/**
	 * Changed comment threads.
	 */
	readonly changed: CommentThread[];
}

A
Alex Dima 已提交
1217 1218 1219
/**
 * @internal
 */
1220
export interface DocumentCommentProvider {
1221 1222 1223
	provideDocumentComments(resource: URI, token: CancellationToken): Promise<CommentInfo>;
	createNewCommentThread(resource: URI, range: Range, text: string, token: CancellationToken): Promise<CommentThread>;
	replyToCommentThread(resource: URI, range: Range, thread: CommentThread, text: string, token: CancellationToken): Promise<CommentThread>;
1224
	editComment(resource: URI, comment: Comment, text: string, token: CancellationToken): Promise<void>;
1225
	deleteComment(resource: URI, comment: Comment, token: CancellationToken): Promise<void>;
1226 1227 1228
	onDidChangeCommentThreads(): Event<CommentThreadChangedEvent>;
}

A
Alex Dima 已提交
1229 1230 1231
/**
 * @internal
 */
1232 1233
export interface WorkspaceCommentProvider {
	provideWorkspaceComments(token: CancellationToken): Promise<CommentThread[]>;
1234
	onDidChangeCommentThreads(): Event<CommentThreadChangedEvent>;
M
Matt Bierner 已提交
1235 1236
}

E
Erich Gamma 已提交
1237
export interface ICodeLensSymbol {
A
Alex Dima 已提交
1238
	range: IRange;
E
Erich Gamma 已提交
1239
	id?: string;
A
Alex Dima 已提交
1240
	command?: Command;
E
Erich Gamma 已提交
1241
}
1242
export interface CodeLensProvider {
1243
	onDidChange?: Event<this>;
1244 1245
	provideCodeLenses(model: model.ITextModel, token: CancellationToken): ProviderResult<ICodeLensSymbol[]>;
	resolveCodeLens?(model: model.ITextModel, codeLens: ICodeLensSymbol, token: CancellationToken): ProviderResult<ICodeLensSymbol>;
E
Erich Gamma 已提交
1246 1247
}

1248 1249
// --- feature registries ------

1250 1251 1252
/**
 * @internal
 */
1253
export const ReferenceProviderRegistry = new LanguageFeatureRegistry<ReferenceProvider>();
1254

1255 1256 1257
/**
 * @internal
 */
1258
export const RenameProviderRegistry = new LanguageFeatureRegistry<RenameProvider>();
1259

1260 1261 1262
/**
 * @internal
 */
1263
export const CompletionProviderRegistry = new LanguageFeatureRegistry<CompletionItemProvider>();
1264

1265 1266 1267
/**
 * @internal
 */
1268
export const SignatureHelpProviderRegistry = new LanguageFeatureRegistry<SignatureHelpProvider>();
1269

1270 1271 1272
/**
 * @internal
 */
1273
export const HoverProviderRegistry = new LanguageFeatureRegistry<HoverProvider>();
1274

1275 1276 1277
/**
 * @internal
 */
1278
export const DocumentSymbolProviderRegistry = new LanguageFeatureRegistry<DocumentSymbolProvider>();
1279

1280 1281 1282
/**
 * @internal
 */
1283
export const DocumentHighlightProviderRegistry = new LanguageFeatureRegistry<DocumentHighlightProvider>();
1284

1285 1286 1287
/**
 * @internal
 */
1288
export const DefinitionProviderRegistry = new LanguageFeatureRegistry<DefinitionProvider>();
1289

1290 1291 1292 1293 1294
/**
 * @internal
 */
export const DeclarationProviderRegistry = new LanguageFeatureRegistry<DeclarationProvider>();

1295 1296 1297
/**
 * @internal
 */
M
Matt Bierner 已提交
1298
export const ImplementationProviderRegistry = new LanguageFeatureRegistry<ImplementationProvider>();
1299

1300 1301 1302 1303 1304
/**
 * @internal
 */
export const TypeDefinitionProviderRegistry = new LanguageFeatureRegistry<TypeDefinitionProvider>();

1305 1306 1307
/**
 * @internal
 */
1308
export const CodeLensProviderRegistry = new LanguageFeatureRegistry<CodeLensProvider>();
1309

1310 1311 1312
/**
 * @internal
 */
1313
export const CodeActionProviderRegistry = new LanguageFeatureRegistry<CodeActionProvider>();
1314

1315 1316 1317
/**
 * @internal
 */
1318 1319
export const DocumentFormattingEditProviderRegistry = new LanguageFeatureRegistry<DocumentFormattingEditProvider>();

1320 1321 1322
/**
 * @internal
 */
1323
export const DocumentRangeFormattingEditProviderRegistry = new LanguageFeatureRegistry<DocumentRangeFormattingEditProvider>();
1324

1325 1326 1327
/**
 * @internal
 */
1328
export const OnTypeFormattingEditProviderRegistry = new LanguageFeatureRegistry<OnTypeFormattingEditProvider>();
1329

1330 1331 1332
/**
 * @internal
 */
A
Alex Dima 已提交
1333
export const LinkProviderRegistry = new LanguageFeatureRegistry<LinkProvider>();
1334

J
Joao Moreno 已提交
1335 1336 1337
/**
 * @internal
 */
R
rebornix 已提交
1338
export const ColorProviderRegistry = new LanguageFeatureRegistry<DocumentColorProvider>();
J
Joao Moreno 已提交
1339

1340 1341 1342
/**
 * @internal
 */
1343
export const FoldingRangeProviderRegistry = new LanguageFeatureRegistry<FoldingRangeProvider>();
1344

1345 1346 1347 1348
/**
 * @internal
 */
export interface ITokenizationSupportChangedEvent {
A
Alex Dima 已提交
1349 1350
	changedLanguages: string[];
	changedColorMap: boolean;
1351 1352 1353 1354 1355
}

/**
 * @internal
 */
1356
export interface ITokenizationRegistry {
A
Alex Dima 已提交
1357 1358 1359 1360 1361 1362

	/**
	 * An event triggered when:
	 *  - a tokenization support is registered, unregistered or changed.
	 *  - the color map is changed.
	 */
1363
	onDidChange: Event<ITokenizationSupportChangedEvent>;
A
Alex Dima 已提交
1364

1365 1366 1367 1368
	/**
	 * Fire a change event for a language.
	 * This is useful for languages that embed other languages.
	 */
1369
	fire(languages: string[]): void;
1370

A
Alex Dima 已提交
1371 1372 1373
	/**
	 * Register a tokenization support.
	 */
1374
	register(language: string, support: ITokenizationSupport): IDisposable;
1375

1376 1377 1378 1379 1380
	/**
	 * Register a promise for a tokenization support.
	 */
	registerPromise(language: string, promise: Thenable<ITokenizationSupport>): Thenable<IDisposable>;

A
Alex Dima 已提交
1381 1382 1383 1384
	/**
	 * Get the tokenization support for a language.
	 * Returns null if not found.
	 */
1385
	get(language: string): ITokenizationSupport;
A
Alex Dima 已提交
1386

1387 1388 1389 1390
	/**
	 * Get the promise of a tokenization support for a language.
	 * `null` is returned if no support is available and no promise for the support has been registered yet.
	 */
A
Alex Dima 已提交
1391
	getPromise(language: string): Thenable<ITokenizationSupport> | null;
1392

A
Alex Dima 已提交
1393 1394 1395
	/**
	 * Set the new color map that all tokens will use in their ColorId binary encoded bits for foreground and background.
	 */
1396
	setColorMap(colorMap: Color[]): void;
A
Alex Dima 已提交
1397

A
Alex Dima 已提交
1398
	getColorMap(): Color[] | null;
A
Alex Dima 已提交
1399

A
Alex Dima 已提交
1400
	getDefaultBackground(): Color | null;
1401 1402 1403 1404 1405 1406
}

/**
 * @internal
 */
export const TokenizationRegistry = new TokenizationRegistryImpl();