modes.ts 49.3 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';
P
Peng Lyu 已提交
11
import { URI, UriComponents } from 'vs/base/common/uri';
12 13 14
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 已提交
15
import { TokenizationResult, TokenizationResult2 } from 'vs/editor/common/core/token';
16
import * as model from 'vs/editor/common/model';
A
Alex Dima 已提交
17
import { LanguageFeatureRegistry } from 'vs/editor/common/modes/languageFeatureRegistry';
18
import { TokenizationRegistryImpl } from 'vs/editor/common/modes/tokenizationRegistry';
19
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
20
import { IMarkerData } from 'vs/platform/markers/common/markers';
21
import { iconRegistry, Codicon } from 'vs/base/common/codicons';
22
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
23
/**
24
 * Open ended enum at runtime
25 26
 * @internal
 */
A
Alex Dima 已提交
27 28 29 30 31 32 33 34 35
export const enum LanguageId {
	Null = 0,
	PlainText = 1
}

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

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

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

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

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

	getId(): string;

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

E
Erich Gamma 已提交
64 65
}

A
Alex Dima 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78
/**
 * 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
}

/**
79
 * Open ended enum at runtime
A
Alex Dima 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
 * @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 已提交
99 100 101 102 103 104 105
/**
 * 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 已提交
106 107 108 109 110 111 112 113 114 115 116 117
 * - -------------------------------------------
 *     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 已提交
118 119 120 121 122 123 124 125 126 127
 *
 * @internal
 */
export const enum MetadataConsts {
	LANGUAGEID_MASK = 0b00000000000000000000000011111111,
	TOKEN_TYPE_MASK = 0b00000000000000000000011100000000,
	FONT_STYLE_MASK = 0b00000000000000000011100000000000,
	FOREGROUND_MASK = 0b00000000011111111100000000000000,
	BACKGROUND_MASK = 0b11111111100000000000000000000000,

128 129 130 131 132 133 134 135 136
	ITALIC_MASK = 0b00000000000000000000100000000000,
	BOLD_MASK = 0b00000000000000000001000000000000,
	UNDERLINE_MASK = 0b00000000000000000010000000000000,

	SEMANTIC_USE_ITALIC = 0b00000000000000000000000000000001,
	SEMANTIC_USE_BOLD = 0b00000000000000000000000000000010,
	SEMANTIC_USE_UNDERLINE = 0b00000000000000000000000000000100,
	SEMANTIC_USE_FOREGROUND = 0b00000000000000000000000000001000,
	SEMANTIC_USE_BACKGROUND = 0b00000000000000000000000000010000,
137

A
Alex Dima 已提交
138 139 140 141 142 143 144
	LANGUAGEID_OFFSET = 0,
	TOKEN_TYPE_OFFSET = 8,
	FONT_STYLE_OFFSET = 11,
	FOREGROUND_OFFSET = 14,
	BACKGROUND_OFFSET = 23
}

A
Alex Dima 已提交
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 195 196 197 198 199 200 201 202 203 204 205
/**
 * @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;
	}
}

206 207 208
/**
 * @internal
 */
E
Erich Gamma 已提交
209 210
export interface ITokenizationSupport {

J
Johannes Rieken 已提交
211
	getInitialState(): IState;
E
Erich Gamma 已提交
212 213

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

216
	tokenize2(line: string, hasEOL: boolean, state: IState, offsetDelta: number): TokenizationResult2;
E
Erich Gamma 已提交
217 218
}

A
Alex Dima 已提交
219 220 221 222 223
/**
 * 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 已提交
224 225 226
export interface IState {
	clone(): IState;
	equals(other: IState): boolean;
A
Alex Dima 已提交
227 228
}

229 230 231 232 233 234
/**
 * 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.
 */
235
export type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;
236

E
Erich Gamma 已提交
237
/**
238 239
 * A hover represents additional information for a symbol or word. Hovers are
 * rendered in a tooltip-like widget.
E
Erich Gamma 已提交
240
 */
241
export interface Hover {
242 243 244
	/**
	 * The contents of this hover.
	 */
245
	contents: IMarkdownString[];
246 247 248 249 250 251

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

A
Alex Dima 已提交
255 256
/**
 * The hover provider interface defines the contract between extensions and
G
Greg Van Liew 已提交
257
 * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
A
Alex Dima 已提交
258
 */
A
Alex Dima 已提交
259
export interface HoverProvider {
A
Alex Dima 已提交
260 261 262 263 264
	/**
	 * 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.
	 */
265
	provideHover(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Hover>;
E
Erich Gamma 已提交
266 267
}

268 269 270
/**
 * An evaluatable expression represents additional information for an expression in a document. Evaluatable expression are
 * evaluated by a debugger or runtime and their result is rendered in a tooltip-like widget.
A
Alex Dima 已提交
271
 * @internal
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
 */
export interface EvaluatableExpression {
	/**
	 * The range to which this expression applies.
	 */
	range: IRange;
	/*
	 * This expression overrides the expression extracted from the range.
	 */
	expression?: string;
}

/**
 * The hover provider interface defines the contract between extensions and
 * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
A
Alex Dima 已提交
287
 * @internal
288 289 290 291 292 293 294 295 296 297
 */
export interface EvaluatableExpressionProvider {
	/**
	 * 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.
	 */
	provideEvaluatableExpression(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<EvaluatableExpression>;
}

298
export const enum CompletionItemKind {
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
	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,
324 325
	User,
	Issue,
J
Johannes Rieken 已提交
326
	Snippet, // <- highest value (used for compare!)
327 328 329 330 331
}

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

363
	return function (kind: CompletionItemKind): string {
364 365 366 367 368 369 370
		const name = data[kind];
		let codicon = name && iconRegistry.get(name);
		if (!codicon) {
			console.info('No codicon found for CompletionItemKind ' + kind);
			codicon = Codicon.symbolProperty;
		}
		return codicon.classNames;
371 372 373 374 375 376
	};
})();

/**
 * @internal
 */
377 378 379 380
export let completionKindFromString: {
	(value: string): CompletionItemKind;
	(value: string, strict: true): CompletionItemKind | undefined;
} = (function () {
381
	let data: Record<string, CompletionItemKind> = Object.create(null);
382 383
	data['method'] = CompletionItemKind.Method;
	data['function'] = CompletionItemKind.Function;
384
	data['constructor'] = <any>CompletionItemKind.Constructor;
385 386 387 388 389 390 391 392 393 394 395 396 397 398
	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;
399
	data['enumMember'] = CompletionItemKind.EnumMember;
400 401 402 403 404 405 406 407 408
	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;
409
	data['typeParameter'] = CompletionItemKind.TypeParameter;
410 411
	data['account'] = CompletionItemKind.User;
	data['issue'] = CompletionItemKind.Issue;
412 413 414 415 416 417
	return function (value: string, strict?: true) {
		let res = data[value];
		if (typeof res === 'undefined' && !strict) {
			res = CompletionItemKind.Property;
		}
		return res;
418 419
	};
})();
J
Johannes Rieken 已提交
420

421 422
export interface CompletionItemLabel {
	/**
P
Pine Wu 已提交
423
	 * The function or variable. Rendered leftmost.
424
	 */
P
Pine Wu 已提交
425
	name: string;
426

P
Pine Wu 已提交
427
	/**
428
	 * The parameters without the return type. Render after `name`.
P
Pine Wu 已提交
429
	 */
430
	parameters?: string;
P
Pine Wu 已提交
431 432

