mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -465,7 +465,7 @@ class FileServiceBasedWorkspaceConfiguration extends Disposable implements IWork
|
||||
}
|
||||
|
||||
private consolidate(): void {
|
||||
this.workspaceSettings = this.workspaceConfigurationModelParser.settingsModel.merge(this.workspaceConfigurationModelParser.launchModel);
|
||||
this.workspaceSettings = this.workspaceConfigurationModelParser.settingsModel.merge(this.workspaceConfigurationModelParser.launchModel, this.workspaceConfigurationModelParser.tasksModel);
|
||||
}
|
||||
|
||||
private watchWorkspaceConfigurationFile(): IDisposable {
|
||||
@@ -509,7 +509,7 @@ class CachedWorkspaceConfiguration extends Disposable implements IWorkspaceConfi
|
||||
const contents = await this.configurationCache.read(key);
|
||||
this.workspaceConfigurationModelParser = new WorkspaceConfigurationModelParser(key.key);
|
||||
this.workspaceConfigurationModelParser.parseContent(contents);
|
||||
this.workspaceSettings = this.workspaceConfigurationModelParser.settingsModel.merge(this.workspaceConfigurationModelParser.launchModel);
|
||||
this.workspaceSettings = this.workspaceConfigurationModelParser.settingsModel.merge(this.workspaceConfigurationModelParser.launchModel, this.workspaceConfigurationModelParser.tasksModel);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,10 +59,10 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
|
||||
protected readonly _onDidChangeWorkbenchState: Emitter<WorkbenchState> = this._register(new Emitter<WorkbenchState>());
|
||||
public readonly onDidChangeWorkbenchState: Event<WorkbenchState> = this._onDidChangeWorkbenchState.event;
|
||||
|
||||
private configurationEditingService: ConfigurationEditingService;
|
||||
private jsonEditingService: JSONEditingService;
|
||||
|
||||
private cyclicDependencyReady: Function;
|
||||
// TODO@sandeep debt with cyclic dependencies
|
||||
private configurationEditingService!: ConfigurationEditingService;
|
||||
private jsonEditingService!: JSONEditingService;
|
||||
private cyclicDependencyReady!: Function;
|
||||
private cyclicDependency = new Promise<void>(resolve => this.cyclicDependencyReady = resolve);
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -428,11 +428,6 @@ export class ConfigurationEditingService {
|
||||
if (target === EditableConfigurationTarget.USER_LOCAL || target === EditableConfigurationTarget.USER_REMOTE) {
|
||||
return this.reject(ConfigurationEditingErrorCode.ERROR_INVALID_USER_TARGET, target, operation);
|
||||
}
|
||||
|
||||
// Workspace tasks are not supported
|
||||
if (operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY && this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && operation.target === EditableConfigurationTarget.WORKSPACE) {
|
||||
return this.reject(ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_TARGET, target, operation);
|
||||
}
|
||||
}
|
||||
|
||||
// Target cannot be workspace or folder if no workspace opened
|
||||
|
||||
@@ -17,11 +17,13 @@ export class WorkspaceConfigurationModelParser extends ConfigurationModelParser
|
||||
private _folders: IStoredWorkspaceFolder[] = [];
|
||||
private _settingsModelParser: ConfigurationModelParser;
|
||||
private _launchModel: ConfigurationModel;
|
||||
private _tasksModel: ConfigurationModel;
|
||||
|
||||
constructor(name: string) {
|
||||
super(name);
|
||||
this._settingsModelParser = new ConfigurationModelParser(name, WORKSPACE_SCOPES);
|
||||
this._launchModel = new ConfigurationModel();
|
||||
this._tasksModel = new ConfigurationModel();
|
||||
}
|
||||
|
||||
get folders(): IStoredWorkspaceFolder[] {
|
||||
@@ -36,6 +38,10 @@ export class WorkspaceConfigurationModelParser extends ConfigurationModelParser
|
||||
return this._launchModel;
|
||||
}
|
||||
|
||||
get tasksModel(): ConfigurationModel {
|
||||
return this._tasksModel;
|
||||
}
|
||||
|
||||
reprocessWorkspaceSettings(): void {
|
||||
this._settingsModelParser.parse();
|
||||
}
|
||||
@@ -44,6 +50,7 @@ export class WorkspaceConfigurationModelParser extends ConfigurationModelParser
|
||||
this._folders = (raw['folders'] || []) as IStoredWorkspaceFolder[];
|
||||
this._settingsModelParser.parseRaw(raw['settings']);
|
||||
this._launchModel = this.createConfigurationModelFrom(raw, 'launch');
|
||||
this._tasksModel = this.createConfigurationModelFrom(raw, 'tasks');
|
||||
return super.doParseRaw(raw);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ suite('ConfigurationEditingService', () => {
|
||||
test('do not notify error', () => {
|
||||
instantiationService.stub(ITextFileService, 'isDirty', true);
|
||||
const target = sinon.stub();
|
||||
instantiationService.stub(INotificationService, <INotificationService>{ prompt: target, _serviceBrand: undefined, notify: null!, error: null!, info: null!, warn: null!, status: null! });
|
||||
instantiationService.stub(INotificationService, <INotificationService>{ prompt: target, _serviceBrand: undefined, notify: null!, error: null!, info: null!, warn: null!, status: null!, setFilter: null! });
|
||||
return testObject.writeConfiguration(EditableConfigurationTarget.USER_LOCAL, { key: 'configurationEditing.service.testSetting', value: 'value' }, { donotNotifyError: true })
|
||||
.then(() => assert.fail('Should fail with ERROR_CONFIGURATION_FILE_DIRTY error.'),
|
||||
(error: ConfigurationEditingError) => {
|
||||
|
||||
@@ -1406,6 +1406,53 @@ suite.skip('WorkspaceConfigurationService-Multiroot', () => { // {{SQL CARBON ED
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('get tasks configuration', () => {
|
||||
const expectedTasksConfiguration = {
|
||||
'version': '2.0.0',
|
||||
'tasks': [
|
||||
{
|
||||
'label': 'Run Dev',
|
||||
'type': 'shell',
|
||||
'command': './scripts/code.sh',
|
||||
'windows': {
|
||||
'command': '.\\scripts\\code.bat'
|
||||
},
|
||||
'problemMatcher': []
|
||||
}
|
||||
]
|
||||
};
|
||||
return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, [{ key: 'tasks', value: expectedTasksConfiguration }], true)
|
||||
.then(() => testObject.reloadConfiguration())
|
||||
.then(() => {
|
||||
const actual = testObject.getValue('tasks');
|
||||
assert.deepEqual(actual, expectedTasksConfiguration);
|
||||
});
|
||||
});
|
||||
|
||||
test('inspect tasks configuration', () => {
|
||||
const expectedTasksConfiguration = {
|
||||
'version': '2.0.0',
|
||||
'tasks': [
|
||||
{
|
||||
'label': 'Run Dev',
|
||||
'type': 'shell',
|
||||
'command': './scripts/code.sh',
|
||||
'windows': {
|
||||
'command': '.\\scripts\\code.bat'
|
||||
},
|
||||
'problemMatcher': []
|
||||
}
|
||||
]
|
||||
};
|
||||
return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, [{ key: 'tasks', value: expectedTasksConfiguration }], true)
|
||||
.then(() => testObject.reloadConfiguration())
|
||||
.then(() => {
|
||||
const actual = testObject.inspect('tasks').workspace;
|
||||
assert.deepEqual(actual, expectedTasksConfiguration);
|
||||
});
|
||||
});
|
||||
|
||||
test('update user configuration', () => {
|
||||
return testObject.updateValue('configurationService.workspace.testSetting', 'userValue', ConfigurationTarget.USER)
|
||||
.then(() => assert.equal(testObject.getValue('configurationService.workspace.testSetting'), 'userValue'));
|
||||
@@ -1483,25 +1530,17 @@ suite.skip('WorkspaceConfigurationService-Multiroot', () => { // {{SQL CARBON ED
|
||||
.then(() => assert.deepEqual(testObject.getValue('tasks', { resource: workspace.folders[0].uri }), { 'version': '1.0.0', tasks: [{ 'taskName': 'myTask' }] }));
|
||||
});
|
||||
|
||||
test('update tasks configuration in a workspace is not supported', () => {
|
||||
const workspace = workspaceContextService.getWorkspace();
|
||||
return testObject.updateValue('tasks', { 'version': '1.0.0', tasks: [{ 'taskName': 'myTask' }] }, { resource: workspace.folders[0].uri }, ConfigurationTarget.WORKSPACE, true)
|
||||
.then(() => assert.fail('Should not be supported'), (e) => assert.equal(e.code, ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_TARGET));
|
||||
});
|
||||
|
||||
test('update launch configuration in a workspace', () => {
|
||||
const workspace = workspaceContextService.getWorkspace();
|
||||
return testObject.updateValue('launch', { 'version': '1.0.0', configurations: [{ 'name': 'myLaunch' }] }, { resource: workspace.folders[0].uri }, ConfigurationTarget.WORKSPACE, true)
|
||||
.then(() => assert.deepEqual(testObject.getValue('launch'), { 'version': '1.0.0', configurations: [{ 'name': 'myLaunch' }] }));
|
||||
});
|
||||
|
||||
test('task configurations are not read from workspace', () => {
|
||||
return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, [{ key: 'tasks', value: { 'version': '1.0' } }], true)
|
||||
.then(() => testObject.reloadConfiguration())
|
||||
.then(() => {
|
||||
const actual = testObject.inspect('tasks.version');
|
||||
assert.equal(actual.workspace, undefined);
|
||||
});
|
||||
test('update tasks configuration in a workspace', () => {
|
||||
const workspace = workspaceContextService.getWorkspace();
|
||||
const tasks = { 'version': '2.0.0', tasks: [{ 'label': 'myTask' }] };
|
||||
return testObject.updateValue('tasks', tasks, { resource: workspace.folders[0].uri }, ConfigurationTarget.WORKSPACE, true)
|
||||
.then(() => assert.deepEqual(testObject.getValue('tasks'), tasks));
|
||||
});
|
||||
|
||||
test('configuration of newly added folder is available on configuration change event', async () => {
|
||||
|
||||
Reference in New Issue
Block a user