unicodeTextModelHighlighter.ts ×8

Frontier kind: Code frontier

unlabeled · c_950050ee88fb

17 tests · 14914 LOC · 62 files · introduces 0 tests · 65 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges65 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1667 ranges14914 lines · 62 files · Browse complete extent
All tests (intent)
17 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 65 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/services/unicodeTextModelHighlighter.ts 65 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- unicodeTextModelHighlighter.ts
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 { IRange, Range } from '../core/range.js';
7 > import { Searcher } from '../model/textModelSearch.js';
8 > import * as strings from '../../../base/common/strings.js';
9 > import { IUnicodeHighlightsResult } from './editorWorker.js';
10 > import { assertNever } from '../../../base/common/assert.js';
11 > import { DEFAULT_WORD_REGEXP, getWordAtText } from '../core/wordHelper.js';
12 >
13 > export class UnicodeTextModelHighlighter {
14 > public static computeUnicodeHighlights(model: IUnicodeCharacterSearcherTarget, options: UnicodeHighlighterOptions, range?: IRange): IUnicodeHighlightsResult {
15 const startLine = range ? range.startLineNumber : 1;
16 const endLine = range ? range.endLineNumber : model.getLineCount();
99 };
100 }
102 > public static computeUnicodeHighlightReason(char: string, options: UnicodeHighlighterOptions): UnicodeHighlighterReason | null {
103 const codePointHighlighter = new CodePointHighlighter(options);
104
126 }
127 }
129 >
130 function buildRegExpCharClassExpr(codePoints: number[], flags?: string): string {
131 const src = `[${strings.escapeRegExpCharacters(
134 return src;
135 }
137 > export const enum UnicodeHighlighterReasonKind {
138 > Ambiguous, Invisible, NonBasicAscii
139 > }
140 >
141 > export type UnicodeHighlighterReason = {
142 > kind: UnicodeHighlighterReasonKind.Ambiguous;
143 > confusableWith: string;
144 > notAmbiguousInLocales: string[];
145 > } | {
146 > kind: UnicodeHighlighterReasonKind.Invisible;
147 > } | {
148 > kind: UnicodeHighlighterReasonKind.NonBasicAscii;
149 > };
150 >
151 > class CodePointHighlighter {
152 > private readonly allowedCodePoints: Set<number>;
153 > public readonly ambiguousCharacters: strings.AmbiguousCharacters;
154 > constructor(private readonly options: UnicodeHighlighterOptions) {
155 this.allowedCodePoints = new Set(options.allowedCodePoints);
156 this.ambiguousCharacters = strings.AmbiguousCharacters.getInstance(new Set(options.allowedLocales));
157 }
159 > public getCandidateCodePoints(): Set<number> | 'allNonBasicAscii' {
160 if (this.options.nonBasicASCII) {
161 return 'allNonBasicAscii';
184 return set;
185 }
187 > public shouldHighlightNonBasicASCII(character: string, wordContext: string | null): SimpleHighlightReason {
188 const codePoint = character.codePointAt(0)!;
189
236 return SimpleHighlightReason.None;
237 }
239 >
240 function isAllowedInvisibleCharacter(character: string): boolean {
241 return character === ' ' || character === '\n' || character === '\t';
242 }
244 > const enum SimpleHighlightReason {
245 > None,
246 > NonBasicASCII,
247 > Invisible,
248 > Ambiguous
249 > }
250 >
251 > export interface IUnicodeCharacterSearcherTarget {
252 > getLineCount(): number;
253 > getLineContent(lineNumber: number): string;
254 > }
255 >
256 > export interface UnicodeHighlighterOptions {
257 > nonBasicASCII: boolean;
258 > ambiguousCharacters: boolean;
259 > invisibleCharacters: boolean;
260 > includeComments: boolean;
261 > includeStrings: boolean;
262 > allowedCodePoints: number[];
263 > allowedLocales: string[];
264 > }