	/**
P
Pine Wu 已提交
433
	 * The fully qualified name, like package name or file path. Rendered after `signature`.
P
Pine Wu 已提交
434 435
	 */
	qualifier?: string;
436 437

	/**
P
Pine Wu 已提交
438
	 * The return-type of a function or type of a property/variable. Rendered rightmost.
439
	 */
P
Pine Wu 已提交
440
	type?: string;
441 442
}

443
export const enum CompletionItemTag {
444 445 446
	Deprecated = 1
}

447
export const enum CompletionItemInsertTextRule {
448
	/**
449 450
	 * Adjust whitespace/indentation of multiline insert texts to
	 * match the current line indentation.
451
	 */
452
	KeepWhitespace = 0b001,
453 454

	/**
455
	 * `insertText` is a snippet.
456
	 */
457
	InsertAsSnippet = 0b100,
458 459
}

460
/**
461 462
 * A completion item represents a text snippet that is
 * proposed to complete text that is being typed.
463
 */
464
export interface CompletionItem {
465 466 467 468 469
	/**
	 * The label of this completion item. By default
	 * this is also the text that is inserted when selecting
	 * this completion.
	 */
470
	label: string | CompletionItemLabel;
471 472 473 474 475
	/**
	 * The kind of this completion item. Based on the kind
	 * an icon is chosen by the editor.
	 */
	kind: CompletionItemKind;
476
	/**
477 478
	 * A modifier to the `kind` which affect how the item
	 * is rendered, e.g. Deprecated is rendered with a strikeout
479
	 */
480
	tags?: ReadonlyArray<CompletionItemTag>;
481 482 483 484
	/**
	 * A human-readable string with additional information
	 * about this item, like type or symbol information.
	 */
485
	detail?: string;
486 487 488
	/**
	 * A human-readable string that represents a doc-comment.
	 */
489
	documentation?: string | IMarkdownString;
490 491 492 493 494
	/**
	 * A string that should be used when comparing this item
	 * with other items. When `falsy` the [label](#CompletionItem.label)
	 * is used.
	 */
E
Erich Gamma 已提交
495
	sortText?: string;
496 497 498 499 500
	/**
	 * A string that should be used when filtering a set of
	 * completion items. When `falsy` the [label](#CompletionItem.label)
	 * is used.
	 */
501
	filterText?: string;
J
Johannes Rieken 已提交
502 503 504 505 506
	/**
	 * 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.
	 */
507
	preselect?: boolean;
508 509
	/**
	 * A string or snippet that should be inserted in a document when selecting
510
	 * this completion.
511 512
	 * is used.
	 */
513
	insertText: string;
514
	/**
515 516
	 * Addition rules (as bitmask) that should be applied when inserting
	 * this completion.
517
	 */
518
	insertTextRules?: CompletionItemInsertTextRule;
519 520 521 522 523 524 525 526 527
	/**
	 * 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).
	 */
J
Johannes Rieken 已提交
528
	range: IRange | { insert: IRange, replace: IRange };
529 530 531 532 533
	/**
	 * 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.
	 */
534
	commitCharacters?: string[];
535 536 537 538 539
	/**
	 * 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.
	 */
540
	additionalTextEdits?: model.ISingleEditOperation[];
541 542 543
	/**
	 * A command that should be run upon acceptance of this item.
	 */
544
	command?: Command;
J
Johannes Rieken 已提交
545 546 547 548

	/**
	 * @internal
	 */
549
	_id?: [number, number];
E
Erich Gamma 已提交
550 551
}

552 553
export interface CompletionList {
	suggestions: CompletionItem[];
E
Erich Gamma 已提交
554
	incomplete?: boolean;
555
	dispose?(): void;
556 557 558 559 560

	/**
	 * @internal
	 */
	duration?: number;
E
Erich Gamma 已提交
561 562
}

M
Matt Bierner 已提交
563 564 565
/**
 * How a suggest provider was triggered.
 */
566
export const enum CompletionTriggerKind {
M
Matt Bierner 已提交
567
	Invoke = 0,
568 569
	TriggerCharacter = 1,
	TriggerForIncompleteCompletions = 2
M
Matt Bierner 已提交
570
}
571
/**
572 573
 * Contains additional information about the context in which
 * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered.
574
 */
575
export interface CompletionContext {
576 577 578
	/**
	 * How the completion was triggered.
	 */
579
	triggerKind: CompletionTriggerKind;
580 581 582 583 584
	/**
	 * Character that triggered the completion item provider.
	 *
	 * `undefined` if provider was not triggered by a character.
	 */
585 586
	triggerCharacter?: string;
}
587
/**
588 589 590 591 592 593 594 595 596
 * 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).
597
 */
598
export interface CompletionItemProvider {
E
Erich Gamma 已提交
599

600 601 602 603 604
	/**
	 * @internal
	 */
	_debugDisplayName?: string;

605
	triggerCharacters?: string[];
606 607 608
	/**
	 * Provide completion items for the given position and document.
	 */
609
	provideCompletionItems(model: model.ITextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult<CompletionList>;
E
Erich Gamma 已提交
610

611 612 613 614 615 616
	/**
	 * 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.
	 */
617
	resolveCompletionItem?(item: CompletionItem, token: CancellationToken): ProviderResult<CompletionItem>;
E
Erich Gamma 已提交
618 619
}

620 621 622
export interface CodeAction {
	title: string;
	command?: Command;
623
	edit?: WorkspaceEdit;
624
	diagnostics?: IMarkerData[];
M
Matt Bierner 已提交
625
	kind?: string;
626
	isPreferred?: boolean;
M
Matt Bierner 已提交
627
	disabled?: string;
M
Matt Bierner 已提交
628 629
}

630 631 632
/**
 * @internal
 */
633 634
export const enum CodeActionTriggerType {
	Auto = 1,
635 636 637
	Manual = 2,
}

M
Matt Bierner 已提交
638 639 640 641 642
/**
 * @internal
 */
export interface CodeActionContext {
	only?: string;
643
	trigger: CodeActionTriggerType;
644 645
}

646 647 648 649
export interface CodeActionList extends IDisposable {
	readonly actions: ReadonlyArray<CodeAction>;
}

A
Alex Dima 已提交
650 651 652
/**
 * The code action interface defines the contract between extensions and
 * the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
653
 * @internal
A
Alex Dima 已提交
654
 */
655
export interface CodeActionProvider {
656 657 658

