Merge VS Code 1.21 source code (#1067)

* Initial VS Code 1.21 file copy with patches

* A few more merges

* Post npm install

* Fix batch of build breaks

* Fix more build breaks

* Fix more build errors

* Fix more build breaks

* Runtime fixes 1

* Get connection dialog working with some todos

* Fix a few packaging issues

* Copy several node_modules to package build to fix loader issues

* Fix breaks from master

* A few more fixes

* Make tests pass

* First pass of license header updates

* Second pass of license header updates

* Fix restore dialog issues

* Remove add additional themes menu items

* fix select box issues where the list doesn't show up

* formatting

* Fix editor dispose issue

* Copy over node modules to correct location on all platforms
This commit is contained in:
Karl Burtram
2018-04-04 15:27:51 -07:00
committed by GitHub
parent 5fba3e31b4
commit dafb780987
9412 changed files with 141255 additions and 98813 deletions

View File

@@ -51,6 +51,13 @@ export class Context implements IContext {
}
return ret;
}
collectAllValues(): { [key: string]: any; } {
let result = this._parent ? this._parent.collectAllValues() : Object.create(null);
result = { ...result, ...this._value };
delete result['_contextId'];
return result;
}
}
class ConfigAwareContextValuesContainer extends Context {
@@ -169,11 +176,7 @@ 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);
}
this._keys = this._keys.concat(oneOrManyKeys);
}
affectsSome(keys: Set<string>): boolean {

View File

@@ -6,13 +6,15 @@
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import Event from 'vs/base/common/event';
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
export enum ContextKeyExprType {
Defined = 1,
Not = 2,
Equals = 3,
NotEquals = 4,
And = 5
And = 5,
Regex = 6
}
export abstract class ContextKeyExpr {
@@ -29,6 +31,10 @@ export abstract class ContextKeyExpr {
return new ContextKeyNotEqualsExpr(key, value);
}
public static regex(key: string, value: RegExp): ContextKeyExpr {
return new ContextKeyRegexExpr(key, value);
}
public static not(key: string): ContextKeyExpr {
return new ContextKeyNotExpr(key);
}
@@ -60,6 +66,11 @@ export abstract class ContextKeyExpr {
return new ContextKeyEqualsExpr(pieces[0].trim(), this._deserializeValue(pieces[1]));
}
if (serializedOne.indexOf('=~') >= 0) {
let pieces = serializedOne.split('=~');
return new ContextKeyRegexExpr(pieces[0].trim(), this._deserializeRegexValue(pieces[1]));
}
if (/^\!\s*/.test(serializedOne)) {
return new ContextKeyNotExpr(serializedOne.substr(1).trim());
}
@@ -86,6 +97,29 @@ export abstract class ContextKeyExpr {
return serializedValue;
}
private static _deserializeRegexValue(serializedValue: string): RegExp {
if (isFalsyOrWhitespace(serializedValue)) {
console.warn('missing regexp-value for =~-expression');
return null;
}
let start = serializedValue.indexOf('/');
let end = serializedValue.lastIndexOf('/');
if (start === end || start < 0 /* || to < 0 */) {
console.warn(`bad regexp-value '${serializedValue}', missing /-enclosure`);
return null;
}
let value = serializedValue.slice(start + 1, end);
try {
return new RegExp(value);
} catch (e) {
console.warn(`bad regexp-value '${serializedValue}', parse error: ${e}`);
return null;
}
}
public abstract getType(): ContextKeyExprType;
public abstract equals(other: ContextKeyExpr): boolean;
public abstract evaluate(context: IContext): boolean;
@@ -109,6 +143,8 @@ function cmp(a: ContextKeyExpr, b: ContextKeyExpr): number {
return (<ContextKeyEqualsExpr>a).cmp(<ContextKeyEqualsExpr>b);
case ContextKeyExprType.NotEquals:
return (<ContextKeyNotEqualsExpr>a).cmp(<ContextKeyNotEqualsExpr>b);
case ContextKeyExprType.Regex:
return (<ContextKeyRegexExpr>a).cmp(<ContextKeyRegexExpr>b);
default:
throw new Error('Unknown ContextKeyExpr!');
}
@@ -320,6 +356,58 @@ export class ContextKeyNotExpr implements ContextKeyExpr {
}
}
export class ContextKeyRegexExpr implements ContextKeyExpr {
constructor(private key: string, private regexp: RegExp) {
//
}
public getType(): ContextKeyExprType {
return ContextKeyExprType.Regex;
}
public cmp(other: ContextKeyRegexExpr): number {
if (this.key < other.key) {
return -1;
}
if (this.key > other.key) {
return 1;
}
const source = this.regexp ? this.regexp.source : undefined;
if (source < other.regexp.source) {
return -1;
}
if (source > other.regexp.source) {
return 1;
}
return 0;
}
public equals(other: ContextKeyExpr): boolean {
if (other instanceof ContextKeyRegexExpr) {
const source = this.regexp ? this.regexp.source : undefined;
return (this.key === other.key && source === other.regexp.source);
}
return false;
}
public evaluate(context: IContext): boolean {
return this.regexp ? this.regexp.test(context.getValue(this.key)) : false;
}
public normalize(): ContextKeyExpr {
return this;
}
public serialize(): string {
return `${this.key} =~ /${this.regexp ? this.regexp.source : '<invalid>'}/`;
}
public keys(): string[] {
return [this.key];
}
}
export class ContextKeyAndExpr implements ContextKeyExpr {
public readonly expr: ContextKeyExpr[];
@@ -439,6 +527,10 @@ export class RawContextKey<T> extends ContextKeyDefinedExpr {
public isEqualTo(value: string): ContextKeyExpr {
return ContextKeyExpr.equals(this.key, value);
}
public notEqualsTo(value: string): ContextKeyExpr {
return ContextKeyExpr.notEquals(this.key, value);
}
}
export interface IContext {

View File

@@ -21,6 +21,8 @@ suite('ContextKeyExpr', () => {
ContextKeyExpr.has('a1'),
ContextKeyExpr.and(ContextKeyExpr.has('and.a')),
ContextKeyExpr.has('a2'),
ContextKeyExpr.regex('d3', /d.*/),
ContextKeyExpr.regex('d4', /\*\*3*/),
ContextKeyExpr.equals('b1', 'bb1'),
ContextKeyExpr.equals('b2', 'bb2'),
ContextKeyExpr.notEquals('c1', 'cc1'),
@@ -32,9 +34,11 @@ suite('ContextKeyExpr', () => {
ContextKeyExpr.equals('b2', 'bb2'),
ContextKeyExpr.notEquals('c1', 'cc1'),
ContextKeyExpr.not('d1'),
ContextKeyExpr.regex('d4', /\*\*3*/),
ContextKeyExpr.notEquals('c2', 'cc2'),
ContextKeyExpr.has('a2'),
ContextKeyExpr.equals('b1', 'bb1'),
ContextKeyExpr.regex('d3', /d.*/),
ContextKeyExpr.has('a1'),
ContextKeyExpr.and(ContextKeyExpr.equals('and.a', true)),
ContextKeyExpr.not('d2')
@@ -59,9 +63,11 @@ suite('ContextKeyExpr', () => {
let context = createContext({
'a': true,
'b': false,
'c': '5'
'c': '5',
'd': 'd'
});
function testExpression(expr: string, expected: boolean): void {
// console.log(expr + ' ' + expected);
let rules = ContextKeyExpr.deserialize(expr);
assert.equal(rules.evaluate(context), expected, expr);
}
@@ -74,16 +80,19 @@ suite('ContextKeyExpr', () => {
testExpression(expr + ' == 5', value == <any>'5');
testExpression(expr + ' != 5', value != <any>'5');
testExpression('!' + expr, !value);
testExpression(expr + ' =~ /d.*/', /d.*/.test(value));
}
testBatch('a', true);
testBatch('b', false);
testBatch('c', '5');
testBatch('d', 'd');
testBatch('z', undefined);
testExpression('a && !b', true && !false);
testExpression('a && b', true && false);
testExpression('a && !b && c == 5', true && !false && '5' == '5');
testExpression('dddd =~ d.*', false);
/* tslint:enable:triple-equals */
});
});