coordinatesConverter.ts ×14

Frontier kind: Code frontier

unlabeled · c_ef1a41075f9a

23 tests · 39107 LOC · 241 files · introduces 0 tests · 65 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges65 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4514 ranges39107 lines · 241 files · Browse complete extent
All tests (intent)
23 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 14 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/coordinatesConverter.ts 65 introduced LOC · 14 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- coordinatesConverter.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 { Position } from './core/position.js';
7 > import { Range } from './core/range.js';
8 > import { ITextModel, PositionAffinity } from './model.js';
9 >
10 > export interface ICoordinatesConverter {
11 > // View -> Model conversion and related methods
12 > convertViewPositionToModelPosition(viewPosition: Position): Position;
13 > convertViewRangeToModelRange(viewRange: Range): Range;
14 > validateViewPosition(viewPosition: Position, expectedModelPosition: Position): Position;
15 > validateViewRange(viewRange: Range, expectedModelRange: Range): Range;
16 >
17 > // Model -> View conversion and related methods
18 > /**
19 > * @param allowZeroLineNumber Should it return 0 when there are hidden lines at the top and the position is in the hidden area?
20 > * @param belowHiddenRanges When the model position is in a hidden area, should it return the first view position after or before?
21 > */
22 > convertModelPositionToViewPosition(modelPosition: Position, affinity?: PositionAffinity, allowZeroLineNumber?: boolean, belowHiddenRanges?: boolean): Position;
23 > /**
24 > * @param affinity Only has an effect if the range is empty.
25 > */
26 > convertModelRangeToViewRange(modelRange: Range, affinity?: PositionAffinity): Range;
27 > modelPositionIsVisible(modelPosition: Position): boolean;
28 > getModelLineViewLineCount(modelLineNumber: number): number;
29 > getViewLineNumberOfModelPosition(modelLineNumber: number, modelColumn: number): number;
30 > }
31 >
32 > export class IdentityCoordinatesConverter implements ICoordinatesConverter {
33 >
34 > private readonly _model: ITextModel;
35 >
36 > constructor(model: ITextModel) {
37 this._model = model;
38 }
40 > private _validPosition(pos: Position): Position {
41 return this._model.validatePosition(pos);
42 }
44 > private _validRange(range: Range): Range {
45 return this._model.validateRange(range);
46 }
48 > // View -> Model conversion and related methods
49 >
50 > public convertViewPositionToModelPosition(viewPosition: Position): Position {
51 return this._validPosition(viewPosition);
52 }
54 > public convertViewRangeToModelRange(viewRange: Range): Range {
55 return this._validRange(viewRange);
56 }
58 > public validateViewPosition(_viewPosition: Position, expectedModelPosition: Position): Position {
59 return this._validPosition(expectedModelPosition);
60 }
62 > public validateViewRange(_viewRange: Range, expectedModelRange: Range): Range {
63 return this._validRange(expectedModelRange);
64 }
66 > // Model -> View conversion and related methods
67 >
68 > public convertModelPositionToViewPosition(modelPosition: Position): Position {
69 return this._validPosition(modelPosition);
70 }
72 > public convertModelRangeToViewRange(modelRange: Range): Range {
73 return this._validRange(modelRange);
74 }
76 > public modelPositionIsVisible(modelPosition: Position): boolean {
77 const lineCount = this._model.getLineCount();
78 if (modelPosition.lineNumber < 1 || modelPosition.lineNumber > lineCount) {
82 return true;
83 }
85 > public modelRangeIsVisible(modelRange: Range): boolean {
86 const lineCount = this._model.getLineCount();
87 if (modelRange.startLineNumber < 1 || modelRange.startLineNumber > lineCount) {