	displayName?: string

A
Alex Dima 已提交
659 660 661
	/**
	 * Provide commands for the given document and range.
	 */
662
	provideCodeActions(model: model.ITextModel, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<CodeActionList>;
663

664
	/**
J
Johannes Rieken 已提交
665
	 * Given a code action fill in the edit. Will only invoked when missing.
666 667 668
	 */
	resolveCodeAction?(codeAction: CodeAction, token: CancellationToken): ProviderResult<CodeAction>;

669
	/**
670
	 * Optional list of CodeActionKinds that this provider returns.
671
	 */
672 673 674
	readonly providedCodeActionKinds?: ReadonlyArray<string>;

	readonly documentation?: ReadonlyArray<{ readonly kind: string, readonly command: Command }>;
675 676 677 678 679

	/**
	 * @internal
	 */
	_getAdditionalMenuItems?(context: CodeActionContext, actions: readonly CodeAction[]): Command[];
E
Erich Gamma 已提交
680 681
}

A
Alex Dima 已提交
682 683 684 685
/**
 * Represents a parameter of a callable-signature. A parameter can
 * have a label and a doc-comment.
 */
686
export interface ParameterInformation {
A
Alex Dima 已提交
687 688 689 690
	/**
	 * The label of this signature. Will be shown in
	 * the UI.
	 */
691
	label: string | [number, number];
A
Alex Dima 已提交
692 693 694 695
	/**
	 * The human-readable doc-comment of this signature. Will be shown
	 * in the UI but can be omitted.
	 */
696
	documentation?: string | IMarkdownString;
E
Erich Gamma 已提交
697
}
A
Alex Dima 已提交
698 699 700 701 702
/**
 * Represents the signature of something callable. A signature
 * can have a label, like a function-name, a doc-comment, and
 * a set of parameters.
 */
703
export interface SignatureInformation {
A
Alex Dima 已提交
704 705 706 707
	/**
	 * The label of this signature. Will be shown in
	 * the UI.
	 */
708
	label: string;
A
Alex Dima 已提交
709 710 711 712
	/**
	 * The human-readable doc-comment of this signature. Will be shown
	 * in the UI but can be omitted.
	 */
713
	documentation?: string | IMarkdownString;
A
Alex Dima 已提交
714 715 716
	/**
	 * The parameters of this signature.
	 */
717
	parameters: ParameterInformation[];
718 719 720 721 722 723
	/**
	 * Index of the active parameter.
	 *
	 * If provided, this is used in place of `SignatureHelp.activeSignature`.
	 */
	activeParameter?: number;
E
Erich Gamma 已提交
724
}
A
Alex Dima 已提交
725 726 727 728 729
/**
 * Signature help represents the signature of something
 * callable. There can be multiple signatures but only one
 * active and only one active parameter.
 */
730
export interface SignatureHelp {
A
Alex Dima 已提交
731 732 733
	/**
	 * One or more signatures.
	 */
734
	signatures: SignatureInformation[];
A
Alex Dima 已提交
735 736 737
	/**
	 * The active signature.
	 */
738
	activeSignature: number;
A
Alex Dima 已提交
739 740 741
	/**
	 * The active parameter of the active signature.
	 */
742
	activeParameter: number;
E
Erich Gamma 已提交
743
}
744

745 746 747 748
export interface SignatureHelpResult extends IDisposable {
	value: SignatureHelp;
}

M
Matt Bierner 已提交
749
export enum SignatureHelpTriggerKind {
750 751
	Invoke = 1,
	TriggerCharacter = 2,
752
	ContentChange = 3,
753 754 755
}

export interface SignatureHelpContext {
756
	readonly triggerKind: SignatureHelpTriggerKind;
757 758
	readonly triggerCharacter?: string;
	readonly isRetrigger: boolean;
759
	readonly activeSignatureHelp?: SignatureHelp;
760 761
}

A
Alex Dima 已提交
762 763
/**
 * The signature help provider interface defines the contract between extensions and
G
Greg Van Liew 已提交
764
 * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature.
A
Alex Dima 已提交
765
 */
A
Alex Dima 已提交
766
export interface SignatureHelpProvider {
767

A
Alex Dima 已提交
768 769
	readonly signatureHelpTriggerCharacters?: ReadonlyArray<string>;
	readonly signatureHelpRetriggerCharacters?: ReadonlyArray<string>;
770

A
Alex Dima 已提交
771 772 773
	/**
	 * Provide help for the signature at the given position and document.
	 */
774
	provideSignatureHelp(model: model.ITextModel, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult<SignatureHelpResult>;
E
Erich Gamma 已提交
775 776
}

A
Alex Dima 已提交
777 778 779
/**
 * A document highlight kind.
 */
780
export enum DocumentHighlightKind {
A
Alex Dima 已提交
781 782 783
	/**
	 * A textual occurrence.
	 */
784
	Text,
A
Alex Dima 已提交
785 786 787
	/**
	 * Read-access of a symbol, like reading a variable.
	 */
788
	Read,
A
Alex Dima 已提交
789 790 791
	/**
	 * Write-access of a symbol, like writing to a variable.
	 */
792 793
	Write
}
A
Alex Dima 已提交
794 795 796 797 798
/**
 * 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.
 */
799
export interface DocumentHighlight {
A
Alex Dima 已提交
800 801 802
	/**
	 * The range this highlight applies to.
	 */
A
Alex Dima 已提交
803
	range: IRange;
A
Alex Dima 已提交
804 805 806
	/**
	 * The highlight kind, default is [text](#DocumentHighlightKind.Text).
	 */
807
	kind?: DocumentHighlightKind;
E
Erich Gamma 已提交
808
}
A
Alex Dima 已提交
809 810 811 812
/**
 * The document highlight provider interface defines the contract between extensions and
 * the word-highlight-feature.
 */
813
export interface DocumentHighlightProvider {
A
Alex Dima 已提交
814 815 816 817
	/**
	 * Provide a set of document highlights, like all occurrences of a variable or
	 * all exit-points of a function.
	 */
818
	provideDocumentHighlights(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>;
E
Erich Gamma 已提交
819 820
}

A
Alexandru Dima 已提交
821
/**
822 823
 * The linked editing range provider interface defines the contract between extensions and
 * the linked editing feature.
A
Alexandru Dima 已提交
824
 */
825
export interface LinkedEditingRangeProvider {
P
Pine Wu 已提交
826 827

	/**
828
	 * Provide a list of ranges that can be edited together.
P
Pine Wu 已提交
829
	 */
830
	provideLinkedEditingRanges(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
M
Martin Aeschlimann 已提交
831 832 833
}

/**
834
 * Represents a list of ranges that can be edited together along with a word pattern to describe valid contents.
M
Martin Aeschlimann 已提交
835
 */
836
export interface LinkedEditingRanges {
M
Martin Aeschlimann 已提交
837
	/**
838 839
	 * A list of ranges that can be edited together. The ranges must have
	 * identical length and text content. The ranges cannot overlap
M
Martin Aeschlimann 已提交
840 841 842 843 844 845 846 847
	 */
	ranges: IRange[];

