modes.ts 38.8 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
/**
 * 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.
 */
224
export type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;
225

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;
E
Erich Gamma 已提交
453 454
}

455 456
export interface CompletionList {
	suggestions: CompletionItem[];
E
Erich Gamma 已提交
457
	incomplete?: boolean;
458
	dispose?(): void;
E
Erich Gamma 已提交
459 460
}

M
Matt Bierner 已提交
461 462 463
/**
 * How a suggest provider was triggered.
 */
464
export const enum CompletionTriggerKind {
M
Matt Bierner 已提交
465
	Invoke = 0,
466 467
	TriggerCharacter = 1,
	TriggerForIncompleteCompletions = 2
M
Matt Bierner 已提交
468
}
469
/**
470 471
 * Contains additional information about the context in which
 * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered.
472
 */
473
export interface CompletionContext {
474 475 476
	/**
	 * How the completion was triggered.
	 */
477
	triggerKind: CompletionTriggerKind;
478 479 480 481 482
	/**
	 * Character that triggered the completion item provider.
	 *
	 * `undefined` if provider was not triggered by a character.
	 */
483 484
	triggerCharacter?: string;
}
485
/**
486 487 488 489 490 491 492 493 494
 * 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).
495
 */
496
export interface CompletionItemProvider {
E
Erich Gamma 已提交
497

498
	triggerCharacters?: string[];
499 500 501
	/**
	 * Provide completion items for the given position and document.
	 */
502
	provideCompletionItems(model: model.ITextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult<CompletionList>;
E
Erich Gamma 已提交
503

504 505 506 507 508 509
	/**
	 * 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.
	 */
510
	resolveCompletionItem?(model: model.ITextModel, position: Position, item: CompletionItem, token: CancellationToken): ProviderResult<CompletionItem>;
E
Erich Gamma 已提交
511 512
}

513 514 515
export interface CodeAction {
	title: string;
	command?: Command;
516
	edit?: WorkspaceEdit;
517
	diagnostics?: IMarkerData[];
M
Matt Bierner 已提交
518 519 520
	kind?: string;
}

521 522 523
/**
 * @internal
 */
524
export const enum CodeActionTrigger {
525 526 527 528
	Automatic = 1,
	Manual = 2,
}

M
Matt Bierner 已提交
529 530 531 532 533
/**
 * @internal
 */
export interface CodeActionContext {
	only?: string;
534
	trigger: CodeActionTrigger;
535 536
}

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

	/**
549
	 * Optional list of CodeActionKinds that this provider returns.
550
	 */
551
	providedCodeActionKinds?: ReadonlyArray<string>;
E
Erich Gamma 已提交
552 553
}

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

M
Matt Bierner 已提交
611
export enum SignatureHelpTriggerKind {
612 613
	Invoke = 1,
	TriggerCharacter = 2,
614
	ContentChange = 3,
615 616 617
}

export interface SignatureHelpContext {
618
	readonly triggerKind: SignatureHelpTriggerKind;
619 620
	readonly triggerCharacter?: string;
	readonly isRetrigger: boolean;
621 622
}

A
Alex Dima 已提交
623 624
/**
 * The signature help provider interface defines the contract between extensions and
G
Greg Van Liew 已提交
625
 * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature.
A
Alex Dima 已提交
626
 */
