colorThemeData.ts ×13

Frontier kind: Code frontier

unlabeled · c_080aee2f2e0f

4 tests · 31610 LOC · 176 files · introduces 0 tests · 114 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
23 ranges114 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3455 ranges31610 lines · 176 files · Browse complete extent
All tests (intent)
4 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: 114 introduced LOC across 23 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/themes/common/textMateScopeMatcher.ts 60 introduced LOC · 10 ranges

Open complete file

16
17 export function createMatchers<T>(selector: string, matchesName: (names: string[], matcherInput: T) => number, results: MatcherWithPriority<T>[]): void {
18 > const tokenizer = newTokenizer(selector); textMateScopeMatcher.ts
19 > let token = tokenizer.next();
20 > while (token !== null) {
21 > let priority: -1 | 0 | 1 = 0;
22 > if (token.length === 2 && token.charAt(1) === ':') {
23 switch (token.charAt(0)) {
24 case 'R': priority = 1; break;
29 token = tokenizer.next();
30 }
31 > const matcher = parseConjunction(); textMateScopeMatcher.ts
32 > if (matcher) {
33 > results.push({ matcher, priority });
34 > }
35 > if (token !== ',') {
36 > break;
37 > }
38 token = tokenizer.next();
39 }
41 > function parseOperand(): Matcher<T> | null {
42 > if (token === '-') {
43 token = tokenizer.next();
44 const expressionToNegate = parseOperand();
51 };
52 }
53 > if (token === '(') { textMateScopeMatcher.ts
54 token = tokenizer.next();
55 const expressionInParents = parseInnerExpression();
59 return expressionInParents;
60 }
61 > if (isIdentifier(token)) { textMateScopeMatcher.ts
62 > const identifiers: string[] = [];
63 > do {
64 > identifiers.push(token);
65 > token = tokenizer.next();
66 > } while (isIdentifier(token));
67 > return matcherInput => matchesName(identifiers, matcherInput);
68 > }
69 > return null;
70 > }
71 > function parseConjunction(): Matcher<T> | null {
72 > let matcher = parseOperand();
73 > if (!matcher) {
74 return null;
75 }
77 > const matchers: Matcher<T>[] = [];
78 > while (matcher) {
79 > matchers.push(matcher);
80 > matcher = parseOperand();
81 > }
82 > return matcherInput => { // and
83 > let min = matchers[0](matcherInput);
84 > for (let i = 1; min >= 0 && i < matchers.length; i++) {
85 min = Math.min(min, matchers[i](matcherInput));
86 }
87 > return min; textMateScopeMatcher.ts
88 > };
89 > }
90 > function parseInnerExpression(): Matcher<T> | null {
91 let matcher = parseConjunction();
92 if (!matcher) {
113 };
114 }
116
117 > function isIdentifier(token: string | null): token is string { textMateScopeMatcher.ts
118 > return !!token && !!token.match(/[\w\.:]+/);
119 > }
120
121 > function newTokenizer(input: string): { next: () => string | null } { textMateScopeMatcher.ts
122 > const regex = /([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g;
123 > let match = regex.exec(input);
124 > return {
125 > next: () => {
126 > if (!match) {
127 > return null;
128 > }
129 > const res = match[0];
130 > match = regex.exec(input);
131 > return res;
132 > }
133 > };
134 > }
src/vs/workbench/services/themes/common/colorThemeData.ts 54 introduced LOC · 13 ranges

Open complete file

353 function findTokenStyleForScopeInScopes(scopeMatchers: Matcher<ProbeScope>[], themingRules: ITextMateThemingRule[]) {
354 for (let i = 0; i < scopeMatchers.length; i++) {
355 > const score = scopeMatchers[i](scope); colorThemeData.ts
356 > if (score >= 0) {
357 > const themingRule = themingRules[i];
358 > const settings = themingRules[i].settings;
359 > if (score >= foregroundScore && settings.foreground) {
360 > foreground = settings.foreground;
361 > foregroundScore = score;
362 > foregroundThemingRule = themingRule;
363 > }
364 > if (score >= fontStyleScore && types.isString(settings.fontStyle)) {
365 fontStyle = settings.fontStyle;
366 fontStyleScore = score;
367 fontStyleThemingRule = themingRule;
368 }
370 > }
371 }
372 findTokenStyleForScopeInScopes(this.themeTokenScopeMatchers, this.themeTokenColors);
373 findTokenStyleForScopeInScopes(this.customTokenScopeMatchers, this.customTokenColors);
374 if (foreground !== undefined || fontStyle !== undefined) {
375 > if (definitions) { colorThemeData.ts
376 definitions.foreground = foregroundThemingRule;
377 definitions.bold = definitions.italic = definitions.underline = definitions.strikethrough = fontStyleThemingRule;
378 definitions.scope = scope;
379 }
381 > return TokenStyle.fromSettings(foreground, fontStyle);
382 > }
383 }
384 return undefined;
850 const noMatch = (_scope: ProbeScope) => -1;
851
852 > function nameMatcher(identifiers: string[], scopes: ProbeScope): number { colorThemeData.ts
853 > if (scopes.length < identifiers.length) {
854 return -1;
855 }
857 > let score: number | undefined = undefined;
858 > const every = identifiers.every((identifier) => {
859 > for (let i = scopes.length - 1; i >= 0; i--) {
860 > if (scopesAreMatching(scopes[i], identifier)) {
861 > score = (i + 1) * 0x10000 + identifier.length;
862 > return true;
863 > }
864 > }
865 return false;
866 > }); colorThemeData.ts
867 > return every && score !== undefined ? score : -1;
868 > }
869 > function scopesAreMatching(thisScopeName: string, scopeName: string): boolean {
870 > if (!thisScopeName) {
871 return false;
872 }
873 > if (thisScopeName === scopeName) { colorThemeData.ts
874 > return true;
875 > }
876 > const len = scopeName.length;
877 > return thisScopeName.length > len && thisScopeName.substr(0, len) === scopeName && thisScopeName[len] === '.';
878 > }
879
880 > function getScopeMatcher(rule: ITextMateThemingRule): Matcher<ProbeScope> { colorThemeData.ts
881 > const ruleScope = rule.scope;
882 > if (!ruleScope || !rule.settings) {
883 return noMatch;
884 }
885 > const matchers: MatcherWithPriority<ProbeScope>[] = []; colorThemeData.ts
886 > if (Array.isArray(ruleScope)) {
887 for (const rs of ruleScope) {
888 createMatchers(rs, nameMatcher, matchers);
889 }
890 > } else { colorThemeData.ts
891 > createMatchers(ruleScope, nameMatcher, matchers);
892 > }
893 >
894 > if (matchers.length === 0) {
895 return noMatch;
896 }
897 > return (scope: ProbeScope) => { colorThemeData.ts
898 > let max = matchers[0].matcher(scope);
899 > for (let i = 1; i < matchers.length; i++) {
900 max = Math.max(max, matchers[i].matcher(scope));
901 }
902 > return max; colorThemeData.ts
903 > };
904 > }
905
906 function readSemanticTokenRule(selectorString: string, settings: ISemanticTokenColorizationSetting | string | boolean | undefined): SemanticTokenRule | undefined {