Path: blob/main/src/vs/editor/common/languages/nullTokenize.ts
3296 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 { Token, TokenizationResult, EncodedTokenizationResult, IState } from '../languages.js';6import { LanguageId, FontStyle, ColorId, StandardTokenType, MetadataConsts } from '../encodedTokenAttributes.js';78export const NullState: IState = new class implements IState {9public clone(): IState {10return this;11}12public equals(other: IState): boolean {13return (this === other);14}15};1617export function nullTokenize(languageId: string, state: IState): TokenizationResult {18return new TokenizationResult([new Token(0, '', languageId)], state);19}2021export function nullTokenizeEncoded(languageId: LanguageId, state: IState | null): EncodedTokenizationResult {22const tokens = new Uint32Array(2);23tokens[0] = 0;24tokens[1] = (25(languageId << MetadataConsts.LANGUAGEID_OFFSET)26| (StandardTokenType.Other << MetadataConsts.TOKEN_TYPE_OFFSET)27| (FontStyle.None << MetadataConsts.FONT_STYLE_OFFSET)28| (ColorId.DefaultForeground << MetadataConsts.FOREGROUND_OFFSET)29| (ColorId.DefaultBackground << MetadataConsts.BACKGROUND_OFFSET)30) >>> 0;3132return new EncodedTokenizationResult(tokens, state === null ? NullState : state);33}343536