A
Alex Dima 已提交
627
export interface SignatureHelpProvider {
628

A
Alex Dima 已提交
629 630
	readonly signatureHelpTriggerCharacters?: ReadonlyArray<string>;
	readonly signatureHelpRetriggerCharacters?: ReadonlyArray<string>;
631

A
Alex Dima 已提交
632 633 634
	/**
	 * Provide help for the signature at the given position and document.
	 */
635
	provideSignatureHelp(model: model.ITextModel, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult<SignatureHelp>;
E
Erich Gamma 已提交
636 637
}

A
Alex Dima 已提交
638 639 640
/**
 * A document highlight kind.
 */
641
export enum DocumentHighlightKind {
A
Alex Dima 已提交
642 643 644
	/**
	 * A textual occurrence.
	 */
645
	Text,
A
Alex Dima 已提交
646 647 648
	/**
	 * Read-access of a symbol, like reading a variable.
	 */
649
	Read,
A
Alex Dima 已提交
650 651 652
	/**
	 * Write-access of a symbol, like writing to a variable.
	 */
653 654
	Write
}
A
Alex Dima 已提交
655 656 657 658 659
/**
 * 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.
 */
660
export interface DocumentHighlight {
A
Alex Dima 已提交
661 662 663
	/**
	 * The range this highlight applies to.
	 */
A
Alex Dima 已提交
664
	range: IRange;
A
Alex Dima 已提交
665 666 667
	/**
	 * The highlight kind, default is [text](#DocumentHighlightKind.Text).
	 */
668
	kind: DocumentHighlightKind;
E
Erich Gamma 已提交
669
}
A
Alex Dima 已提交
670 671 672 673
/**
 * The document highlight provider interface defines the contract between extensions and
 * the word-highlight-feature.
 */
674
export interface DocumentHighlightProvider {
A
Alex Dima 已提交
675 676 677 678
	/**
	 * Provide a set of document highlights, like all occurrences of a variable or
	 * all exit-points of a function.
	 */
679
	provideDocumentHighlights(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>;
E
Erich Gamma 已提交
680 681
}

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

A
Alex Dima 已提交
703 704 705 706
/**
 * Represents a location inside a resource, such as a line
 * inside a text file.
 */
A
Alex Dima 已提交
707
export interface Location {
A
Alex Dima 已提交
708 709 710
	/**
	 * The resource identifier of this location.
	 */
711
	uri: URI;
A
Alex Dima 已提交
712 713 714
	/**
	 * The document range of this locations.
	 */
A
Alex Dima 已提交
715
	range: IRange;
E
Erich Gamma 已提交
716
}
A
Alex Dima 已提交
717 718 719 720 721
/**
 * 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.
 */
722
export type Definition = Location | Location[];
723

M
Matt Bierner 已提交
724 725 726 727 728 729 730
export interface DefinitionLink {
	origin?: IRange;
	uri: URI;
	range: IRange;
	selectionRange?: IRange;
}

A
Alex Dima 已提交
731 732 733 734 735
/**
 * 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.
 */
736
export interface DefinitionProvider {
A
Alex Dima 已提交
737 738 739
	/**
	 * Provide the definition of the symbol at the given position and document.
	 */
740
	provideDefinition(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
741 742
}

743 744 745 746 747 748 749 750 751 752 753 754
/**
 * 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[]>;
}

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

766 767 768 769 770 771 772 773
/**
 * 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.
	 */
774
	provideTypeDefinition(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
775 776
}

A
Alex Dima 已提交
777 778 779
/**
 * A symbol kind.
 */
780
export const enum SymbolKind {
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802
	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,
803 804
	Struct = 22,
	Event = 23,
805 806
	Operator = 24,
	TypeParameter = 25
807 808 809 810 811 812 813 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
}


/**
 * @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';
839 840
	_fromMapping[SymbolKind.Event] = 'event';
	_fromMapping[SymbolKind.Operator] = 'operator';
841
	_fromMapping[SymbolKind.TypeParameter] = 'type-parameter';
842 843

	return function toCssClassName(kind: SymbolKind): string {
844
		return `symbol-icon ${_fromMapping[kind] || 'property'}`;
845 846 847
	};
})();

848
export interface DocumentSymbol {
849
	name: string;
850
	detail: string;
851
	kind: SymbolKind;
852
	containerName?: string;
853 854
	range: IRange;
	selectionRange: IRange;
855
	children?: DocumentSymbol[];
856
}
857

A
Alex Dima 已提交
858 859 860 861
/**
 * 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.
 */
862
export interface DocumentSymbolProvider {
863

864
	displayName?: string;
865

A
Alex Dima 已提交
866 867 868
	/**
	 * Provide symbol information for the given document.
	 */
869
	provideDocumentSymbols(model: model.ITextModel, token: CancellationToken): ProviderResult<DocumentSymbol[]>;
E
Erich Gamma 已提交
870 871
}

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

E
Erich Gamma 已提交
874 875 876
/**
 * Interface used to format a model
 */
A
Alex Dima 已提交
877 878 879 880
export interface FormattingOptions {
	/**
	 * Size of a tab in spaces.
	 */
J
Johannes Rieken 已提交
881
	tabSize: number;
A
Alex Dima 已提交
882 883 884
	/**
	 * Prefer spaces over tabs.
	 */
J
Johannes Rieken 已提交
885
	insertSpaces: boolean;
E
Erich Gamma 已提交
886
}
A
Alex Dima 已提交
887 888 889 890
/**
 * The document formatting provider interface defines the contract between extensions and
 * the formatting-feature.
 */
891
export interface DocumentFormattingEditProvider {
A
Alex Dima 已提交
892 893 894
	/**
	 * Provide formatting edits for a whole document.
	 */
895
	provideDocumentFormattingEdits(model: model.ITextModel, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
896
}
A
Alex Dima 已提交
897 898 899 900
/**
 * The document formatting provider interface defines the contract between extensions and
 * the formatting-feature.
 */
901
export interface DocumentRangeFormattingEditProvider {
A
Alex Dima 已提交
902 903 904 905 906 907 908
	/**
	 * 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.
	 */
909
	provideDocumentRangeFormattingEdits(model: model.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
910
}
A
Alex Dima 已提交
911 912 913 914
/**
 * The document formatting provider interface defines the contract between extensions and
 * the formatting-feature.
 */
915 916
export interface OnTypeFormattingEditProvider {
	autoFormatTriggerCharacters: string[];
A
Alex Dima 已提交
917 918 919 920 921 922 923
	/**
	 * 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.
	 */
924
	provideOnTypeFormattingEdits(model: model.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
E
Erich Gamma 已提交
925 926
}

927 928 929
/**
 * @internal
 */
E
Erich Gamma 已提交
930 931
export interface IInplaceReplaceSupportResult {
	value: string;
A
Alex Dima 已提交
932
	range: IRange;
E
Erich Gamma 已提交
933 934
}

A
Alex Dima 已提交
935 936 937
/**
 * A link inside the editor.
 */
938
export interface ILink {
A
Alex Dima 已提交
939
	range: IRange;
A
Alex Dima 已提交
940
	url?: string;
E
Erich Gamma 已提交
941
}
A
Alex Dima 已提交
942 943 944
/**
 * A provider of links.
 */
A
Alex Dima 已提交
945
export interface LinkProvider {
946 947
	provideLinks(model: model.ITextModel, token: CancellationToken): ProviderResult<ILink[]>;
	resolveLink?: (link: ILink, token: CancellationToken) => ProviderResult<ILink>;
E
Erich Gamma 已提交
948 949
}

J
Joao Moreno 已提交
950
/**
J
Joao Moreno 已提交
951
 * A color in RGBA format.
J
Joao Moreno 已提交
952
 */
J
Joao Moreno 已提交
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975
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;
}

976
/**
977
 * String representations for a color
978
 */
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995
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 已提交
996
}
J
Joao Moreno 已提交
997 998 999 1000

/**
 * A color range is a range in a text model which represents a color.
 */
1001
export interface IColorInformation {
J
Joao Moreno 已提交
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011

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

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

J
Joao Moreno 已提交
1014
/**
J
Joao Moreno 已提交
1015
 * A provider of colors for editor models.
J
Joao Moreno 已提交
1016
 */
R
rebornix 已提交
1017
export interface DocumentColorProvider {
J
Joao Moreno 已提交
1018 1019 1020
	/**
	 * Provides the color ranges for a specific model.
	 */
1021
	provideDocumentColors(model: model.ITextModel, token: CancellationToken): ProviderResult<IColorInformation[]>;
1022
	/**
1023
	 * Provide the string representations for a color.
1024
	 */
1025
	provideColorPresentations(model: model.ITextModel, colorInfo: IColorInformation, token: CancellationToken): ProviderResult<IColorPresentation[]>;
J
Joao Moreno 已提交
1026
}
1027

1028 1029 1030 1031 1032
export interface SelectionRange {
	kind: string;
	range: IRange;
}

1033 1034 1035 1036
export interface SelectionRangeProvider {
	/**
	 * Provide ranges that should be selected from the given position.
	 */
1037
	provideSelectionRanges(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<SelectionRange[]>;
1038 1039
}

1040 1041
export interface FoldingContext {
}
1042 1043 1044
/**
 * A provider of colors for editor models.
 */
1045
export interface FoldingRangeProvider {
1046 1047 1048
	/**
	 * Provides the color ranges for a specific model.
	 */
1049
	provideFoldingRanges(model: model.ITextModel, context: FoldingContext, token: CancellationToken): ProviderResult<FoldingRange[]>;
1050 1051
}

1052
export interface FoldingRange {
1053 1054

