defaultDocumentColorsComputer.ts ×12

Frontier kind: Code frontier

unlabeled · c_362d6d5d8128

12 tests · 3769 LOC · 20 files · introduces 0 tests · 54 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges54 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
557 ranges3769 lines · 20 files · Browse complete extent
All tests (intent)
12 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.

Introduced files, introduced tests, and structurally relevant concept specializationdefaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl with decimal hue values should work|occurrence=1 · 0 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl with space separator (CSS Level 4 syntax) should work|occurrence=1 · 0 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsla with decimal values should work|occurrence=1 · 0 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.ts ×1 · 3 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl 100 percent saturation works with decimals|occurrence=1, defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl 100 percent saturation works without decimals|occurrence=1 · 0 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl not 100 percent saturation should also work|occurrence=1 · 0 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.ts ×1 · 2 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.ts ×2 · 11 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer 8-digit hex colors should also work|occurrence=1 · 0 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer Existing functionality should still work|occurrence=1, defaultDocumentColorsComputer.test|title=Default Document Colors Computer Hex colors in strings should be detected|occurrence=1, +2 · 0 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.ts ×4 · 11 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.ts ×4 · 16 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.ts ×1 · 1 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.ts ×2 · 11 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.ts ×1 · 1 introduced LOCdefaultDocumentColorsCom…defaultDocumentColorsComputer.ts ×9 · 27 introduced LOCdefaultDocumentColorsCom…color.ts ×55 · 308 introduced LOCcolor.ts ×55uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/color.ts · 942 LOCcommon/color.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/editor/common/languages/defaultDocumentColorsComputer.ts · 152 LOClanguages/defaultDocumen…src/vs/nls.ts · 244 LOCvs/nls.tscharCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…defaultDocumentColorsComputer.test|title=Default Document Colors Computer 8-digit hex colors should also work|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer 8-digit hex colors should also work|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer Existing functionality should still work|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer Existing functionality should still work|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer Hex colors in double quotes should be detected|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer Hex colors in double quotes should be detected|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer Hex colors in strings should be detected|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer Hex colors in strings should be detected|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer Multiple hex colors in array should be detected|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer Multiple hex colors in array should be detected|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl 100 percent saturation works with decimals|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl 100 percent saturation works with decimals|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl 100 percent saturation works without decimals|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl 100 percent saturation works without decimals|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl not 100 percent saturation should also work|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl not 100 percent saturation should also work|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl with decimal hue values should work|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl with decimal hue values should work|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl with space separator (CSS Level 4 syntax) should work|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsl with space separator (CSS Level 4 syntax) should work|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsla with decimal values should work|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer hsla with decimal values should work|occurrence=1defaultDocumentColorsCom…defaultDocumentColorsComputer.test|title=Default Document Colors Computer rgb and rgba with CSS Level 4 space-separated syntax should work|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/languages/defaultDocumentColorsComputer.test|title=Default Document Colors Computer rgb and rgba with CSS Level 4 space-separated syntax should work|occurrence=1defaultDocumentColorsCom…Focused concept · defaultDocumentColorsComputer.ts ×12 · 54 introduced LOCdefaultDocumentColorsCom…

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: 54 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/languages/defaultDocumentColorsComputer.ts 54 introduced LOC · 12 ranges

Open complete file

