mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 18:46:34 -05:00
Vscode merge (#4582)
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd * fix issues with merges * bump node version in azpipe * replace license headers * remove duplicate launch task * fix build errors * fix build errors * fix tslint issues * working through package and linux build issues * more work * wip * fix packaged builds * working through linux build errors * wip * wip * wip * fix mac and linux file limits * iterate linux pipeline * disable editor typing * revert series to parallel * remove optimize vscode from linux * fix linting issues * revert testing change * add work round for new node * readd packaging for extensions * fix issue with angular not resolving decorator dependencies
This commit is contained in:
@@ -20,6 +20,14 @@ export const enum ContextKeyExprType {
|
||||
//
|
||||
}
|
||||
|
||||
export interface IContextKeyExprMapper {
|
||||
mapDefined(key: string): ContextKeyDefinedExpr;
|
||||
mapNot(key: string): ContextKeyNotExpr;
|
||||
mapEquals(key: string, value: any): ContextKeyEqualsExpr;
|
||||
mapNotEquals(key: string, value: any): ContextKeyNotEqualsExpr;
|
||||
mapRegex(key: string, regexp: RegExp | null): ContextKeyRegexExpr;
|
||||
}
|
||||
|
||||
export abstract class ContextKeyExpr {
|
||||
|
||||
public static has(key: string): ContextKeyExpr {
|
||||
@@ -55,42 +63,42 @@ export abstract class ContextKeyExpr {
|
||||
}
|
||||
//
|
||||
|
||||
public static deserialize(serialized: string | null | undefined): ContextKeyExpr | null {
|
||||
public static deserialize(serialized: string | null | undefined, strict: boolean = false): ContextKeyExpr | null {
|
||||
if (!serialized) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let pieces = serialized.split('&&');
|
||||
let result = new ContextKeyAndExpr(pieces.map(p => this._deserializeOne(p)));
|
||||
let result = new ContextKeyAndExpr(pieces.map(p => this._deserializeOne(p, strict)));
|
||||
return result.normalize();
|
||||
}
|
||||
|
||||
private static _deserializeOne(serializedOne: string): ContextKeyExpr {
|
||||
private static _deserializeOne(serializedOne: string, strict: boolean): ContextKeyExpr {
|
||||
serializedOne = serializedOne.trim();
|
||||
|
||||
if (serializedOne.indexOf('!=') >= 0) {
|
||||
let pieces = serializedOne.split('!=');
|
||||
return new ContextKeyNotEqualsExpr(pieces[0].trim(), this._deserializeValue(pieces[1]));
|
||||
return new ContextKeyNotEqualsExpr(pieces[0].trim(), this._deserializeValue(pieces[1], strict));
|
||||
}
|
||||
|
||||
if (serializedOne.indexOf('==') >= 0) {
|
||||
let pieces = serializedOne.split('==');
|
||||
return new ContextKeyEqualsExpr(pieces[0].trim(), this._deserializeValue(pieces[1]));
|
||||
return new ContextKeyEqualsExpr(pieces[0].trim(), this._deserializeValue(pieces[1], strict));
|
||||
}
|
||||
|
||||
if (serializedOne.indexOf('=~') >= 0) {
|
||||
let pieces = serializedOne.split('=~');
|
||||
return new ContextKeyRegexExpr(pieces[0].trim(), this._deserializeRegexValue(pieces[1]));
|
||||
return new ContextKeyRegexExpr(pieces[0].trim(), this._deserializeRegexValue(pieces[1], strict));
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
if (serializedOne.indexOf('>=') >= 0) {
|
||||
let pieces = serializedOne.split('>=');
|
||||
return new ContextKeyGreaterThanEqualsExpr(pieces[0].trim(), this._deserializeValue(pieces[1]));
|
||||
return new ContextKeyGreaterThanEqualsExpr(pieces[0].trim(), this._deserializeValue(pieces[1], strict));
|
||||
}
|
||||
if (serializedOne.indexOf('<=') >= 0) {
|
||||
let pieces = serializedOne.split('<=');
|
||||
return new ContextKeyLessThanEqualsExpr(pieces[0].trim(), this._deserializeValue(pieces[1]));
|
||||
return new ContextKeyLessThanEqualsExpr(pieces[0].trim(), this._deserializeValue(pieces[1], strict));
|
||||
}
|
||||
//
|
||||
|
||||
@@ -101,7 +109,7 @@ export abstract class ContextKeyExpr {
|
||||
return new ContextKeyDefinedExpr(serializedOne);
|
||||
}
|
||||
|
||||
private static _deserializeValue(serializedValue: string): any {
|
||||
private static _deserializeValue(serializedValue: string, strict: boolean): any {
|
||||
serializedValue = serializedValue.trim();
|
||||
|
||||
if (serializedValue === 'true') {
|
||||
@@ -120,17 +128,25 @@ export abstract class ContextKeyExpr {
|
||||
return serializedValue;
|
||||
}
|
||||
|
||||
private static _deserializeRegexValue(serializedValue: string): RegExp | null {
|
||||
private static _deserializeRegexValue(serializedValue: string, strict: boolean): RegExp | null {
|
||||
|
||||
if (isFalsyOrWhitespace(serializedValue)) {
|
||||
console.warn('missing regexp-value for =~-expression');
|
||||
if (strict) {
|
||||
throw new Error('missing regexp-value for =~-expression');
|
||||
} else {
|
||||
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`);
|
||||
if (strict) {
|
||||
throw new Error(`bad regexp-value '${serializedValue}', missing /-enclosure`);
|
||||
} else {
|
||||
console.warn(`bad regexp-value '${serializedValue}', missing /-enclosure`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -139,7 +155,11 @@ export abstract class ContextKeyExpr {
|
||||
try {
|
||||
return new RegExp(value, caseIgnoreFlag);
|
||||
} catch (e) {
|
||||
console.warn(`bad regexp-value '${serializedValue}', parse error: ${e}`);
|
||||
if (strict) {
|
||||
throw new Error(`bad regexp-value '${serializedValue}', parse error: ${e}`);
|
||||
} else {
|
||||
console.warn(`bad regexp-value '${serializedValue}', parse error: ${e}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -150,6 +170,7 @@ export abstract class ContextKeyExpr {
|
||||
public abstract normalize(): ContextKeyExpr | null;
|
||||
public abstract serialize(): string;
|
||||
public abstract keys(): string[];
|
||||
public abstract map(mapFnc: IContextKeyExprMapper): ContextKeyExpr;
|
||||
}
|
||||
|
||||
function cmp(a: ContextKeyExpr, b: ContextKeyExpr): number {
|
||||
@@ -220,10 +241,14 @@ export class ContextKeyDefinedExpr implements ContextKeyExpr {
|
||||
public keys(): string[] {
|
||||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
return mapFnc.mapDefined(this.key);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyEqualsExpr implements ContextKeyExpr {
|
||||
constructor(private key: string, private value: any) {
|
||||
constructor(private readonly key: string, private readonly value: any) {
|
||||
}
|
||||
|
||||
public getType(): ContextKeyExprType {
|
||||
@@ -281,6 +306,10 @@ export class ContextKeyEqualsExpr implements ContextKeyExpr {
|
||||
public keys(): string[] {
|
||||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
return mapFnc.mapEquals(this.key, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyNotEqualsExpr implements ContextKeyExpr {
|
||||
@@ -342,6 +371,10 @@ export class ContextKeyNotEqualsExpr implements ContextKeyExpr {
|
||||
public keys(): string[] {
|
||||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
return mapFnc.mapNotEquals(this.key, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyNotExpr implements ContextKeyExpr {
|
||||
@@ -384,6 +417,10 @@ export class ContextKeyNotExpr implements ContextKeyExpr {
|
||||
public keys(): string[] {
|
||||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
return mapFnc.mapNot(this.key);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyRegexExpr implements ContextKeyExpr {
|
||||
@@ -442,6 +479,10 @@ export class ContextKeyRegexExpr implements ContextKeyExpr {
|
||||
public keys(): string[] {
|
||||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
return mapFnc.mapRegex(this.key, this.regexp);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyAndExpr implements ContextKeyExpr {
|
||||
@@ -541,6 +582,10 @@ export class ContextKeyAndExpr implements ContextKeyExpr {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
return new ContextKeyAndExpr(this.expr.map(expr => expr.map(mapFnc)));
|
||||
}
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
@@ -592,6 +637,10 @@ export class ContextKeyGreaterThanEqualsExpr implements ContextKeyExpr {
|
||||
public keys(): string[] {
|
||||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
return mapFnc.mapEquals(this.key, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
@@ -643,6 +692,10 @@ export class ContextKeyLessThanEqualsExpr implements ContextKeyExpr {
|
||||
public keys(): string[] {
|
||||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
return mapFnc.mapEquals(this.key, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
export class RawContextKey<T> extends ContextKeyDefinedExpr {
|
||||
|
||||
9
src/vs/platform/contextkey/common/contextkeys.ts
Normal file
9
src/vs/platform/contextkey/common/contextkeys.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export const InputFocusedContextKey = 'inputFocus';
|
||||
export const InputFocusedContext = new RawContextKey<boolean>(InputFocusedContextKey, false);
|
||||
Reference in New Issue
Block a user