	/**
	 * An optional word pattern that describes valid contents for the given ranges.
	 * If no pattern is provided, the language configuration's word pattern will be used.
	 */
	wordPattern?: RegExp;
A
Alexandru Dima 已提交
848 849
}

A
Alex Dima 已提交
850 851 852 853
/**
 * Value-object that contains additional information when
 * requesting references.
 */
854
export interface ReferenceContext {
A
Alex Dima 已提交
855 856 857
	/**
	 * Include the declaration of the current symbol.
	 */
858 859
	includeDeclaration: boolean;
}
A
Alex Dima 已提交
860 861 862 863
/**
 * The reference provider interface defines the contract between extensions and
 * the [find references](https://code.visualstudio.com/docs/editor/editingevolved#_peek)-feature.
 */
864
export interface ReferenceProvider {
A
Alex Dima 已提交
865 866 867
	/**
	 * Provide a set of project-wide references for the given position and document.
	 */
868
	provideReferences(model: model.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult<Location[]>;
E
Erich Gamma 已提交
869 870
}

A
Alex Dima 已提交
871 872 873 874
/**
 * Represents a location inside a resource, such as a line
 * inside a text file.
 */
A
Alex Dima 已提交
875
export interface Location {
A
Alex Dima 已提交
876 877 878
	/**
	 * The resource identifier of this location.
	 */
879
	uri: URI;
A
Alex Dima 已提交
880 881 882
	/**
	 * The document range of this locations.
	 */
A
Alex Dima 已提交
883
	range: IRange;
E
Erich Gamma 已提交
884
}
885

J
Johannes Rieken 已提交
886 887 888 889 890 891 892 893 894
export interface LocationLink {
	/**
	 * A range to select where this link originates from.
	 */
	originSelectionRange?: IRange;

	/**
	 * The target uri this link points to.
	 */
M
Matt Bierner 已提交
895
	uri: URI;
J
Johannes Rieken 已提交
896 897 898 899

	/**
	 * The full range this link points to.
	 */
M
Matt Bierner 已提交
900
	range: IRange;
J
Johannes Rieken 已提交
901 902 903 904 905 906

	/**
	 * A range to select this link points to. Must be contained
	 * in `LocationLink.range`.
	 */
	targetSelectionRange?: IRange;
M
Matt Bierner 已提交
907 908
}

909 910 911
/**
 * @internal
 */
912 913 914 915 916 917 918
export function isLocationLink(thing: any): thing is LocationLink {
	return thing
		&& URI.isUri((thing as LocationLink).uri)
		&& Range.isIRange((thing as LocationLink).range)
		&& (Range.isIRange((thing as LocationLink).originSelectionRange) || Range.isIRange((thing as LocationLink).targetSelectionRange));
}

J
Johannes Rieken 已提交
919 920
export type Definition = Location | Location[] | LocationLink[];

A
Alex Dima 已提交
921 922 923 924 925
/**
 * 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.
 */
926
export interface DefinitionProvider {
A
Alex Dima 已提交
927 928 929
	/**
	 * Provide the definition of the symbol at the given position and document.
	 */
J
Johannes Rieken 已提交
930
	provideDefinition(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>;
931 932
}

933 934 935 936 937 938 939 940 941
/**
 * 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.
	 */
J
Johannes Rieken 已提交
942
	provideDeclaration(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>;
943 944
}

945
/**
946
 * The implementation provider interface defines the contract between extensions and
947
 * the go to implementation feature.
948
 */
M
Matt Bierner 已提交
949
export interface ImplementationProvider {
950 951 952
	/**
	 * Provide the implementation of the symbol at the given position and document.
	 */
J
Johannes Rieken 已提交
953
	provideImplementation(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>;
954
}
955

956 957 958 959 960 961 962 963
/**
 * 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.
	 */
J
Johannes Rieken 已提交
964
	provideTypeDefinition(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>;
965 966
}

A
Alex Dima 已提交
967 968 969
/**
 * A symbol kind.
 */
970
export const enum SymbolKind {
971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992
	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,
993 994
	Struct = 22,
	Event = 23,
995 996
	Operator = 24,
	TypeParameter = 25
997 998
}

999
export const enum SymbolTag {
1000 1001
	Deprecated = 1,
}
1002 1003 1004 1005

/**
 * @internal
 */
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078
export namespace SymbolKinds {

	const byName = new Map<string, SymbolKind>();
	byName.set('file', SymbolKind.File);
	byName.set('module', SymbolKind.Module);
	byName.set('namespace', SymbolKind.Namespace);
	byName.set('package', SymbolKind.Package);
	byName.set('class', SymbolKind.Class);
	byName.set('method', SymbolKind.Method);
	byName.set('property', SymbolKind.Property);
	byName.set('field', SymbolKind.Field);
	byName.set('constructor', SymbolKind.Constructor);
	byName.set('enum', SymbolKind.Enum);
	byName.set('interface', SymbolKind.Interface);
	byName.set('function', SymbolKind.Function);
	byName.set('variable', SymbolKind.Variable);
	byName.set('constant', SymbolKind.Constant);
	byName.set('string', SymbolKind.String);
	byName.set('number', SymbolKind.Number);
	byName.set('boolean', SymbolKind.Boolean);
	byName.set('array', SymbolKind.Array);
	byName.set('object', SymbolKind.Object);
	byName.set('key', SymbolKind.Key);
	byName.set('null', SymbolKind.Null);
	byName.set('enum-member', SymbolKind.EnumMember);
	byName.set('struct', SymbolKind.Struct);
	byName.set('event', SymbolKind.Event);
	byName.set('operator', SymbolKind.Operator);
	byName.set('type-parameter', SymbolKind.TypeParameter);

