Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/common/languages/nullTokenize.ts
3296 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 { Token, TokenizationResult, EncodedTokenizationResult, IState } from '../languages.js';
7
import { LanguageId, FontStyle, ColorId, StandardTokenType, MetadataConsts } from '../encodedTokenAttributes.js';
8
9
export const NullState: IState = new class implements IState {
10
public clone(): IState {
11
return this;
12
}
13
public equals(other: IState): boolean {
14
return (this === other);
15
}
16
};
17
18
export function nullTokenize(languageId: string, state: IState): TokenizationResult {
19
return new TokenizationResult([new Token(0, '', languageId)], state);
20
}
21
22
export function nullTokenizeEncoded(languageId: LanguageId, state: IState | null): EncodedTokenizationResult {
23
const tokens = new Uint32Array(2);
24
tokens[0] = 0;
25
tokens[1] = (
26
(languageId << MetadataConsts.LANGUAGEID_OFFSET)
27
| (StandardTokenType.Other << MetadataConsts.TOKEN_TYPE_OFFSET)
28
| (FontStyle.None << MetadataConsts.FONT_STYLE_OFFSET)
29
| (ColorId.DefaultForeground << MetadataConsts.FOREGROUND_OFFSET)
30
| (ColorId.DefaultBackground << MetadataConsts.BACKGROUND_OFFSET)
31
) >>> 0;
32
33
return new EncodedTokenizationResult(tokens, state === null ? NullState : state);
34
}
35
36