Merge from vscode a234f13c45b40a0929777cb440ee011b7549eed2 (#8911)

* Merge from vscode a234f13c45b40a0929777cb440ee011b7549eed2

* update distro

* fix layering

* update distro

* fix tests
This commit is contained in:
Anthony Dresser
2020-01-22 13:42:37 -08:00
committed by GitHub
parent 977111eb21
commit bd7aac8ee0
895 changed files with 24651 additions and 14520 deletions

View File

@@ -71,11 +71,8 @@ export namespace TokenStyle {
while ((match = expression.exec(fontStyle))) {
switch (match[0]) {
case 'bold': bold = true; break;
case '-bold': bold = false; break;
case 'italic': italic = true; break;
case '-italic': italic = false; break;
case 'underline': underline = true; break;
case '-underline': underline = false; break;
}
}
}
@@ -99,14 +96,13 @@ export interface TokenStyleDefaults {
}
export interface TokenStylingDefaultRule {
classification: TokenClassification;
matchScore: number;
match(classification: TokenClassification): number;
selector: TokenClassification;
defaults: TokenStyleDefaults;
}
export interface TokenStylingRule {
classification: TokenClassification;
matchScore: number;
match(classification: TokenClassification): number;
value: TokenStyle;
}
@@ -220,10 +216,10 @@ class TokenClassificationRegistry implements ITokenClassificationRegistry {
},
fontStyle: {
type: 'string',
description: nls.localize('schema.token.fontStyle', 'Font style of the rule: \'italic\', \'bold\' or \'underline\', \'-italic\', \'-bold\' or \'-underline\'or a combination. The empty string unsets inherited settings.'),
description: nls.localize('schema.token.fontStyle', 'Font style of the rule: \'italic\', \'bold\' or \'underline\' or a combination. The empty string unsets inherited settings.'),
pattern: fontStylePattern,
patternErrorMessage: nls.localize('schema.fontStyle.error', 'Font style must be \'italic\', \'bold\' or \'underline\' to set a style or \'-italic\', \'-bold\' or \'-underline\' to unset or a combination. The empty string unsets all styles.'),
defaultSnippets: [{ label: nls.localize('schema.token.fontStyle.none', 'None (clear inherited style)'), bodyText: '""' }, { body: 'italic' }, { body: 'bold' }, { body: 'underline' }, { body: '-italic' }, { body: '-bold' }, { body: '-underline' }, { body: 'italic bold' }, { body: 'italic underline' }, { body: 'bold underline' }, { body: 'italic bold underline' }]
patternErrorMessage: nls.localize('schema.fontStyle.error', 'Font style must be \'italic\', \'bold\' or \'underline\' or a combination. The empty string unsets all styles.'),
defaultSnippets: [{ label: nls.localize('schema.token.fontStyle.none', 'None (clear inherited style)'), bodyText: '""' }, { body: 'italic' }, { body: 'bold' }, { body: 'underline' }, { body: 'italic underline' }, { body: 'bold underline' }, { body: 'italic bold underline' }]
}
},
additionalProperties: false,
@@ -279,16 +275,35 @@ class TokenClassificationRegistry implements ITokenClassificationRegistry {
return { type: tokenTypeDesc.num, modifiers: allModifierBits };
}
public getTokenStylingRule(classification: TokenClassification, value: TokenStyle): TokenStylingRule {
return { classification, matchScore: getTokenStylingScore(classification), value };
private newMatcher(selector: TokenClassification) {
const score = getTokenStylingScore(selector);
return (classification: TokenClassification) => {
const selectorType = selector.type;
if (selectorType !== TOKEN_TYPE_WILDCARD_NUM && selectorType !== classification.type) {
return -1;
}
const selectorModifier = selector.modifiers;
if ((classification.modifiers & selectorModifier) !== selectorModifier) {
return -1;
}
return score;
};
}
public registerTokenStyleDefault(classification: TokenClassification, defaults: TokenStyleDefaults): void {
this.tokenStylingDefaultRules.push({ classification, matchScore: getTokenStylingScore(classification), defaults });
public getTokenStylingRule(selector: TokenClassification, value: TokenStyle): TokenStylingRule {
return {
match: this.newMatcher(selector),
value
};
}
public registerTokenStyleDefault(selector: TokenClassification, defaults: TokenStyleDefaults): void {
this.tokenStylingDefaultRules.push({ selector, match: this.newMatcher(selector), defaults });
}
public deregisterTokenStyleDefault(classification: TokenClassification): void {
this.tokenStylingDefaultRules = this.tokenStylingDefaultRules.filter(r => !(r.classification.type === classification.type && r.classification.modifiers === classification.modifiers));
this.tokenStylingDefaultRules = this.tokenStylingDefaultRules.filter(r => !(r.selector.type === classification.type && r.selector.modifiers === classification.modifiers));
}
public deregisterTokenType(id: string): void {
@@ -333,18 +348,6 @@ class TokenClassificationRegistry implements ITokenClassificationRegistry {
}
export function matchTokenStylingRule(themeSelector: TokenStylingRule | TokenStylingDefaultRule, classification: TokenClassification): number {
const selectorType = themeSelector.classification.type;
if (selectorType !== TOKEN_TYPE_WILDCARD_NUM && selectorType !== classification.type) {
return -1;
}
const selectorModifier = themeSelector.classification.modifiers;
if ((classification.modifiers & selectorModifier) !== selectorModifier) {
return -1;
}
return themeSelector.matchScore;
}
const tokenClassificationRegistry = new TokenClassificationRegistry();
platform.Registry.add(Extensions.TokenClassificationContribution, tokenClassificationRegistry);
@@ -378,7 +381,7 @@ function registerDefaultClassifications(): void {
registerTokenType('class', nls.localize('class', "Style for classes."), [['entity.name.class']], 'type');
registerTokenType('interface', nls.localize('interface', "Style for interfaces."), undefined, 'type');
registerTokenType('enum', nls.localize('enum', "Style for enums."), undefined, 'type');
registerTokenType('parameterType', nls.localize('parameterType', "Style for parameter types."), undefined, 'type');
registerTokenType('typeParameter', nls.localize('typeParameter', "Style for type parameters."), undefined, 'type');
registerTokenType('function', nls.localize('function', "Style for functions"), [['entity.name.function'], ['support.function']]);
registerTokenType('member', nls.localize('member', "Style for member"), [['entity.name.function'], ['support.function']]);
@@ -395,12 +398,12 @@ function registerDefaultClassifications(): void {
tokenClassificationRegistry.registerTokenModifier('declaration', nls.localize('declaration', "Style for all symbol declarations."), undefined);
tokenClassificationRegistry.registerTokenModifier('documentation', nls.localize('documentation', "Style to use for references in documentation."), undefined);
//tokenClassificationRegistry.registerTokenModifier('member', nls.localize('member', "Style to use for member functions, variables (fields) and types."), undefined);
tokenClassificationRegistry.registerTokenModifier('static', nls.localize('static', "Style to use for symbols that are static."), undefined);
tokenClassificationRegistry.registerTokenModifier('abstract', nls.localize('abstract', "Style to use for symbols that are abstract."), undefined);
tokenClassificationRegistry.registerTokenModifier('deprecated', nls.localize('deprecated', "Style to use for symbols that are deprecated."), undefined);
tokenClassificationRegistry.registerTokenModifier('modification', nls.localize('modification', "Style to use for write accesses."), undefined);
tokenClassificationRegistry.registerTokenModifier('async', nls.localize('async', "Style to use for symbols that are async."), undefined);
tokenClassificationRegistry.registerTokenModifier('readonly', nls.localize('readonly', "Style to use for symbols that are readonly."), undefined);
}
export function getTokenClassificationRegistry(): ITokenClassificationRegistry {

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { isWindows, isMacintosh } from 'vs/base/common/platform';
import { systemPreferences, ipcMain as ipc } from 'electron';
import { ipcMain as ipc, nativeTheme } from 'electron';
import { IStateService } from 'vs/platform/state/node/state';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@@ -42,14 +42,14 @@ export class ThemeMainService implements IThemeMainService {
}
getBackgroundColor(): string {
if (isWindows && systemPreferences.isInvertedColorScheme()) {
if (isWindows && nativeTheme.shouldUseInvertedColorScheme) {
return DEFAULT_BG_HC_BLACK;
}
let background = this.stateService.getItem<string | null>(THEME_BG_STORAGE_KEY, null);
if (!background) {
let baseTheme: string;
if (isWindows && systemPreferences.isInvertedColorScheme()) {
if (isWindows && nativeTheme.shouldUseInvertedColorScheme) {
baseTheme = 'hc-black';
} else {
baseTheme = this.stateService.getItem<string>(THEME_STORAGE_KEY, 'vs-dark').split(' ')[0];