	/**
1055
	 * The one-based start line of the range to fold. The folded area starts after the line's last character.
1056
	 */
1057
	start: number;
1058 1059

	/**
1060
	 * The one-based end line of the range to fold. The folded area ends with the line's last character.
1061
	 */
1062
	end: number;
1063 1064

	/**
1065 1066 1067 1068
	 * 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.
1069
	 */
1070
	kind?: FoldingRangeKind;
1071
}
1072
export class FoldingRangeKind {
1073
	/**
1074
	 * Kind for folding range representing a comment. The value of the kind is 'comment'.
1075
	 */
1076
	static readonly Comment = new FoldingRangeKind('comment');
1077
	/**
1078
	 * Kind for folding range representing a import. The value of the kind is 'imports'.
1079
	 */
1080
	static readonly Imports = new FoldingRangeKind('imports');
1081
	/**
1082 1083
	 * Kind for folding range representing regions (for example marked by `#region`, `#endregion`).
	 * The value of the kind is 'region'.
1084
	 */
1085 1086
	static readonly Region = new FoldingRangeKind('region');

1087
	/**
1088 1089 1090
	 * Creates a new [FoldingRangeKind](#FoldingRangeKind).
	 *
	 * @param value of the kind.
1091
	 */
1092 1093
	public constructor(public value: string) {
	}
1094 1095
}

1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107
/**
 * @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 已提交
1108
}
1109

1110 1111 1112
export interface ResourceFileEdit {
	oldUri: URI;
	newUri: URI;
J
Johannes Rieken 已提交
1113
	options: { overwrite?: boolean, ignoreIfNotExists?: boolean, ignoreIfExists?: boolean, recursive?: boolean };
1114 1115
}

1116
export interface ResourceTextEdit {
E
Erich Gamma 已提交
1117
	resource: URI;
1118 1119
	modelVersionId?: number;
	edits: TextEdit[];
E
Erich Gamma 已提交
1120
}
1121

1122
export interface WorkspaceEdit {
M
Matt Bierner 已提交
1123
	edits: Array<ResourceTextEdit | ResourceFileEdit>;
E
Erich Gamma 已提交
1124
}
1125

1126
export interface Rejection {
1127
	rejectReason?: string;
1128
}
1129 1130 1131 1132 1133
export interface RenameLocation {
	range: IRange;
	text: string;
}

1134
export interface RenameProvider {
1135
	provideRenameEdits(model: model.ITextModel, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit & Rejection>;
1136
	resolveRenameLocation?(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<RenameLocation & Rejection>;
E
Erich Gamma 已提交
1137 1138
}

1139

A
Alex Dima 已提交
1140
export interface Command {
E
Erich Gamma 已提交
1141 1142
	id: string;
	title: string;
1143
	tooltip?: string;
E
Erich Gamma 已提交
1144 1145
	arguments?: any[];
}
M
Matt Bierner 已提交
1146

A
Alex Dima 已提交
1147 1148 1149
/**
 * @internal
 */
1150 1151 1152 1153
export interface CommentInfo {
	threads: CommentThread[];
	commentingRanges?: IRange[];
	reply?: Command;
R
rebornix 已提交
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
	draftMode: DraftMode;
}

/**
 * @internal
 */
export enum DraftMode {
	NotSupported,
	InDraft,
	NotInDraft
1164
}
M
Matt Bierner 已提交
1165

A
Alex Dima 已提交
1166 1167 1168
/**
 * @internal
 */
1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179
export enum CommentThreadCollapsibleState {
	/**
	 * Determines an item is collapsed
	 */
	Collapsed = 0,
	/**
	 * Determines an item is expanded
	 */
	Expanded = 1
}

A
Alex Dima 已提交
1180 1181 1182
/**
 * @internal
 */
M
Matt Bierner 已提交
1183
export interface CommentThread {
1184 1185 1186 1187 1188 1189
	threadId: string;
	resource: string;
	range: IRange;
	comments: Comment[];
	collapsibleState?: CommentThreadCollapsibleState;
	reply?: Command;
M
Matt Bierner 已提交
1190 1191
}

A
Alex Dima 已提交
1192 1193 1194
/**
 * @internal
 */
P
Peng Lyu 已提交
1195 1196 1197 1198 1199
export interface NewCommentAction {
	ranges: IRange[];
	actions: Command[];
}

A
Alex Dima 已提交
1200 1201 1202
/**
 * @internal
 */
M
Matt Bierner 已提交
1203
export interface Comment {
P
Peng Lyu 已提交
1204
	readonly commentId: string;
M
Matt Bierner 已提交
1205 1206
	readonly body: IMarkdownString;
	readonly userName: string;
1207
	readonly userIconPath: string;
1208
	readonly canEdit?: boolean;
1209
	readonly canDelete?: boolean;
1210
	readonly command?: Command;
R
rebornix 已提交
1211
	readonly isDraft?: boolean;
M
Matt Bierner 已提交
1212 1213
}

A
Alex Dima 已提交
1214 1215 1216
/**
 * @internal
 */
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
export interface CommentThreadChangedEvent {
	/**
	 * Added comment threads.
	 */
	readonly added: CommentThread[];

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

