Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/common/tokenizationTextModelPart.ts
3292 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Range } from './core/range.js';
7
import { StandardTokenType } from './encodedTokenAttributes.js';
8
import { LineTokens } from './tokens/lineTokens.js';
9
import { SparseMultilineTokens } from './tokens/sparseMultilineTokens.js';
10
11
/**
12
* Provides tokenization related functionality of the text model.
13
*/
14
export interface ITokenizationTextModelPart {
15
readonly hasTokens: boolean;
16
17
/**
18
* Replaces all semantic tokens with the provided `tokens`.
19
* @internal
20
*/
21
setSemanticTokens(tokens: SparseMultilineTokens[] | null, isComplete: boolean): void;
22
23
/**
24
* Merges the provided semantic tokens into existing semantic tokens.
25
* @internal
26
*/
27
setPartialSemanticTokens(range: Range, tokens: SparseMultilineTokens[] | null): void;
28
29
/**
30
* @internal
31
*/
32
hasCompleteSemanticTokens(): boolean;
33
34
/**
35
* @internal
36
*/
37
hasSomeSemanticTokens(): boolean;
38
39
/**
40
* Flush all tokenization state.
41
* @internal
42
*/
43
resetTokenization(): void;
44
45
/**
46
* Force tokenization information for `lineNumber` to be accurate.
47
* @internal
48
*/
49
forceTokenization(lineNumber: number): void;
50
51
/**
52
* If it is cheap, force tokenization information for `lineNumber` to be accurate.
53
* This is based on a heuristic.
54
* @internal
55
*/
56
tokenizeIfCheap(lineNumber: number): void;
57
58
/**
59
* Check if tokenization information is accurate for `lineNumber`.
60
* @internal
61
*/
62
hasAccurateTokensForLine(lineNumber: number): boolean;
63
64
/**
65
* Check if calling `forceTokenization` for this `lineNumber` will be cheap (time-wise).
66
* This is based on a heuristic.
67
* @internal
68
*/
69
isCheapToTokenize(lineNumber: number): boolean;
70
71
/**
72
* Get the tokens for the line `lineNumber`.
73
* The tokens might be inaccurate. Use `forceTokenization` to ensure accurate tokens.
74
* @internal
75
*/
76
getLineTokens(lineNumber: number): LineTokens;
77
78
/**
79
* Returns the standard token type for a character if the character were to be inserted at
80
* the given position. If the result cannot be accurate, it returns null.
81
* @internal
82
*/
83
getTokenTypeIfInsertingCharacter(lineNumber: number, column: number, character: string): StandardTokenType;
84
85
/**
86
* Tokens the lines as if they were inserted at [lineNumber, lineNumber).
87
* @internal
88
*/
89
tokenizeLinesAt(lineNumber: number, lines: string[]): LineTokens[] | null;
90
91
getLanguageId(): string;
92
getLanguageIdAtPosition(lineNumber: number, column: number): string;
93
94
setLanguageId(languageId: string, source?: string): void;
95
96
readonly backgroundTokenizationState: BackgroundTokenizationState;
97
}
98
99
export const enum BackgroundTokenizationState {
100
InProgress = 1,
101
Completed = 2,
102
}
103
104