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;
867
>
return every && score !== undefined ? score : -1;
868
>
}
869
>
function scopesAreMatching(thisScopeName: string, scopeName: string): boolean {
870
>
if (!thisScopeName) {
871
return false;
872
}
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
}
886
>
if (Array.isArray(ruleScope)) {
887
for (const rs of ruleScope) {
888
createMatchers(rs, nameMatcher, matchers);
889
}
891
>
createMatchers(ruleScope, nameMatcher, matchers);
892
>
}
893
>
894
>
if (matchers.length === 0) {
895
return noMatch;
896
}
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
}
903
>
};
904
>
}
905
906
function readSemanticTokenRule(selectorString: string, settings: ISemanticTokenColorizationSetting | string | boolean | undefined): SemanticTokenRule | undefined {