	/**
	 * Changed comment threads.
	 */
	readonly changed: CommentThread[];
1232 1233 1234 1235 1236

	/**
	 * changed draft mode.
	 */
	readonly draftMode: DraftMode;
1237 1238
}

A
Alex Dima 已提交
1239 1240 1241
/**
 * @internal
 */
1242
export interface DocumentCommentProvider {
1243 1244 1245
	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>;
1246
	editComment(resource: URI, comment: Comment, text: string, token: CancellationToken): Promise<void>;
1247
	deleteComment(resource: URI, comment: Comment, token: CancellationToken): Promise<void>;
1248 1249 1250
	startDraft?(resource: URI, token: CancellationToken): Promise<void>;
	deleteDraft?(resource: URI, token: CancellationToken): Promise<void>;
	finishDraft?(resource: URI, token: CancellationToken): Promise<void>;
R
rebornix 已提交
1251 1252 1253 1254

	startDraftLabel?: string;
	deleteDraftLabel?: string;
	finishDraftLabel?: string;
1255 1256 1257
	onDidChangeCommentThreads(): Event<CommentThreadChangedEvent>;
}

A
Alex Dima 已提交
1258 1259 1260
/**
 * @internal
 */
1261 1262
export interface WorkspaceCommentProvider {
	provideWorkspaceComments(token: CancellationToken): Promise<CommentThread[]>;
1263
	onDidChangeCommentThreads(): Event<CommentThreadChangedEvent>;
M
Matt Bierner 已提交
1264 1265
}

E
Erich Gamma 已提交
1266
export interface ICodeLensSymbol {
A
Alex Dima 已提交
1267
	range: IRange;
E
Erich Gamma 已提交
1268
	id?: string;
A
Alex Dima 已提交
1269
	command?: Command;
E
Erich Gamma 已提交
1270
}
1271
export interface CodeLensProvider {
1272
	onDidChange?: Event<this>;
1273 1274
	provideCodeLenses(model: model.ITextModel, token: CancellationToken): ProviderResult<ICodeLensSymbol[]>;
	resolveCodeLens?(model: model.ITextModel, codeLens: ICodeLensSymbol, token: CancellationToken): ProviderResult<ICodeLensSymbol>;
E
Erich Gamma 已提交
1275 1276
}

1277 1278
// --- feature registries ------

1279 1280 1281
/**
 * @internal
 */
1282
export const ReferenceProviderRegistry = new LanguageFeatureRegistry<ReferenceProvider>();
1283

1284 1285 1286
/**
 * @internal
 */
1287
export const RenameProviderRegistry = new LanguageFeatureRegistry<RenameProvider>();
1288

1289 1290 1291
/**
 * @internal
 */
1292
export const CompletionProviderRegistry = new LanguageFeatureRegistry<CompletionItemProvider>();
1293

1294 1295 1296
/**
 * @internal
 */
1297
export const SignatureHelpProviderRegistry = new LanguageFeatureRegistry<SignatureHelpProvider>();
1298

1299 1300 1301
/**
 * @internal
 */
1302
export const HoverProviderRegistry = new LanguageFeatureRegistry<HoverProvider>();
1303

1304 1305 1306
/**
 * @internal
 */
1307
export const DocumentSymbolProviderRegistry = new LanguageFeatureRegistry<DocumentSymbolProvider>();
1308

1309 1310 1311
/**
 * @internal
 */
1312
export const DocumentHighlightProviderRegistry = new LanguageFeatureRegistry<DocumentHighlightProvider>();
1313

1314 1315 1316
/**
 * @internal
 */
1317
export const DefinitionProviderRegistry = new LanguageFeatureRegistry<DefinitionProvider>();
1318

1319 1320 1321 1322 1323
/**
 * @internal
 */
export const DeclarationProviderRegistry = new LanguageFeatureRegistry<DeclarationProvider>();

1324 1325 1326
/**
 * @internal
 */
M
Matt Bierner 已提交
1327
export const ImplementationProviderRegistry = new LanguageFeatureRegistry<ImplementationProvider>();
1328

1329 1330 1331 1332 1333
/**
 * @internal
 */
export const TypeDefinitionProviderRegistry = new LanguageFeatureRegistry<TypeDefinitionProvider>();

1334 1335 1336
/**
 * @internal
 */
1337
export const CodeLensProviderRegistry = new LanguageFeatureRegistry<CodeLensProvider>();
1338

1339 1340 1341
/**
 * @internal
 */
1342
export const CodeActionProviderRegistry = new LanguageFeatureRegistry<CodeActionProvider>();
1343

1344 1345 1346
/**
 * @internal
 */
1347 1348
export const DocumentFormattingEditProviderRegistry = new LanguageFeatureRegistry<DocumentFormattingEditProvider>();

1349 1350 1351
/**
 * @internal
 */
1352
export const DocumentRangeFormattingEditProviderRegistry = new LanguageFeatureRegistry<DocumentRangeFormattingEditProvider>();
1353

1354 1355 1356
/**
 * @internal
 */
1357
export const OnTypeFormattingEditProviderRegistry = new LanguageFeatureRegistry<OnTypeFormattingEditProvider>();
1358

1359 1360 1361
/**
 * @internal
 */
A
Alex Dima 已提交
1362
export const LinkProviderRegistry = new LanguageFeatureRegistry<LinkProvider>();
1363

J
Joao Moreno 已提交
1364 1365 1366
/**
 * @internal
 */
R
rebornix 已提交
1367
export const ColorProviderRegistry = new LanguageFeatureRegistry<DocumentColorProvider>();
J
Joao Moreno 已提交
1368

1369 1370 1371 1372 1373
/**
 * @internal
 */
export const SelectionRangeRegistry = new LanguageFeatureRegistry<SelectionRangeProvider>();

1374 1375 1376
/**
 * @internal
 */
1377
export const FoldingRangeProviderRegistry = new LanguageFeatureRegistry<FoldingRangeProvider>();
1378

1379 1380 1381 1382
/**
 * @internal
 */
export interface ITokenizationSupportChangedEvent {
A
Alex Dima 已提交
1383 1384
	changedLanguages: string[];
	changedColorMap: boolean;
1385 1386 1387 1388 1389
}

/**
 * @internal
 */
1390
export interface ITokenizationRegistry {
A
Alex Dima 已提交
1391 1392 1393 1394 1395 1396

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

1399 1400 1401 1402
	/**
	 * Fire a change event for a language.
	 * This is useful for languages that embed other languages.
	 */
1403
	fire(languages: string[]): void;
1404

A
Alex Dima 已提交
1405 1406 1407
	/**
	 * Register a tokenization support.
	 */
1408
	register(language: string, support: ITokenizationSupport): IDisposable;
1409

1410 1411 1412
	/**
	 * Register a promise for a tokenization support.
	 */
1413
	registerPromise(language: string, promise: Thenable<ITokenizationSupport>): IDisposable;
1414

A
Alex Dima 已提交
1415 1416 1417 1418
	/**
	 * Get the tokenization support for a language.
	 * Returns null if not found.
	 */
1419
	get(language: string): ITokenizationSupport;
A
Alex Dima 已提交
1420

1421 1422 1423 1424
	/**
	 * 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.
	 */
1425
	getPromise(language: string): Thenable<ITokenizationSupport> | null;
1426

A
Alex Dima 已提交
1427 1428 1429
	/**
	 * Set the new color map that all tokens will use in their ColorId binary encoded bits for foreground and background.
	 */
1430
	setColorMap(colorMap: Color[]): void;
A
Alex Dima 已提交
1431

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

A
Alex Dima 已提交
1434
	getDefaultBackground(): Color | null;
1435 1436 1437 1438 1439 1440
}

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