VSCode merge (#4610)

* Merge from vscode e388c734f30757875976c7e326d6cfeee77710de

* fix yarn lcoks

* remove small issue
This commit is contained in:
Anthony Dresser
2019-03-20 10:39:09 -07:00
committed by GitHub
parent 87765e8673
commit c814b92557
310 changed files with 6606 additions and 2129 deletions

View File

@@ -37,17 +37,17 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic
@IQuickInputService private readonly quickInputService: IQuickInputService
) {
super({
getFolderUri: (folderName: string): uri => {
getFolderUri: (folderName: string): uri | undefined => {
const folder = workspaceContextService.getWorkspace().folders.filter(f => f.name === folderName).pop();
return folder ? folder.uri : undefined;
},
getWorkspaceFolderCount: (): number => {
return workspaceContextService.getWorkspace().folders.length;
},
getConfigurationValue: (folderUri: uri, suffix: string) => {
return configurationService.getValue<string>(suffix, folderUri ? { resource: folderUri } : undefined);
getConfigurationValue: (folderUri: uri, suffix: string): string | undefined => {
return configurationService.getValue<string>(suffix, folderUri ? { resource: folderUri } : {});
},
getExecPath: () => {
getExecPath: (): string | undefined => {
return environmentService['execPath'];
},
getFilePath: (): string | undefined => {
@@ -72,18 +72,21 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic
}
return undefined;
},
getLineNumber: (): string => {
getLineNumber: (): string | undefined => {
const activeTextEditorWidget = editorService.activeTextEditorWidget;
if (isCodeEditor(activeTextEditorWidget)) {
const lineNumber = activeTextEditorWidget.getSelection().positionLineNumber;
return String(lineNumber);
const selection = activeTextEditorWidget.getSelection();
if (selection) {
const lineNumber = selection.positionLineNumber;
return String(lineNumber);
}
}
return undefined;
}
}, windowService.getConfiguration().userEnv);
}
public resolveWithInteractionReplace(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary<string>): Promise<any> {
public resolveWithInteractionReplace(folder: IWorkspaceFolder | undefined, config: any, section?: string, variables?: IStringDictionary<string>): Promise<any> {
// resolve any non-interactive variables
config = this.resolveAny(folder, config);
@@ -100,7 +103,7 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic
});
}
public resolveWithInteraction(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary<string>): Promise<Map<string, string>> {
public resolveWithInteraction(folder: IWorkspaceFolder | undefined, config: any, section?: string, variables?: IStringDictionary<string>): Promise<Map<string, string> | undefined> {
// resolve any non-interactive variables
const resolved = this.resolveAnyMap(folder, config);
config = resolved.newConfig;
@@ -118,7 +121,7 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic
/**
* Add all items from newMapping to fullMapping. Returns false if newMapping is undefined.
*/
private updateMapping(newMapping: IStringDictionary<string>, fullMapping: Map<string, string>): boolean {
private updateMapping(newMapping: IStringDictionary<string> | undefined, fullMapping: Map<string, string>): boolean {
if (!newMapping) {
return false;
}
@@ -136,15 +139,15 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic
*
* @param variableToCommandMap Aliases for commands
*/
private async resolveWithInputAndCommands(folder: IWorkspaceFolder, configuration: any, variableToCommandMap: IStringDictionary<string>, section: string): Promise<IStringDictionary<string>> {
private async resolveWithInputAndCommands(folder: IWorkspaceFolder | undefined, configuration: any, variableToCommandMap?: IStringDictionary<string>, section?: string): Promise<IStringDictionary<string> | undefined> {
if (!configuration) {
return Promise.resolve(undefined);
}
// get all "inputs"
let inputs: ConfiguredInput[] = undefined;
if (folder && this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY) {
let inputs: ConfiguredInput[] = [];
if (folder && this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY && section) {
let result = this.configurationService.getValue<any>(section, { resource: folder.uri });
if (result) {
inputs = result.inputs;
@@ -222,7 +225,7 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic
* @param variable Name of the input variable.
* @param inputInfos Information about each possible input variable.
*/
private showUserInput(variable: string, inputInfos: ConfiguredInput[]): Promise<string> {
private showUserInput(variable: string, inputInfos: ConfiguredInput[]): Promise<string | undefined> {
// find info for the given input variable
const info = inputInfos.filter(item => item.id === variable).pop();
@@ -290,4 +293,4 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic
}
}
registerSingleton(IConfigurationResolverService, ConfigurationResolverService, true);
registerSingleton(IConfigurationResolverService, ConfigurationResolverService, true);

View File

@@ -35,7 +35,7 @@ export interface IConfigurationResolverService {
* Similar to resolveWithInteractionReplace, except without the replace. Returns a map of variables and their resolution.
* Keys in the map will be of the format input:variableName or command:variableName.
*/
resolveWithInteraction(folder: IWorkspaceFolder | undefined, config: any, section?: string, variables?: IStringDictionary<string>): Promise<Map<string, string>>;
resolveWithInteraction(folder: IWorkspaceFolder | undefined, config: any, section?: string, variables?: IStringDictionary<string>): Promise<Map<string, string> | undefined>;
}
export interface PromptStringInputInfo {
@@ -60,4 +60,4 @@ export interface CommandInputInfo {
args?: any;
}
export type ConfiguredInput = PromptStringInputInfo | PickStringInputInfo | CommandInputInfo;
export type ConfiguredInput = PromptStringInputInfo | PickStringInputInfo | CommandInputInfo;

View File

@@ -82,11 +82,11 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
return { newConfig, resolvedVariables };
}
public resolveWithInteractionReplace(folder: IWorkspaceFolder, config: any): Promise<any> {
public resolveWithInteractionReplace(folder: IWorkspaceFolder | undefined, config: any, section?: string, variables?: IStringDictionary<string>): Promise<any> {
throw new Error('resolveWithInteractionReplace not implemented.');
}
public resolveWithInteraction(folder: IWorkspaceFolder, config: any): Promise<any> {
public resolveWithInteraction(folder: IWorkspaceFolder | undefined, config: any, section?: string, variables?: IStringDictionary<string>): Promise<Map<string, string> | undefined> {
throw new Error('resolveWithInteraction not implemented.');
}

View File

@@ -37,7 +37,7 @@ suite('Configuration Resolver Service', () => {
uri: uri.parse('file:///VSCode/workspaceLocation'),
name: 'hey',
index: 0,
toResource: () => null
toResource: (path: string) => uri.file(path)
};
configurationResolverService = new ConfigurationResolverService(windowService, editorService, TestEnvironmentService, new MockInputsConfigurationService(), mockCommandService, new TestContextService(), quickInputService);
});
@@ -528,7 +528,7 @@ class MockQuickInputService implements IQuickInputService {
public pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: true }, token?: CancellationToken): Promise<T[]>;
public pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: false }, token?: CancellationToken): Promise<T>;
public pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: Omit<IPickOptions<T>, 'canPickMany'>, token?: CancellationToken): Promise<T> {
public pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: Omit<IPickOptions<T>, 'canPickMany'>, token?: CancellationToken): Promise<T | undefined> {
if (Types.isArray(picks)) {
return Promise.resolve(<T>{ label: 'selectedPick', description: 'pick description' });
} else {
@@ -537,7 +537,7 @@ class MockQuickInputService implements IQuickInputService {
}
public input(options?: IInputOptions, token?: CancellationToken): Promise<string> {
return Promise.resolve('resolved' + options.prompt);
return Promise.resolve(options ? 'resolved' + options.prompt : 'resolved');
}
backButton: IQuickInputButton;