25 }
26
27 > function _toIColor(r: number, g: number, b: number, a: number): IColor { defaultDocumentColorsComputer.ts
28 > return {
29 > red: r / 255,
30 > blue: b / 255,
31 > green: g / 255,
32 > alpha: a
33 > };
34 > }
35
36 > function _findRange(model: IDocumentColorComputerTarget, match: RegExpMatchArray): IRange | undefined { defaultDocumentColorsComputer.ts
37 > const index = match.index;
38 > const length = match[0].length;
39 > if (index === undefined) {
40 return;
41 }
42 > const startPosition = model.positionAt(index); defaultDocumentColorsComputer.ts
43 > const range: IRange = {
44 > startLineNumber: startPosition.lineNumber,
45 > startColumn: startPosition.column,
46 > endLineNumber: startPosition.lineNumber,
47 > endColumn: startPosition.column + length
48 > };
49 > return range;
50 > }
51
52 function _findHexColorInformation(range: IRange | undefined, hexValue: string) {
91 }
92
93 > function _findMatches(model: IDocumentColorComputerTarget | string, regex: RegExp): RegExpMatchArray[] { defaultDocumentColorsComputer.ts
94 > if (typeof model === 'string') {
95 return [...model.matchAll(regex)];
97 > return model.findMatches(regex);
98 > }
99 > }
100
101 > function computeColors(model: IDocumentColorComputerTarget): IColorInformation[] { defaultDocumentColorsComputer.ts
102 > const result: IColorInformation[] = [];
103 > // Early validation for RGB and HSL (including CSS Level 4 syntax with / separator)
104 > const initialValidationRegex = /\b(rgb|rgba|hsl|hsla)(\([0-9\s,.\%\/]*\))|^(#)([A-Fa-f0-9]{3})\b|^(#)([A-Fa-f0-9]{4})\b|^(#)([A-Fa-f0-9]{6})\b|^(#)([A-Fa-f0-9]{8})\b|(?<=['"\s])(#)([A-Fa-f0-9]{3})\b|(?<=['"\s])(#)([A-Fa-f0-9]{4})\b|(?<=['"\s])(#)([A-Fa-f0-9]{6})\b|(?<=['"\s])(#)([A-Fa-f0-9]{8})\b/gm;
105 > const initialValidationMatches = _findMatches(model, initialValidationRegex);
106 >
107 > // Potential colors have been found, validate the parameters
108 > if (initialValidationMatches.length > 0) {
109 > for (const initialMatch of initialValidationMatches) {
110 > const initialCaptureGroups = initialMatch.filter(captureGroup => captureGroup !== undefined);
111 > const colorScheme = initialCaptureGroups[1];
112 > const colorParameters = initialCaptureGroups[2];
113 > if (!colorParameters) {
114 continue;
115 }
116 > let colorInformation; defaultDocumentColorsComputer.ts
117 > if (colorScheme === 'rgb') {
118 // Supports both comma-separated (rgb(255, 0, 0)) and CSS Level 4 space-separated syntax (rgb(255 0 0))
119 const regexParameters = /^\(\s*(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\s*[\s,]\s*(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\s*[\s,]\s*(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\s*\)$/gm;
120 colorInformation = _findRGBColorInformation(_findRange(model, initialMatch), _findMatches(colorParameters, regexParameters), false);
121 > } else if (colorScheme === 'rgba') { defaultDocumentColorsComputer.ts
122 // Supports both comma-separated (rgba(255, 0, 0, 0.5)) and CSS Level 4 syntax (rgba(255 0 0 / 0.5))
123 const regexParameters = /^\(\s*(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\s*[\s,]\s*(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\s*[\s,]\s*(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\s*(?:[\s,]|[\s]*\/)\s*(0[.][0-9]+|[.][0-9]+|[01][.]|[01])\s*\)$/gm;
124 colorInformation = _findRGBColorInformation(_findRange(model, initialMatch), _findMatches(colorParameters, regexParameters), true);
125 > } else if (colorScheme === 'hsl') { defaultDocumentColorsComputer.ts
126 const regexParameters = /^\(\s*((?:360(?:\.0+)?|(?:36[0]|3[0-5][0-9]|[12][0-9][0-9]|[1-9]?[0-9])(?:\.\d+)?))\s*[\s,]\s*(100(?:\.0+)?|\d{1,2}[.]\d*|\d{1,2})%\s*[\s,]\s*(100(?:\.0+)?|\d{1,2}[.]\d*|\d{1,2})%\s*\)$/gm;
127 colorInformation = _findHSLColorInformation(_findRange(model, initialMatch), _findMatches(colorParameters, regexParameters), false);
133 colorInformation = _findHexColorInformation(_findRange(model, initialMatch), colorScheme + colorParameters);
134 }
135 > if (colorInformation) { defaultDocumentColorsComputer.ts
136 > result.push(colorInformation);
137 > }
138 > }
139 > }
140 > return result;
141 > }
142
143 /**
145 */
146 export function computeDefaultDocumentColors(model: IDocumentColorComputerTarget): IColorInformation[] {
147 > if (!model || typeof model.getValue !== 'function' || typeof model.positionAt !== 'function') { defaultDocumentColorsComputer.ts
148 // Unknown caller!
149 return [];
150 }
151 > return computeColors(model); defaultDocumentColorsComputer.ts
152 > }