mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 03:58:33 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import { IContextKey, IContext, IContextKeyServiceTarget, IContextKeyService, SET_CONTEXT_COMMAND_ID, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextKey, IContext, IContextKeyServiceTarget, IContextKeyService, SET_CONTEXT_COMMAND_ID, ContextKeyExpr, IContextKeyChangeEvent } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfigurationService, IConfigurationChangeEvent, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import Event, { Emitter, debounceEvent } from 'vs/base/common/event';
|
||||
|
||||
@@ -37,7 +37,11 @@ export class Context implements IContext {
|
||||
|
||||
public removeValue(key: string): boolean {
|
||||
// console.log('REMOVE ' + key + ' FROM ' + this._id);
|
||||
return delete this._value[key];
|
||||
if (key in this._value) {
|
||||
delete this._value[key];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public getValue<T>(key: string): T {
|
||||
@@ -51,11 +55,11 @@ export class Context implements IContext {
|
||||
|
||||
class ConfigAwareContextValuesContainer extends Context {
|
||||
|
||||
private readonly _emitter: Emitter<string>;
|
||||
private readonly _emitter: Emitter<string | string[]>;
|
||||
private readonly _subscription: IDisposable;
|
||||
private readonly _configurationService: IConfigurationService;
|
||||
|
||||
constructor(id: number, configurationService: IConfigurationService, emitter: Emitter<string>) {
|
||||
constructor(id: number, configurationService: IConfigurationService, emitter: Emitter<string | string[]>) {
|
||||
super(id, null);
|
||||
|
||||
this._emitter = emitter;
|
||||
@@ -86,14 +90,10 @@ class ConfigAwareContextValuesContainer extends Context {
|
||||
|
||||
private _initFromConfiguration() {
|
||||
|
||||
const config = this._configurationService.getConfiguration();
|
||||
|
||||
// remove old config.xyz values
|
||||
for (let key in this._value) {
|
||||
if (key.indexOf('config.') === 0) {
|
||||
delete this._value[key];
|
||||
}
|
||||
}
|
||||
const prefix = 'config.';
|
||||
const config = this._configurationService.getValue();
|
||||
const configKeys: { [key: string]: boolean } = Object.create(null);
|
||||
const configKeysChanged: string[] = [];
|
||||
|
||||
// add new value from config
|
||||
const walk = (obj: any, keys: string[]) => {
|
||||
@@ -103,8 +103,14 @@ class ConfigAwareContextValuesContainer extends Context {
|
||||
let value = obj[key];
|
||||
if (typeof value === 'boolean') {
|
||||
const configKey = keys.join('.');
|
||||
const oldValue = this._value[configKey];
|
||||
this._value[configKey] = value;
|
||||
this._emitter.fire(configKey);
|
||||
if (oldValue !== value) {
|
||||
configKeysChanged.push(configKey);
|
||||
configKeys[configKey] = true;
|
||||
} else {
|
||||
configKeys[configKey] = false;
|
||||
}
|
||||
} else if (typeof value === 'object') {
|
||||
walk(value, keys);
|
||||
}
|
||||
@@ -113,6 +119,18 @@ class ConfigAwareContextValuesContainer extends Context {
|
||||
}
|
||||
};
|
||||
walk(config, ['config']);
|
||||
|
||||
// remove unused keys
|
||||
for (let key in this._value) {
|
||||
if (key.indexOf(prefix) === 0 && configKeys[key] === undefined) {
|
||||
delete this._value[key];
|
||||
configKeys[key] = true;
|
||||
configKeysChanged.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
// send events
|
||||
this._emitter.fire(configKeysChanged);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,11 +164,33 @@ class ContextKey<T> implements IContextKey<T> {
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyChangeEvent implements IContextKeyChangeEvent {
|
||||
|
||||
private _keys: string[] = [];
|
||||
|
||||
collect(oneOrManyKeys: string | string[]): void {
|
||||
if (Array.isArray(oneOrManyKeys)) {
|
||||
this._keys = this._keys.concat(oneOrManyKeys);
|
||||
} else {
|
||||
this._keys.push(oneOrManyKeys);
|
||||
}
|
||||
}
|
||||
|
||||
affectsSome(keys: Set<string>): boolean {
|
||||
for (const key of this._keys) {
|
||||
if (keys.has(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class AbstractContextKeyService implements IContextKeyService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
protected _onDidChangeContext: Event<string[]>;
|
||||
protected _onDidChangeContextKey: Emitter<string>;
|
||||
protected _onDidChangeContext: Event<IContextKeyChangeEvent>;
|
||||
protected _onDidChangeContextKey: Emitter<string | string[]>;
|
||||
protected _myContextId: number;
|
||||
|
||||
constructor(myContextId: number) {
|
||||
@@ -164,14 +204,13 @@ export abstract class AbstractContextKeyService implements IContextKeyService {
|
||||
return new ContextKey(this, key, defaultValue);
|
||||
}
|
||||
|
||||
public get onDidChangeContext(): Event<string[]> {
|
||||
public get onDidChangeContext(): Event<IContextKeyChangeEvent> {
|
||||
if (!this._onDidChangeContext) {
|
||||
this._onDidChangeContext = debounceEvent(this._onDidChangeContextKey.event, (prev: string[], cur) => {
|
||||
this._onDidChangeContext = debounceEvent<string | string[], ContextKeyChangeEvent>(this._onDidChangeContextKey.event, (prev, cur) => {
|
||||
if (!prev) {
|
||||
prev = [cur];
|
||||
} else if (prev.indexOf(cur) < 0) {
|
||||
prev.push(cur);
|
||||
prev = new ContextKeyChangeEvent();
|
||||
}
|
||||
prev.collect(cur);
|
||||
return prev;
|
||||
}, 25);
|
||||
}
|
||||
@@ -196,7 +235,11 @@ export abstract class AbstractContextKeyService implements IContextKeyService {
|
||||
}
|
||||
|
||||
public setContext(key: string, value: any): void {
|
||||
if (this.getContextValuesContainer(this._myContextId).setValue(key, value)) {
|
||||
const myContext = this.getContextValuesContainer(this._myContextId);
|
||||
if (!myContext) {
|
||||
return;
|
||||
}
|
||||
if (myContext.setValue(key, value)) {
|
||||
this._onDidChangeContextKey.fire(key);
|
||||
}
|
||||
}
|
||||
@@ -270,7 +313,7 @@ class ScopedContextKeyService extends AbstractContextKeyService {
|
||||
private _parent: AbstractContextKeyService;
|
||||
private _domNode: IContextKeyServiceTarget;
|
||||
|
||||
constructor(parent: AbstractContextKeyService, emitter: Emitter<string>, domNode?: IContextKeyServiceTarget) {
|
||||
constructor(parent: AbstractContextKeyService, emitter: Emitter<string | string[]>, domNode?: IContextKeyServiceTarget) {
|
||||
super(parent.createChildContext());
|
||||
this._parent = parent;
|
||||
this._onDidChangeContextKey = emitter;
|
||||
@@ -288,7 +331,7 @@ class ScopedContextKeyService extends AbstractContextKeyService {
|
||||
}
|
||||
}
|
||||
|
||||
public get onDidChangeContext(): Event<string[]> {
|
||||
public get onDidChangeContext(): Event<IContextKeyChangeEvent> {
|
||||
return this._parent.onDidChangeContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ export class ContextKeyNotExpr implements ContextKeyExpr {
|
||||
}
|
||||
|
||||
export class ContextKeyAndExpr implements ContextKeyExpr {
|
||||
private expr: ContextKeyExpr[];
|
||||
public readonly expr: ContextKeyExpr[];
|
||||
|
||||
constructor(expr: ContextKeyExpr[]) {
|
||||
this.expr = ContextKeyAndExpr._normalizeArr(expr);
|
||||
@@ -461,11 +461,15 @@ export interface IContextKeyServiceTarget {
|
||||
|
||||
export const IContextKeyService = createDecorator<IContextKeyService>('contextKeyService');
|
||||
|
||||
export interface IContextKeyChangeEvent {
|
||||
affectsSome(keys: Set<string>): boolean;
|
||||
}
|
||||
|
||||
export interface IContextKeyService {
|
||||
_serviceBrand: any;
|
||||
dispose(): void;
|
||||
|
||||
onDidChangeContext: Event<string[]>;
|
||||
onDidChangeContext: Event<IContextKeyChangeEvent>;
|
||||
createKey<T>(key: string, defaultValue: T): IContextKey<T>;
|
||||
contextMatchesRules(rules: ContextKeyExpr): boolean;
|
||||
getContextKeyValue<T>(key: string): T;
|
||||
|
||||
Reference in New Issue
Block a user