	const byKind = new Map<SymbolKind, string>();
	byKind.set(SymbolKind.File, 'file');
	byKind.set(SymbolKind.Module, 'module');
	byKind.set(SymbolKind.Namespace, 'namespace');
	byKind.set(SymbolKind.Package, 'package');
	byKind.set(SymbolKind.Class, 'class');
	byKind.set(SymbolKind.Method, 'method');
	byKind.set(SymbolKind.Property, 'property');
	byKind.set(SymbolKind.Field, 'field');
	byKind.set(SymbolKind.Constructor, 'constructor');
	byKind.set(SymbolKind.Enum, 'enum');
	byKind.set(SymbolKind.Interface, 'interface');
	byKind.set(SymbolKind.Function, 'function');
	byKind.set(SymbolKind.Variable, 'variable');
	byKind.set(SymbolKind.Constant, 'constant');
	byKind.set(SymbolKind.String, 'string');
	byKind.set(SymbolKind.Number, 'number');
	byKind.set(SymbolKind.Boolean, 'boolean');
	byKind.set(SymbolKind.Array, 'array');
	byKind.set(SymbolKind.Object, 'object');
	byKind.set(SymbolKind.Key, 'key');
	byKind.set(SymbolKind.Null, 'null');
	byKind.set(SymbolKind.EnumMember, 'enum-member');
	byKind.set(SymbolKind.Struct, 'struct');
	byKind.set(SymbolKind.Event, 'event');
	byKind.set(SymbolKind.Operator, 'operator');
	byKind.set(SymbolKind.TypeParameter, 'type-parameter');
	/**
	 * @internal
	 */
	export function fromString(value: string): SymbolKind | undefined {
		return byName.get(value);
	}
	/**
	 * @internal
	 */
	export function toString(kind: SymbolKind): string | undefined {
		return byKind.get(kind);
	}
	/**
	 * @internal
	 */
	export function toCssClassName(kind: SymbolKind, inline?: boolean): string {
1079 1080 1081 1082 1083 1084 1085
		const symbolName = byKind.get(kind);
		let codicon = symbolName && iconRegistry.get('symbol-' + symbolName);
		if (!codicon) {
			console.info('No codicon found for SymbolKind ' + kind);
			codicon = Codicon.symbolProperty;
		}
		return `${inline ? 'inline' : 'block'} ${codicon.classNames}`;
1086 1087
	}
}
1088

1089
export interface DocumentSymbol {
1090
	name: string;
1091
	detail: string;
1092
	kind: SymbolKind;
1093
	tags: ReadonlyArray<SymbolTag>;
1094
	containerName?: string;
1095 1096
	range: IRange;
	selectionRange: IRange;
1097
	children?: DocumentSymbol[];
1098
}
1099

A
Alex Dima 已提交
1100 1101
/**
 * The document symbol provider interface defines the contract between extensions and
L
Lars Hvam 已提交
1102
 * the [go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-symbol)-feature.
A
Alex Dima 已提交
1103
 */
1104
export interface DocumentSymbolProvider {
1105

1106
	displayName?: string;
1107

A
Alex Dima 已提交
1108 1109 1110
	/**
	 * Provide symbol information for the given document.
	 */
1111
	provideDocumentSymbols(model: model.ITextModel, token: CancellationToken): ProviderResult<DocumentSymbol[]>;
E
Erich Gamma 已提交
1112 1113
}

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

E
Erich Gamma 已提交
1116 1117 1118
/**
 * Interface used to format a model
 */
A
Alex Dima 已提交
1119 1120 1121 1122
export interface FormattingOptions {
	/**
	 * Size of a tab in spaces.
	 */
J
Johannes Rieken 已提交
1123
	tabSize: number;
A
Alex Dima 已提交
1124 1125 1126
	/**
	 * Prefer spaces over tabs.
	 */
J
Johannes Rieken 已提交
1127
	insertSpaces: boolean;
E
Erich Gamma 已提交
1128
}
A
Alex Dima 已提交
1129 1130 1131 1132
/**
 * The document formatting provider interface defines the contract between extensions and
 * the formatting-feature.
 */
1133
export interface DocumentFormattingEditProvider {
1134

1135 1136 1137 1138
	/**
	 * @internal
	 */
	readonly extensionId?: ExtensionIdentifier;
1139

1140 1141
	readonly displayName?: string;

A
Alex Dima 已提交
1142 1143 1144
	/**
	 * Provide formatting edits for a whole document.
	 */
1145
	provideDocumentFormattingEdits(model: model.ITextModel, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
1146
}
A
Alex Dima 已提交
1147 1148 1149 1150
/**
 * The document formatting provider interface defines the contract between extensions and
 * the formatting-feature.
 */
1151
export interface DocumentRangeFormattingEditProvider {
1152 1153 1154 1155
	/**
	 * @internal
	 */
	readonly extensionId?: ExtensionIdentifier;
1156

1157 1158
	readonly displayName?: string;

A
Alex Dima 已提交
1159 1160 1161 1162 1163 1164 1165
	/**
	 * 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.
	 */
1166
	provideDocumentRangeFormattingEdits(model: model.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
1167
}
A
Alex Dima 已提交
1168 1169 1170 1171
/**
 * The document formatting provider interface defines the contract between extensions and
 * the formatting-feature.
 */
1172
export interface OnTypeFormattingEditProvider {
1173 1174 1175 1176 1177 1178 1179


	/**
	 * @internal
	 */
	readonly extensionId?: ExtensionIdentifier;

1180
	autoFormatTriggerCharacters: string[];
1181

A
Alex Dima 已提交
1182 1183 1184 1185 1186 1187 1188
	/**
	 * 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.
	 */
1189
	provideOnTypeFormattingEdits(model: model.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
E
Erich Gamma 已提交
1190 1191
}

1192 1193 1194
/**
 * @internal
 */
E
Erich Gamma 已提交
1195 1196
export interface IInplaceReplaceSupportResult {
	value: string;
A
Alex Dima 已提交
1197
	range: IRange;
E
Erich Gamma 已提交
1198 1199
}

A
Alex Dima 已提交
1200 1201 1202
/**
 * A link inside the editor.
 */
1203
export interface ILink {
A
Alex Dima 已提交
1204
	range: IRange;
M
Martin Aeschlimann 已提交
1205
	url?: URI | string;
1206
	tooltip?: string;
E
Erich Gamma 已提交
1207
}
1208 1209 1210 1211 1212

export interface ILinksList {
	links: ILink[];
	dispose?(): void;
}
A
Alex Dima 已提交
1213 1214 1215
/**
 * A provider of links.
 */
A
Alex Dima 已提交
1216
export interface LinkProvider {
1217
	provideLinks(model: model.ITextModel, token: CancellationToken): ProviderResult<ILinksList>;
1218
	resolveLink?: (link: ILink, token: CancellationToken) => ProviderResult<ILink>;
E
Erich Gamma 已提交
1219 1220
}

J
Joao Moreno 已提交
1221
/**
J
Joao Moreno 已提交
1222
 * A color in RGBA format.
J
Joao Moreno 已提交
1223
 */
J
Joao Moreno 已提交
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246
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;
}

1247
/**
1248
 * String representations for a color
1249
 */
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266
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 已提交
1267
}
J
Joao Moreno 已提交
1268 1269 1270 1271

/**
 * A color range is a range in a text model which represents a color.
 */
1272
export interface IColorInformation {
J
Joao Moreno 已提交
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282

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

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

J
Joao Moreno 已提交
1285
/**
J
Joao Moreno 已提交
1286
 * A provider of colors for editor models.
J
Joao Moreno 已提交
1287
 */
R
rebornix 已提交
1288
export interface DocumentColorProvider {
J
Joao Moreno 已提交
1289 1290 1291
	/**
	 * Provides the color ranges for a specific model.
	 */
1292
	provideDocumentColors(model: model.ITextModel, token: CancellationToken): ProviderResult<IColorInformation[]>;
1293
	/**
1294
	 * Provide the string representations for a color.
1295
	 */
1296
	provideColorPresentations(model: model.ITextModel, colorInfo: IColorInformation, token: CancellationToken): ProviderResult<IColorPresentation[]>;
J
Joao Moreno 已提交
1297
}
1298

1299 1300 1301 1302
export interface SelectionRange {
	range: IRange;
}

1303 1304 1305 1306
export interface SelectionRangeProvider {
	/**
	 * Provide ranges that should be selected from the given position.
	 */
1307
	provideSelectionRanges(model: model.ITextModel, positions: Position[], token: CancellationToken): ProviderResult<SelectionRange[][]>;
1308 1309
}

1310 1311
export interface FoldingContext {
}
1312
/**
1313
 * A provider of folding ranges for editor models.
1314
 */
1315
export interface FoldingRangeProvider {
1316 1317 1318 1319 1320 1321

