inlineDecorations.ts ×10

Frontier kind: Code frontier

unlabeled · c_042f01b7157f

100 tests · 7245 LOC · 33 files · introduces 0 tests · 131 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges131 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
831 ranges7245 lines · 33 files · Browse complete extent
All tests (intent)
100 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.

2 files ranked by introduced lines: 131 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/viewModel/inlineDecorations.ts 102 introduced LOC · 10 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- inlineDecorations.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 { IModelDecoration, InjectedTextOptions, ITextModel, PositionAffinity } from '../model.js';
7 > import { Range } from '../core/range.js';
8 > import { Position } from '../core/position.js';
9 > import { ICoordinatesConverter } from '../coordinatesConverter.js';
10 > import { isModelDecorationVisible, ViewModelDecoration } from './viewModelDecoration.js';
11 >
12 > export const enum InlineDecorationType {
13 > Regular = 0,
14 > Before = 1,
15 > After = 2,
16 > RegularAffectingLetterSpacing = 3
17 > }
18 >
19 > export class InlineDecoration {
20 > constructor(
21 public readonly range: Range,
22 public readonly inlineClassName: string,
23 public readonly type: InlineDecorationType
24 ) { }
26 >
27 > /**
28 > * A collection of decorations in a range of lines.
29 > */
30 > export interface IViewDecorationsCollection {
31 > /**
32 > * decorations in the range of lines (ungrouped).
33 > */
34 > readonly decorations: ViewModelDecoration[];
35 > /**
36 > * inline decorations (grouped by each line in the range of lines).
37 > */
38 > readonly inlineDecorations: InlineDecoration[][];
39 > /**
40 > * Whether the decorations affect the fonts.
41 > */
42 > readonly hasVariableFonts: boolean[];
43 > }
44 >
45 > export interface IInlineDecorationsComputer {
46 > /**
47 > * Get the inline decorations for a specific model line number, split by view line number
48 > */
49 > getInlineDecorations(modelLineNumber: number): InlineDecoration[][];
50 > }
51 >
52 > export interface IInlineModelDecorationsComputerContext {
53 > /**
54 > * Get model decorations for a view range
55 > */
56 > getModelDecorations(viewRange: Range, onlyMinimapDecorations: boolean, onlyMarginDecorations: boolean): IModelDecoration[];
57 > }
58 >
59 > export class InlineModelDecorationsComputer implements IInlineDecorationsComputer {
60 >
61 > private _decorationsCache: { [decorationId: string]: ViewModelDecoration };
62 >
63 > constructor(
64 private readonly context: IInlineModelDecorationsComputerContext,
65 private readonly model: ITextModel,
68 this._decorationsCache = Object.create(null);
69 }
71 > public getInlineDecorations(modelLineNumber: number): InlineDecoration[][] {
72 const modelRange = new Range(modelLineNumber, 1, modelLineNumber, this.model.getLineMaxColumn(modelLineNumber));
73 const viewRange = this.coordinatesConverter.convertModelRangeToViewRange(modelRange);
75 return decorationsViewportData.inlineDecorations;
76 }
78 > public getDecorations(viewRange: Range, onlyMinimapDecorations: boolean, onlyMarginDecorations: boolean): IViewDecorationsCollection {
79 const modelDecorations = this.context.getModelDecorations(viewRange, onlyMinimapDecorations, onlyMarginDecorations);
80 const startLineNumber = viewRange.startLineNumber;
148 };
149 }
151 > public reset(): void {
152 this._decorationsCache = Object.create(null);
153 }
155 > public onModelDecorationsChanged(): void {
156 this.reset();
157 }
159 > public onLineMappingChanged(): void {
160 this.reset();
161 }
163 > private _getOrCreateViewModelDecoration(modelDecoration: IModelDecoration): ViewModelDecoration {
164 const id = modelDecoration.id;
165 let r = this._decorationsCache[id];
182 return r;
183 }
185 >
186 > export interface IInjectedTextInlineDecorationsComputerContext {
187 > /**
188 > * Get the injections options for a model line number
189 > */
190 > getInjectionOptions(modelLineNumber: number): InjectedTextOptions[] | null;
191 > /**
192 > * Get the injection offsets for a model line number
193 > */
194 > getInjectionOffsets(modelLineNumber: number): number[] | null;
195 > /**
196 > * Get the break offets for a model line number
197 > */
198 > getBreakOffsets(modelLineNumber: number): number[];
199 > /**
200 > * Get the wrapped text indent length for a model line number
201 > */
202 > getWrappedTextIndentLength(modelLineNumber: number): number;
203 > /**
204 > * Get the view line number for the first output line of a model line
205 > */
206 > getBaseViewLineNumber(modelLineNumber: number): number;
207 > }
208 >
209 > export class InjectedTextInlineDecorationsComputer implements IInlineDecorationsComputer {
210 >
211 > constructor(private readonly context: IInjectedTextInlineDecorationsComputerContext) { }
212 >
213 > public getInlineDecorations(modelLineNumber: number): InlineDecoration[][] {
214 const injectionOffsets = this.context.getInjectionOffsets(modelLineNumber);
215 if (!injectionOffsets) {
src/vs/editor/common/viewModel/viewModelDecoration.ts 29 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- viewModelDecoration.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 { IModelDecoration, IModelDecorationOptions, ITextModel } from '../model.js';
7 > import { Range } from '../core/range.js';
8 > import { StandardTokenType } from '../encodedTokenAttributes.js';
9 >
10 > export class ViewModelDecoration {
11 > _viewModelDecorationBrand: void = undefined;
12 >
13 > public readonly range: Range;
14 > public readonly options: IModelDecorationOptions;
15 >
16 > constructor(range: Range, options: IModelDecorationOptions) {
17 this.range = range;
18 this.options = options;
19 }
21 >
22 > export function isModelDecorationVisible(model: ITextModel, decoration: IModelDecoration): boolean {
23 if (decoration.options.hideInCommentTokens && isModelDecorationInComment(model, decoration)) {
24 return false;
31 return true;
32 }
34 > export function isModelDecorationInComment(model: ITextModel, decoration: IModelDecoration): boolean {
35 return testTokensInRange(
36 model,
39 );
40 }
42 > export function isModelDecorationInString(model: ITextModel, decoration: IModelDecoration): boolean {
43 return testTokensInRange(
44 model,
47 );
48 }
50 > /**
51 > * Calls the callback for every token that intersects the range.
52 > * If the callback returns `false`, iteration stops and `false` is returned.
53 > * Otherwise, `true` is returned.
54 > */
55 function testTokensInRange(model: ITextModel, range: Range, callback: (tokenType: StandardTokenType) => boolean): boolean {
56 for (let lineNumber = range.startLineNumber; lineNumber <= range.endLineNumber; lineNumber++) {