forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenizationTextModelPart.ts
More file actions
108 lines (90 loc) · 3.16 KB
/
tokenizationTextModelPart.ts
File metadata and controls
108 lines (90 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { IPosition } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
import { ContiguousMultilineTokens } from 'vs/editor/common/tokens/contiguousMultilineTokens';
import { LineTokens } from 'vs/editor/common/tokens/lineTokens';
import { SparseMultilineTokens } from 'vs/editor/common/tokens/sparseMultilineTokens';
/**
* Provides tokenization related functionality of the text model.
*/
export interface ITokenizationTextModelPart {
/**
* @internal
*/
setTokens(tokens: ContiguousMultilineTokens[]): void;
/**
* Replaces all semantic tokens with the provided `tokens`.
* @internal
*/
setSemanticTokens(tokens: SparseMultilineTokens[] | null, isComplete: boolean): void;
/**
* Merges the provided semantic tokens into existing semantic tokens.
* @internal
*/
setPartialSemanticTokens(range: Range, tokens: SparseMultilineTokens[] | null): void;
/**
* @internal
*/
hasCompleteSemanticTokens(): boolean;
/**
* @internal
*/
hasSomeSemanticTokens(): boolean;
/**
* Flush all tokenization state.
* @internal
*/
resetTokenization(): void;
/**
* Force tokenization information for `lineNumber` to be accurate.
* @internal
*/
forceTokenization(lineNumber: number): void;
/**
* If it is cheap, force tokenization information for `lineNumber` to be accurate.
* This is based on a heuristic.
* @internal
*/
tokenizeIfCheap(lineNumber: number): void;
/**
* Check if calling `forceTokenization` for this `lineNumber` will be cheap (time-wise).
* This is based on a heuristic.
* @internal
*/
isCheapToTokenize(lineNumber: number): boolean;
/**
* Get the tokens for the line `lineNumber`.
* The tokens might be inaccurate. Use `forceTokenization` to ensure accurate tokens.
* @internal
*/
getLineTokens(lineNumber: number): LineTokens;
/**
* Returns the standard token type for a character if the character were to be inserted at
* the given position. If the result cannot be accurate, it returns null.
* @internal
*/
getTokenTypeIfInsertingCharacter(lineNumber: number, column: number, character: string): StandardTokenType;
/**
* @internal
*/
tokenizeLineWithEdit(position: IPosition, length: number, newText: string): LineTokens | null;
/**
* @internal
*/
tokenizeViewport(startLineNumber: number, endLineNumber: number): void;
getLanguageId(): string;
getLanguageIdAtPosition(lineNumber: number, column: number): string;
setLanguageId(languageId: string, source?: string): void;
readonly backgroundTokenizationState: BackgroundTokenizationState;
readonly onBackgroundTokenizationStateChanged: Event<void>;
}
export const enum BackgroundTokenizationState {
Uninitialized = 0,
InProgress = 1,
Completed = 2,
}