mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 01:25:38 -05:00
Merge from vscode 4636be2b71c87bfb0bfe3c94278b447a5efcc1f1 (#8722)
* Merge from vscode 4636be2b71c87bfb0bfe3c94278b447a5efcc1f1 * remove tests that aren't working
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope, getScopes } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { MainThreadConfigurationShape, MainContext, ExtHostContext, IExtHostContext, IConfigurationInitData } from '../common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationTarget, IConfigurationService, IConfigurationOverrides } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadConfiguration)
|
||||
@@ -45,25 +45,45 @@ export class MainThreadConfiguration implements MainThreadConfigurationShape {
|
||||
this._configurationListener.dispose();
|
||||
}
|
||||
|
||||
$updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: any, resourceUriComponenets: UriComponents | undefined): Promise<void> {
|
||||
const resource = resourceUriComponenets ? URI.revive(resourceUriComponenets) : null;
|
||||
return this.writeConfiguration(target, key, value, resource);
|
||||
$updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: any, overrides: IConfigurationOverrides | undefined, scopeToLanguage: boolean | undefined): Promise<void> {
|
||||
overrides = { resource: overrides?.resource ? URI.revive(overrides.resource) : undefined, overrideIdentifier: overrides?.overrideIdentifier };
|
||||
return this.writeConfiguration(target, key, value, overrides, scopeToLanguage);
|
||||
}
|
||||
|
||||
$removeConfigurationOption(target: ConfigurationTarget | null, key: string, resourceUriComponenets: UriComponents | undefined): Promise<void> {
|
||||
const resource = resourceUriComponenets ? URI.revive(resourceUriComponenets) : null;
|
||||
return this.writeConfiguration(target, key, undefined, resource);
|
||||
$removeConfigurationOption(target: ConfigurationTarget | null, key: string, overrides: IConfigurationOverrides | undefined, scopeToLanguage: boolean | undefined): Promise<void> {
|
||||
overrides = { resource: overrides?.resource ? URI.revive(overrides.resource) : undefined, overrideIdentifier: overrides?.overrideIdentifier };
|
||||
return this.writeConfiguration(target, key, undefined, overrides, scopeToLanguage);
|
||||
}
|
||||
|
||||
private writeConfiguration(target: ConfigurationTarget | null, key: string, value: any, resource: URI | null): Promise<void> {
|
||||
target = target !== null && target !== undefined ? target : this.deriveConfigurationTarget(key, resource);
|
||||
return this.configurationService.updateValue(key, value, { resource }, target, true);
|
||||
private writeConfiguration(target: ConfigurationTarget | null, key: string, value: any, overrides: IConfigurationOverrides, scopeToLanguage: boolean | undefined): Promise<void> {
|
||||
target = target !== null && target !== undefined ? target : this.deriveConfigurationTarget(key, overrides);
|
||||
const configurationValue = this.configurationService.inspect(key, overrides);
|
||||
switch (target) {
|
||||
case ConfigurationTarget.MEMORY:
|
||||
return this._updateValue(key, value, target, configurationValue?.memory?.override, overrides, scopeToLanguage);
|
||||
case ConfigurationTarget.WORKSPACE_FOLDER:
|
||||
return this._updateValue(key, value, target, configurationValue?.workspaceFolder?.override, overrides, scopeToLanguage);
|
||||
case ConfigurationTarget.WORKSPACE:
|
||||
return this._updateValue(key, value, target, configurationValue?.workspace?.override, overrides, scopeToLanguage);
|
||||
case ConfigurationTarget.USER_REMOTE:
|
||||
return this._updateValue(key, value, target, configurationValue?.userRemote?.override, overrides, scopeToLanguage);
|
||||
default:
|
||||
return this._updateValue(key, value, target, configurationValue?.userLocal?.override, overrides, scopeToLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
private deriveConfigurationTarget(key: string, resource: URI | null): ConfigurationTarget {
|
||||
if (resource && this._workspaceContextService.getWorkbenchState() === WorkbenchState.WORKSPACE) {
|
||||
private _updateValue(key: string, value: any, configurationTarget: ConfigurationTarget, overriddenValue: any | undefined, overrides: IConfigurationOverrides, scopeToLanguage: boolean | undefined): Promise<void> {
|
||||
overrides = scopeToLanguage === true ? overrides
|
||||
: scopeToLanguage === false ? { resource: overrides.resource }
|
||||
: overrides.overrideIdentifier && overriddenValue !== undefined ? overrides
|
||||
: { resource: overrides.resource };
|
||||
return this.configurationService.updateValue(key, value, overrides, configurationTarget);
|
||||
}
|
||||
|
||||
private deriveConfigurationTarget(key: string, overrides: IConfigurationOverrides): ConfigurationTarget {
|
||||
if (overrides.resource && this._workspaceContextService.getWorkbenchState() === WorkbenchState.WORKSPACE) {
|
||||
const configurationProperties = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).getConfigurationProperties();
|
||||
if (configurationProperties[key] && configurationProperties[key].scope === ConfigurationScope.RESOURCE) {
|
||||
if (configurationProperties[key] && (configurationProperties[key].scope === ConfigurationScope.RESOURCE || configurationProperties[key].scope === ConfigurationScope.RESOURCE_LANGUAGE)) {
|
||||
return ConfigurationTarget.WORKSPACE_FOLDER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,13 +506,17 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
this._registrations.set(handle, callh.CallHierarchyProviderRegistry.register(selector, {
|
||||
|
||||
prepareCallHierarchy: async (document, position, token) => {
|
||||
const item = await this._proxy.$prepareCallHierarchy(handle, document.uri, position, token);
|
||||
if (!item) {
|
||||
const items = await this._proxy.$prepareCallHierarchy(handle, document.uri, position, token);
|
||||
if (!items) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
dispose: () => this._proxy.$releaseCallHierarchy(handle, item._sessionId),
|
||||
root: MainThreadLanguageFeatures._reviveCallHierarchyItemDto(item)
|
||||
dispose: () => {
|
||||
for (const item of items) {
|
||||
this._proxy.$releaseCallHierarchy(handle, item._sessionId);
|
||||
}
|
||||
},
|
||||
roots: items.map(MainThreadLanguageFeatures._reviveCallHierarchyItemDto)
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -514,15 +514,19 @@ export class MainThreadTask implements MainThreadTaskShape {
|
||||
if (TaskHandleDTO.is(value)) {
|
||||
const workspaceFolder = this._workspaceContextServer.getWorkspaceFolder(URI.revive(value.workspaceFolder));
|
||||
if (workspaceFolder) {
|
||||
this._taskService.getTask(workspaceFolder, value.id, true).then((task: Task) => {
|
||||
this._taskService.run(task).then(undefined, reason => {
|
||||
// eat the error, it has already been surfaced to the user and we don't care about it here
|
||||
});
|
||||
const result: TaskExecutionDTO = {
|
||||
id: value.id,
|
||||
task: TaskDTO.from(task)
|
||||
};
|
||||
resolve(result);
|
||||
this._taskService.getTask(workspaceFolder, value.id, true).then((task: Task | undefined) => {
|
||||
if (!task) {
|
||||
reject(new Error('Task not found'));
|
||||
} else {
|
||||
this._taskService.run(task).then(undefined, reason => {
|
||||
// eat the error, it has already been surfaced to the user and we don't care about it here
|
||||
});
|
||||
const result: TaskExecutionDTO = {
|
||||
id: value.id,
|
||||
task: TaskDTO.from(task)
|
||||
};
|
||||
resolve(result);
|
||||
}
|
||||
}, (_error) => {
|
||||
reject(new Error('Task not found'));
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import { MainThreadTunnelServiceShape, IExtHostContext, MainContext, ExtHostCont
|
||||
import { TunnelOptions, TunnelDto } from 'vs/workbench/api/common/extHostTunnelService';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { IRemoteExplorerService } from 'vs/workbench/services/remote/common/remoteExplorerService';
|
||||
import { ITunnelProvider, ITunnelService } from 'vs/platform/remote/common/tunnel';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadTunnelService)
|
||||
export class MainThreadTunnelService implements MainThreadTunnelServiceShape {
|
||||
@@ -14,7 +15,8 @@ export class MainThreadTunnelService implements MainThreadTunnelServiceShape {
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IRemoteExplorerService private readonly remoteExplorerService: IRemoteExplorerService
|
||||
@IRemoteExplorerService private readonly remoteExplorerService: IRemoteExplorerService,
|
||||
@ITunnelService private readonly tunnelService: ITunnelService
|
||||
) {
|
||||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostTunnelService);
|
||||
}
|
||||
@@ -22,7 +24,7 @@ export class MainThreadTunnelService implements MainThreadTunnelServiceShape {
|
||||
async $openTunnel(tunnelOptions: TunnelOptions): Promise<TunnelDto | undefined> {
|
||||
const tunnel = await this.remoteExplorerService.forward(tunnelOptions.remote.port, tunnelOptions.localPort, tunnelOptions.name);
|
||||
if (tunnel) {
|
||||
return { remote: { host: tunnel.tunnelRemoteHost, port: tunnel.tunnelRemotePort }, localAddress: tunnel.localAddress };
|
||||
return TunnelDto.fromServiceTunnel(tunnel);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -31,14 +33,32 @@ export class MainThreadTunnelService implements MainThreadTunnelServiceShape {
|
||||
return this.remoteExplorerService.close(remotePort);
|
||||
}
|
||||
|
||||
$addDetected(tunnels: { remote: { port: number, host: string }, localAddress: string }[]): Promise<void> {
|
||||
return Promise.resolve(this.remoteExplorerService.addDetected(tunnels));
|
||||
}
|
||||
|
||||
async $registerCandidateFinder(): Promise<void> {
|
||||
this.remoteExplorerService.registerCandidateFinder(() => this._proxy.$findCandidatePorts());
|
||||
}
|
||||
|
||||
async $setTunnelProvider(): Promise<void> {
|
||||
const tunnelProvider: ITunnelProvider = {
|
||||
forwardPort: (tunnelOptions: TunnelOptions) => {
|
||||
const forward = this._proxy.$forwardPort(tunnelOptions);
|
||||
if (forward) {
|
||||
return forward.then(tunnel => {
|
||||
return {
|
||||
tunnelRemotePort: tunnel.remote.port,
|
||||
tunnelRemoteHost: tunnel.remote.host,
|
||||
localAddress: tunnel.localAddress,
|
||||
dispose: () => {
|
||||
this._proxy.$closeTunnel({ host: tunnel.remote.host, port: tunnel.remote.port });
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
this.tunnelService.setTunnelProvider(tunnelProvider);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
//
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { Disposable, IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { isWeb } from 'vs/base/common/platform';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
@@ -20,7 +20,7 @@ import { editorGroupToViewColumn, EditorViewColumn, viewColumnToEditorGroup } fr
|
||||
import { IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { CustomFileEditorInput } from 'vs/workbench/contrib/customEditor/browser/customEditorInput';
|
||||
import { ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
|
||||
import { ICustomEditorModel, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
|
||||
import { WebviewExtensionDescription } from 'vs/workbench/contrib/webview/browser/webview';
|
||||
import { WebviewInput } from 'vs/workbench/contrib/webview/browser/webviewEditorInput';
|
||||
import { ICreateWebViewShowOptions, IWebviewWorkbenchService, WebviewInputOptions } from 'vs/workbench/contrib/webview/browser/webviewWorkbenchService';
|
||||
@@ -95,6 +95,7 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
|
||||
private readonly _webviewInputs = new WebviewInputStore();
|
||||
private readonly _revivers = new Map<string, IDisposable>();
|
||||
private readonly _editorProviders = new Map<string, IDisposable>();
|
||||
private readonly _customEditorModels = new Map<ICustomEditorModel, { referenceCount: number }>();
|
||||
|
||||
constructor(
|
||||
context: extHostProtocol.IExtHostContext,
|
||||
@@ -252,7 +253,7 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
|
||||
this._revivers.delete(viewType);
|
||||
}
|
||||
|
||||
public $registerEditorProvider(extensionData: extHostProtocol.WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions): void {
|
||||
public $registerEditorProvider(extensionData: extHostProtocol.WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions, capabilities: readonly extHostProtocol.WebviewEditorCapabilities[]): void {
|
||||
if (this._editorProviders.has(viewType)) {
|
||||
throw new Error(`Provider for ${viewType} already registered`);
|
||||
}
|
||||
@@ -270,15 +271,16 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
|
||||
|
||||
webviewInput.webview.options = options;
|
||||
webviewInput.webview.extension = extension;
|
||||
const resource = webviewInput.getResource();
|
||||
|
||||
const model = await this.getModel(webviewInput);
|
||||
const model = await this.retainCustomEditorModel(webviewInput, resource, viewType, capabilities);
|
||||
webviewInput.onDisposeWebview(() => {
|
||||
this._customEditorService.models.disposeModel(model);
|
||||
this.releaseCustomEditorModel(model);
|
||||
});
|
||||
|
||||
try {
|
||||
await this._proxy.$resolveWebviewEditor(
|
||||
{ resource: webviewInput.getResource(), edits: model.currentEdits },
|
||||
resource,
|
||||
handle,
|
||||
viewType,
|
||||
webviewInput.getTitle(),
|
||||
@@ -304,43 +306,62 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
|
||||
this._editorProviders.delete(viewType);
|
||||
}
|
||||
|
||||
public async $registerCapabilities(handle: extHostProtocol.WebviewPanelHandle, capabilities: readonly extHostProtocol.WebviewEditorCapabilities[]): Promise<void> {
|
||||
const webviewInput = this.getWebviewInput(handle);
|
||||
const model = await this.getModel(webviewInput);
|
||||
private async retainCustomEditorModel(webviewInput: WebviewInput, resource: URI, viewType: string, capabilities: readonly extHostProtocol.WebviewEditorCapabilities[]) {
|
||||
const model = await this._customEditorService.models.loadOrCreate(webviewInput.getResource(), webviewInput.viewType);
|
||||
|
||||
const existingEntry = this._customEditorModels.get(model);
|
||||
if (existingEntry) {
|
||||
++existingEntry.referenceCount;
|
||||
// no need to hook up listeners again
|
||||
return model;
|
||||
}
|
||||
|
||||
this._customEditorModels.set(model, { referenceCount: 1 });
|
||||
|
||||
const capabilitiesSet = new Set(capabilities);
|
||||
if (capabilitiesSet.has(extHostProtocol.WebviewEditorCapabilities.Editable)) {
|
||||
model.onUndo(edits => { this._proxy.$undoEdits(handle, edits.map(x => x.data)); });
|
||||
model.onUndo(edits => {
|
||||
this._proxy.$undoEdits(resource, viewType, edits.map(x => x.data));
|
||||
});
|
||||
|
||||
model.onApplyEdit(edits => {
|
||||
const editsToApply = edits.filter(x => x.source !== webviewInput).map(x => x.data);
|
||||
const editsToApply = edits.filter(x => x.source !== model).map(x => x.data);
|
||||
if (editsToApply.length) {
|
||||
this._proxy.$applyEdits(handle, editsToApply);
|
||||
this._proxy.$applyEdits(resource, viewType, editsToApply);
|
||||
}
|
||||
});
|
||||
|
||||
model.onWillSave(e => { e.waitUntil(this._proxy.$onSave(handle)); });
|
||||
model.onWillSave(e => {
|
||||
e.waitUntil(this._proxy.$onSave(resource.toJSON(), viewType));
|
||||
});
|
||||
|
||||
model.onWillSaveAs(e => { e.waitUntil(this._proxy.$onSaveAs(handle, e.resource.toJSON(), e.targetResource.toJSON())); });
|
||||
model.onWillSaveAs(e => {
|
||||
e.waitUntil(this._proxy.$onSaveAs(e.resource.toJSON(), viewType, e.targetResource.toJSON()));
|
||||
});
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
private async releaseCustomEditorModel(model: ICustomEditorModel) {
|
||||
const entry = this._customEditorModels.get(model);
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
|
||||
--entry.referenceCount;
|
||||
if (entry.referenceCount <= 0) {
|
||||
this._customEditorService.models.disposeModel(model);
|
||||
this._customEditorModels.delete(model);
|
||||
}
|
||||
}
|
||||
|
||||
private getModel(webviewInput: WebviewInput) {
|
||||
return this._customEditorService.models.loadOrCreate(webviewInput.getResource(), webviewInput.viewType);
|
||||
}
|
||||
|
||||
public $onEdit(handle: extHostProtocol.WebviewPanelHandle, editData: any): void {
|
||||
const webview = this.getWebviewInput(handle);
|
||||
if (!(webview instanceof CustomFileEditorInput)) {
|
||||
throw new Error('Webview is not a webview editor');
|
||||
}
|
||||
|
||||
const model = this._customEditorService.models.get(webview.getResource(), webview.viewType);
|
||||
public $onEdit(resource: UriComponents, viewType: string, editData: any): void {
|
||||
const model = this._customEditorService.models.get(URI.revive(resource), viewType);
|
||||
if (!model) {
|
||||
throw new Error('Could not find model for webview editor');
|
||||
}
|
||||
|
||||
model.makeEdit({ source: webview, data: editData });
|
||||
model.pushEdit({ source: model, data: editData });
|
||||
}
|
||||
|
||||
private hookupWebviewEventDelegate(handle: extHostProtocol.WebviewPanelHandle, input: WebviewInput) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { forEach } from 'vs/base/common/collections';
|
||||
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import { ExtensionMessageCollector, ExtensionsRegistry, IExtensionPoint, IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
||||
import { ViewContainer, IViewsRegistry, ITreeViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions, TEST_VIEW_CONTAINER_ID, IViewDescriptor } from 'vs/workbench/common/views';
|
||||
import { ViewContainer, IViewsRegistry, ITreeViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions, TEST_VIEW_CONTAINER_ID, IViewDescriptor, ViewContainerLocation } from 'vs/workbench/common/views';
|
||||
import { CustomTreeViewPane, CustomTreeView } from 'vs/workbench/browser/parts/views/customView';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { coalesce, } from 'vs/base/common/arrays';
|
||||
@@ -313,7 +313,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
|
||||
|
||||
if (!viewContainer) {
|
||||
|
||||
viewContainer = this.viewContainersRegistry.registerViewContainer(id, true, extensionId);
|
||||
viewContainer = this.viewContainersRegistry.registerViewContainer(id, ViewContainerLocation.Sidebar, true, extensionId);
|
||||
|
||||
class CustomViewPaneContainer extends ViewPaneContainer {
|
||||
constructor(
|
||||
|
||||
Reference in New Issue
Block a user