Path: blob/main/src/vs/editor/common/tokenizationTextModelPart.ts
3292 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Range } from './core/range.js';6import { StandardTokenType } from './encodedTokenAttributes.js';7import { LineTokens } from './tokens/lineTokens.js';8import { SparseMultilineTokens } from './tokens/sparseMultilineTokens.js';910/**11* Provides tokenization related functionality of the text model.12*/13export interface ITokenizationTextModelPart {14readonly hasTokens: boolean;1516/**17* Replaces all semantic tokens with the provided `tokens`.18* @internal19*/20setSemanticTokens(tokens: SparseMultilineTokens[] | null, isComplete: boolean): void;2122/**23* Merges the provided semantic tokens into existing semantic tokens.24* @internal25*/26setPartialSemanticTokens(range: Range, tokens: SparseMultilineTokens[] | null): void;2728/**29* @internal30*/31hasCompleteSemanticTokens(): boolean;3233/**34* @internal35*/36hasSomeSemanticTokens(): boolean;3738/**39* Flush all tokenization state.40* @internal41*/42resetTokenization(): void;4344/**45* Force tokenization information for `lineNumber` to be accurate.46* @internal47*/48forceTokenization(lineNumber: number): void;4950/**51* If it is cheap, force tokenization information for `lineNumber` to be accurate.52* This is based on a heuristic.53* @internal54*/55tokenizeIfCheap(lineNumber: number): void;5657/**58* Check if tokenization information is accurate for `lineNumber`.59* @internal60*/61hasAccurateTokensForLine(lineNumber: number): boolean;6263/**64* Check if calling `forceTokenization` for this `lineNumber` will be cheap (time-wise).65* This is based on a heuristic.66* @internal67*/68isCheapToTokenize(lineNumber: number): boolean;6970/**71* Get the tokens for the line `lineNumber`.72* The tokens might be inaccurate. Use `forceTokenization` to ensure accurate tokens.73* @internal74*/75getLineTokens(lineNumber: number): LineTokens;7677/**78* Returns the standard token type for a character if the character were to be inserted at79* the given position. If the result cannot be accurate, it returns null.80* @internal81*/82getTokenTypeIfInsertingCharacter(lineNumber: number, column: number, character: string): StandardTokenType;8384/**85* Tokens the lines as if they were inserted at [lineNumber, lineNumber).86* @internal87*/88tokenizeLinesAt(lineNumber: number, lines: string[]): LineTokens[] | null;8990getLanguageId(): string;91getLanguageIdAtPosition(lineNumber: number, column: number): string;9293setLanguageId(languageId: string, source?: string): void;9495readonly backgroundTokenizationState: BackgroundTokenizationState;96}9798export const enum BackgroundTokenizationState {99InProgress = 1,100Completed = 2,101}102103104