	/**
	 * An optional event to signal that the folding ranges from this provider have changed.
	 */
	onDidChange?: Event<this>;

1322
	/**
1323
	 * Provides the folding ranges for a specific model.
1324
	 */
1325
	provideFoldingRanges(model: model.ITextModel, context: FoldingContext, token: CancellationToken): ProviderResult<FoldingRange[]>;
1326 1327
}

1328
export interface FoldingRange {
1329 1330

	/**
1331
	 * The one-based start line of the range to fold. The folded area starts after the line's last character.
1332
	 */
1333
	start: number;
1334 1335

	/**
1336
	 * The one-based end line of the range to fold. The folded area ends with the line's last character.
1337
	 */
1338
	end: number;
1339 1340

	/**
1341 1342 1343 1344
	 * 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.
1345
	 */
1346
	kind?: FoldingRangeKind;
1347
}
1348
export class FoldingRangeKind {
1349
	/**
1350
	 * Kind for folding range representing a comment. The value of the kind is 'comment'.
1351
	 */
1352
	static readonly Comment = new FoldingRangeKind('comment');
1353
	/**
1354
	 * Kind for folding range representing a import. The value of the kind is 'imports'.
1355
	 */
1356
	static readonly Imports = new FoldingRangeKind('imports');
1357
	/**
1358 1359
	 * Kind for folding range representing regions (for example marked by `#region`, `#endregion`).
	 * The value of the kind is 'region'.
1360
	 */
1361 1362
	static readonly Region = new FoldingRangeKind('region');

1363
	/**
1364 1365 1366
	 * Creates a new [FoldingRangeKind](#FoldingRangeKind).
	 *
	 * @param value of the kind.
1367
	 */
1368 1369
	public constructor(public value: string) {
	}
1370 1371
}

1372

1373 1374 1375 1376
export interface WorkspaceEditMetadata {
	needsConfirmation: boolean;
	label: string;
	description?: string;
1377 1378 1379 1380
	/**
	 * @internal
	 */
	iconPath?: ThemeIcon | URI | { light: URI, dark: URI };
1381 1382 1383 1384 1385 1386 1387
}

export interface WorkspaceFileEditOptions {
	overwrite?: boolean;
	ignoreIfNotExists?: boolean;
	ignoreIfExists?: boolean;
	recursive?: boolean;
1388
	copy?: boolean;
I
isidor 已提交
1389
	folder?: boolean;
I
isidor 已提交
1390
	skipTrashBin?: boolean;
I
isidor 已提交
1391
	maxSize?: number;
1392 1393
}

1394
export interface WorkspaceFileEdit {
1395 1396
	oldUri?: URI;
	newUri?: URI;
1397 1398
	options?: WorkspaceFileEditOptions;
	metadata?: WorkspaceEditMetadata;
1399 1400
}

1401
export interface WorkspaceTextEdit {
E
Erich Gamma 已提交
1402
	resource: URI;
1403
	edit: TextEdit;
1404
	modelVersionId?: number;
1405
	metadata?: WorkspaceEditMetadata;
E
Erich Gamma 已提交
1406
}
1407

1408
export interface WorkspaceEdit {
1409
	edits: Array<WorkspaceTextEdit | WorkspaceFileEdit>;
E
Erich Gamma 已提交
1410
}
1411

1412
export interface Rejection {
1413
	rejectReason?: string;
1414
}
1415 1416 1417 1418 1419
export interface RenameLocation {
	range: IRange;
	text: string;
}

1420
export interface RenameProvider {
1421
	provideRenameEdits(model: model.ITextModel, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit & Rejection>;
1422
	resolveRenameLocation?(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<RenameLocation & Rejection>;
E
Erich Gamma 已提交
1423 1424
}

1425 1426 1427
/**
 * @internal
 */
1428
export interface AuthenticationSession {
1429
	id: string;
1430
	accessToken: string;
1431
	account: {
1432
		label: string;
1433 1434
		id: string;
	}
1435
	scopes: ReadonlyArray<string>;
1436
}
1437

1438 1439 1440 1441
/**
 * @internal
 */
export interface AuthenticationSessionsChangeEvent {
1442 1443 1444
	added: ReadonlyArray<string>;
	removed: ReadonlyArray<string>;
	changed: ReadonlyArray<string>;
1445 1446
}

1447 1448 1449 1450 1451 1452 1453 1454
/**
 * @internal
 */
export interface AuthenticationProviderInformation {
	id: string;
	label: string;
}

A
Alex Dima 已提交
1455
export interface Command {
E
Erich Gamma 已提交
1456 1457
	id: string;
	title: string;
1458
	tooltip?: string;
E
Erich Gamma 已提交
1459 1460
	arguments?: any[];
}
M
Matt Bierner 已提交
1461

P
Peng Lyu 已提交
1462 1463 1464 1465
/**
 * @internal
 */
export interface CommentThreadTemplate {
P
Peng Lyu 已提交
1466
	controllerHandle: number;
P
Peng Lyu 已提交
1467 1468 1469 1470 1471 1472
	label: string;
	acceptInputCommand?: Command;
	additionalCommands?: Command[];
	deleteCommand?: Command;
}

A
Alex Dima 已提交
1473 1474 1475
/**
 * @internal
 */
1476
export interface CommentInfo {
1477
	extensionId?: string;
1478
	threads: CommentThread[];
1479
	commentingRanges: CommentingRanges;
1480
}
M
Matt Bierner 已提交
1481

A
Alex Dima 已提交
1482 1483 1484
/**
 * @internal
 */
1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
export enum CommentThreadCollapsibleState {
	/**
	 * Determines an item is collapsed
	 */
	Collapsed = 0,
	/**
	 * Determines an item is expanded
	 */
	Expanded = 1
}

1496 1497 1498 1499 1500 1501 1502 1503 1504


/**
 * @internal
 */
export interface CommentWidget {
	commentThread: CommentThread;
	comment?: Comment;
	input: string;
P
Peng Lyu 已提交
1505 1506 1507 1508 1509 1510
	onDidChangeInput: Event<string>;
}

/**
 * @internal
 */
1511 1512 1513 1514
export interface CommentInput {
	value: string;
	uri: URI;
}
P
Peng Lyu 已提交
1515

1516 1517 1518
/**
 * @internal
 */
1519
export interface CommentThread {
R
rebornix 已提交
1520
	commentThreadHandle: number;
P
Peng Lyu 已提交
1521
	controllerHandle: number;
1522
	extensionId?: string;
1523
	threadId: string;
M
Matt Bierner 已提交
1524
	resource: string | null;
P
Peng Lyu 已提交
1525
	range: IRange;
1526
	label: string | undefined;
P
Peng Lyu 已提交
1527
	contextValue: string | undefined;
1528 1529
	comments: Comment[] | undefined;
	onDidChangeComments: Event<Comment[] | undefined>;
P
Peng Lyu 已提交
1530
	collapsibleState?: CommentThreadCollapsibleState;
R
rebornix 已提交
1531
	canReply: boolean;
M
Matt Bierner 已提交
1532
	input?: CommentInput;
1533
	onDidChangeInput: Event<CommentInput | undefined>;
P
Peng Lyu 已提交
1534
	onDidChangeRange: Event<IRange>;
1535
	onDidChangeLabel: Event<string | undefined>;
1536
	onDidChangeCollasibleState: Event<CommentThreadCollapsibleState | undefined>;
R
rebornix 已提交
1537
	onDidChangeCanReply: Event<boolean>;
P
Peng Lyu 已提交
1538
	isDisposed: boolean;
1539 1540
}

P
Peng Lyu 已提交
1541 1542 1543 1544 1545 1546 1547
/**
 * @internal
 */

export interface CommentingRanges {
	readonly resource: URI;
	ranges: IRange[];
P
Peng Lyu 已提交
1548 1549
}

P
Peng Lyu 已提交
1550 1551 1552 1553 1554
/**
 * @internal
 */
export interface CommentReaction {
	readonly label?: string;
P
Peng Lyu 已提交
1555 1556
	readonly iconPath?: UriComponents;
	readonly count?: number;
P
Peng Lyu 已提交
1557
	readonly hasReacted?: boolean;
1558
	readonly canEdit?: boolean;
P
Peng Lyu 已提交
1559
}
1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574

/**
 * @internal
 */
export interface CommentOptions {
	/**
	 * An optional string to show on the comment input box when it's collapsed.
	 */
	prompt?: string;

	/**
	 * An optional string to show as placeholder in the comment input box when it's focused.
	 */
	placeHolder?: string;
}
P
Peng Lyu 已提交
1575

P
Peng Lyu 已提交
1576 1577 1578 1579 1580 1581 1582 1583
/**
 * @internal
 */
export enum CommentMode {
	Editing = 0,
	Preview = 1
}

A
Alex Dima 已提交
1584 1585 1586
/**
 * @internal
 */
M
Matt Bierner 已提交
1587
export interface Comment {
P
Peng Lyu 已提交
1588
	readonly uniqueIdInThread: number;
M
Matt Bierner 已提交
1589 1590
	readonly body: IMarkdownString;
	readonly userName: string;
1591
	readonly userIconPath?: string;
P
Peng Lyu 已提交
1592
	readonly contextValue?: string;
P
Peng Lyu 已提交
1593
	readonly commentReactions?: CommentReaction[];
1594
	readonly label?: string;
P
Peng Lyu 已提交
1595
	readonly mode?: CommentMode;
M
Matt Bierner 已提交
1596 1597
}

A
Alex Dima 已提交
1598 1599 1600
/**
 * @internal
 */
1601 1602 1603 1604
export interface CommentThreadChangedEvent {
	/**
	 * Added comment threads.
	 */
1605
	readonly added: CommentThread[];
1606 1607 1608 1609

	/**
	 * Removed comment threads.
	 */
1610
	readonly removed: CommentThread[];
1611 1612 1613 1614

	/**
	 * Changed comment threads.
	 */
1615
	readonly changed: CommentThread[];
M
Matt Bierner 已提交
1616 1617
}

1618 1619 1620 1621 1622 1623 1624 1625
/**
 * @internal
 */
export interface IWebviewPortMapping {
	webviewPort: number;
	extensionHostPort: number;
}

1626 1627 1628 1629 1630 1631
/**
 * @internal
 */
export interface IWebviewOptions {
	readonly enableScripts?: boolean;
	readonly enableCommandUris?: boolean;
1632
	readonly localResourceRoots?: ReadonlyArray<UriComponents>;
1633
	readonly portMapping?: ReadonlyArray<IWebviewPortMapping>;
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643
}

/**
 * @internal
 */
export interface IWebviewPanelOptions {
	readonly enableFindWidget?: boolean;
	readonly retainContextWhenHidden?: boolean;
}

1644

1645
export interface CodeLens {
A
Alex Dima 已提交
1646
	range: IRange;
E
Erich Gamma 已提交
1647
	id?: string;
A
Alex Dima 已提交
1648
	command?: Command;
E
Erich Gamma 已提交
1649
}
1650 1651 1652 1653 1654 1655

export interface CodeLensList {
	lenses: CodeLens[];
	dispose(): void;
}

1656
export interface CodeLensProvider {
1657
	onDidChange?: Event<this>;
1658 1659
	provideCodeLenses(model: model.ITextModel, token: CancellationToken): ProviderResult<CodeLensList>;
	resolveCodeLens?(model: model.ITextModel, codeLens: CodeLens, token: CancellationToken): ProviderResult<CodeLens>;
E
Erich Gamma 已提交
1660 1661
}

1662
export interface SemanticTokensLegend {
A
wip  
Alexandru Dima 已提交
1663 1664 1665 1666
	readonly tokenTypes: string[];
	readonly tokenModifiers: string[];
}

1667 1668
export interface SemanticTokens {
	readonly resultId?: string;
A
wip  
Alexandru Dima 已提交
1669
	readonly data: Uint32Array;
1670
}
A
wip  
Alexandru Dima 已提交
1671

1672 1673 1674 1675
export interface SemanticTokensEdit {
	readonly start: number;
	readonly deleteCount: number;
	readonly data?: Uint32Array;
A
wip  
Alexandru Dima 已提交
1676 1677
}

1678 1679 1680
export interface SemanticTokensEdits {
	readonly resultId?: string;
	readonly edits: SemanticTokensEdit[];
A
wip  
Alexandru Dima 已提交
1681 1682
}

1683
export interface DocumentSemanticTokensProvider {
1684
	onDidChange?: Event<void>;
1685
	getLegend(): SemanticTokensLegend;
1686 1687 1688 1689 1690
	provideDocumentSemanticTokens(model: model.ITextModel, lastResultId: string | null, token: CancellationToken): ProviderResult<SemanticTokens | SemanticTokensEdits>;
	releaseDocumentSemanticTokens(resultId: string | undefined): void;
}

export interface DocumentRangeSemanticTokensProvider {
1691
	getLegend(): SemanticTokensLegend;
1692
	provideDocumentRangeSemanticTokens(model: model.ITextModel, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>;
A
wip  
Alexandru Dima 已提交
1693 1694
}

1695 1696
// --- feature registries ------

1697 1698 1699
/**
 * @internal
 */
1700
export const ReferenceProviderRegistry = new LanguageFeatureRegistry<ReferenceProvider>();
1701

1702 1703 1704
/**
 * @internal
 */
1705
export const RenameProviderRegistry = new LanguageFeatureRegistry<RenameProvider>();
1706

1707 1708 1709
/**
 * @internal
 */
1710
export const CompletionProviderRegistry = new LanguageFeatureRegistry<CompletionItemProvider>();
1711

1712 1713 1714
/**
 * @internal
 */
1715
export const SignatureHelpProviderRegistry = new LanguageFeatureRegistry<SignatureHelpProvider>();
1716

1717 1718 1719
/**
 * @internal
 */
1720
export const HoverProviderRegistry = new LanguageFeatureRegistry<HoverProvider>();
1721

1722 1723 1724 1725 1726
/**
 * @internal
 */
export const EvaluatableExpressionProviderRegistry = new LanguageFeatureRegistry<EvaluatableExpressionProvider>();

1727 1728 1729
/**
 * @internal
 */
1730
export const DocumentSymbolProviderRegistry = new LanguageFeatureRegistry<DocumentSymbolProvider>();
1731

1732 1733 1734
/**
 * @internal
 */
1735
export const DocumentHighlightProviderRegistry = new LanguageFeatureRegistry<DocumentHighlightProvider>();
1736

A
Alexandru Dima 已提交
1737 1738 1739
/**
 * @internal
 */
1740
export const LinkedEditingRangeProviderRegistry = new LanguageFeatureRegistry<LinkedEditingRangeProvider>();
A
Alexandru Dima 已提交
1741

1742 1743 1744
/**
 * @internal
 */
1745
export const DefinitionProviderRegistry = new LanguageFeatureRegistry<DefinitionProvider>();
1746

1747 1748 1749 1750 1751
/**
 * @internal
 */
export const DeclarationProviderRegistry = new LanguageFeatureRegistry<DeclarationProvider>();

1752 1753 1754
/**
 * @internal
 */
M
Matt Bierner 已提交
1755
export const ImplementationProviderRegistry = new LanguageFeatureRegistry<ImplementationProvider>();
1756

1757 1758 1759 1760 1761
/**
 * @internal
 */
export const TypeDefinitionProviderRegistry = new LanguageFeatureRegistry<TypeDefinitionProvider>();

1762 1763 1764
/**
 * @internal
 */
1765
export const CodeLensProviderRegistry = new LanguageFeatureRegistry<CodeLensProvider>();
1766

1767 1768 1769
/**
 * @internal
 */
1770
export const CodeActionProviderRegistry = new LanguageFeatureRegistry<CodeActionProvider>();
1771

1772 1773 1774
/**
 * @internal
 */
1775 1776
export const DocumentFormattingEditProviderRegistry = new LanguageFeatureRegistry<DocumentFormattingEditProvider>();

1777 1778 1779
/**
 * @internal
 */
1780
export const DocumentRangeFormattingEditProviderRegistry = new LanguageFeatureRegistry<DocumentRangeFormattingEditProvider>();
1781

1782 1783 1784
/**
 * @internal
 */
1785
export const OnTypeFormattingEditProviderRegistry = new LanguageFeatureRegistry<OnTypeFormattingEditProvider>();
1786

1787 1788 1789
/**
 * @internal
 */
A
Alex Dima 已提交
1790
export const LinkProviderRegistry = new LanguageFeatureRegistry<LinkProvider>();
1791

J
Joao Moreno 已提交
1792 1793 1794
/**
 * @internal
 */
R
rebornix 已提交
1795
export const ColorProviderRegistry = new LanguageFeatureRegistry<DocumentColorProvider>();
J
Joao Moreno 已提交
1796

1797 1798 1799 1800 1801
/**
 * @internal
 */
export const SelectionRangeRegistry = new LanguageFeatureRegistry<SelectionRangeProvider>();

1802 1803 1804
/**
 * @internal
 */
1805
export const FoldingRangeProviderRegistry = new LanguageFeatureRegistry<FoldingRangeProvider>();
1806

A
wip  
Alexandru Dima 已提交
1807 1808 1809
/**
 * @internal
 */
1810 1811 1812 1813 1814 1815
export const DocumentSemanticTokensProviderRegistry = new LanguageFeatureRegistry<DocumentSemanticTokensProvider>();

/**
 * @internal
 */
export const DocumentRangeSemanticTokensProviderRegistry = new LanguageFeatureRegistry<DocumentRangeSemanticTokensProvider>();
A
wip  
Alexandru Dima 已提交
1816

1817 1818 1819 1820
/**
 * @internal
 */
export interface ITokenizationSupportChangedEvent {
A
Alex Dima 已提交
1821 1822
	changedLanguages: string[];
	changedColorMap: boolean;
1823 1824 1825 1826 1827
}

/**
 * @internal
 */
1828
export interface ITokenizationRegistry {
A
Alex Dima 已提交
1829 1830 1831 1832 1833 1834

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

1837 1838 1839 1840
	/**
	 * Fire a change event for a language.
	 * This is useful for languages that embed other languages.
	 */
1841
	fire(languages: string[]): void;
1842

A
Alex Dima 已提交
1843 1844 1845
	/**
	 * Register a tokenization support.
	 */
1846
	register(language: string, support: ITokenizationSupport): IDisposable;
1847

1848 1849 1850
	/**
	 * Register a promise for a tokenization support.
	 */
1851
	registerPromise(language: string, promise: Thenable<ITokenizationSupport>): IDisposable;
1852

A
Alex Dima 已提交
1853 1854
	/**
	 * Get the tokenization support for a language.
1855
	 * Returns `null` if not found.
A
Alex Dima 已提交
1856
	 */
1857
	get(language: string): ITokenizationSupport | null;
A
Alex Dima 已提交
1858

1859 1860 1861 1862
	/**
	 * 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.
	 */
1863
	getPromise(language: string): Thenable<ITokenizationSupport> | null;
1864

A
Alex Dima 已提交
1865 1866 1867
	/**
	 * Set the new color map that all tokens will use in their ColorId binary encoded bits for foreground and background.
	 */
1868
	setColorMap(colorMap: Color[]): void;
A
Alex Dima 已提交
1869

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

A
Alex Dima 已提交
1872
	getDefaultBackground(): Color | null;
1873 1874 1875 1876 1877 1878
}

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