refactor notebook to be fileservice based (#6459)

This commit is contained in:
Anthony Dresser
2019-07-26 22:19:13 -07:00
committed by GitHub
parent 8e40aa3306
commit 371504358d
80 changed files with 192 additions and 175 deletions

View File

@@ -13,9 +13,10 @@ import { URI } from 'vs/base/common/uri';
import { INotebookService, INotebookProvider, INotebookManager } from 'sql/workbench/services/notebook/common/notebookService';
import { INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, FutureMessageType, INotebookFutureDetails, INotebookFutureDone } from 'sql/workbench/api/common/sqlExtHostTypes';
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
import { Deferred } from 'sql/base/common/promise';
import { FutureInternal } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { FutureInternal } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@extHostNamedCustomer(SqlMainContext.MainThreadNotebook)
export class MainThreadNotebook extends Disposable implements MainThreadNotebookShape {
@@ -26,7 +27,8 @@ export class MainThreadNotebook extends Disposable implements MainThreadNotebook
constructor(
extHostContext: IExtHostContext,
@INotebookService private notebookService: INotebookService
@INotebookService private notebookService: INotebookService,
@IInstantiationService private readonly instantiationService: IInstantiationService
) {
super();
if (extHostContext) {
@@ -48,7 +50,7 @@ export class MainThreadNotebook extends Disposable implements MainThreadNotebook
main: this,
ext: this._proxy
};
let notebookProvider = new NotebookProviderWrapper(proxy, providerId, handle);
let notebookProvider = this.instantiationService.createInstance(NotebookProviderWrapper, proxy, providerId, handle);
this._providers.set(handle, notebookProvider);
this.notebookService.registerProvider(providerId, notebookProvider);
}
@@ -87,7 +89,12 @@ interface Proxies {
class NotebookProviderWrapper extends Disposable implements INotebookProvider {
private _notebookUriToManagerMap = new Map<string, NotebookManagerWrapper>();
constructor(private _proxy: Proxies, public readonly providerId, public readonly providerHandle: number) {
constructor(
private _proxy: Proxies,
public readonly providerId,
public readonly providerHandle: number,
@IInstantiationService private readonly instantiationService: IInstantiationService
) {
super();
}
@@ -100,7 +107,7 @@ class NotebookProviderWrapper extends Disposable implements INotebookProvider {
let uriString = notebookUri.toString();
let manager = this._notebookUriToManagerMap.get(uriString);
if (!manager) {
manager = new NotebookManagerWrapper(this._proxy, this.providerId, notebookUri);
manager = this.instantiationService.createInstance(NotebookManagerWrapper, this._proxy, this.providerId, notebookUri);
await manager.initialize(this.providerHandle);
this._notebookUriToManagerMap.set(uriString, manager);
}
@@ -121,13 +128,14 @@ class NotebookManagerWrapper implements INotebookManager {
constructor(private _proxy: Proxies,
public readonly providerId,
private notebookUri: URI
private notebookUri: URI,
@IInstantiationService private readonly instantiationService: IInstantiationService
) { }
public async initialize(providerHandle: number): Promise<NotebookManagerWrapper> {
this.managerDetails = await this._proxy.ext.$getNotebookManager(providerHandle, this.notebookUri);
let managerHandle = this.managerDetails.handle;
this._contentManager = this.managerDetails.hasContentManager ? new ContentManagerWrapper(managerHandle, this._proxy) : new LocalContentManager();
this._contentManager = this.managerDetails.hasContentManager ? new ContentManagerWrapper(managerHandle, this._proxy) : this.instantiationService.createInstance(LocalContentManager);
this._serverManager = this.managerDetails.hasServerManager ? new ServerManagerWrapper(managerHandle, this._proxy) : undefined;
this._sessionManager = new SessionManagerWrapper(managerHandle, this._proxy);
return this;

View File

@@ -21,11 +21,11 @@ import {
SqlMainContext, MainThreadNotebookDocumentsAndEditorsShape, SqlExtHostContext, ExtHostNotebookDocumentsAndEditorsShape,
INotebookDocumentsAndEditorsDelta, INotebookEditorAddData, INotebookShowOptions, INotebookModelAddedData, INotebookModelChangedData
} from 'sql/workbench/api/common/sqlExtHost.protocol';
import { NotebookInput } from 'sql/workbench/parts/notebook/node/notebookInput';
import { NotebookInput } from 'sql/workbench/parts/notebook/common/models/notebookInput';
import { INotebookService, INotebookEditor, IProviderInfo } from 'sql/workbench/services/notebook/common/notebookService';
import { ISingleNotebookEditOperation, NotebookChangeKind } from 'sql/workbench/api/common/sqlExtHostTypes';
import { disposed } from 'vs/base/common/errors';
import { ICellModel, NotebookContentChange, INotebookModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModel, NotebookContentChange, INotebookModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { NotebookChangeType, CellTypes } from 'sql/workbench/parts/notebook/common/models/contracts';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';

View File

@@ -12,7 +12,7 @@ import { QueryResultsInput } from 'sql/workbench/parts/query/common/queryResults
import { QueryInput } from 'sql/workbench/parts/query/common/queryInput';
import { IQueryEditorOptions } from 'sql/workbench/services/queryEditor/common/queryEditorService';
import { QueryPlanInput } from 'sql/workbench/parts/queryPlan/common/queryPlanInput';
import { NotebookInput } from 'sql/workbench/parts/notebook/node/notebookInput';
import { NotebookInput } from 'sql/workbench/parts/notebook/common/models/notebookInput';
import { INotebookService } from 'sql/workbench/services/notebook/common/notebookService';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';

View File

@@ -33,7 +33,7 @@ import { $ } from 'vs/base/browser/dom';
import { ExecuteCommandAction } from 'vs/platform/actions/common/actions';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/electron-browser/notebookActions';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
export class ObjectMetadataWrapper implements ObjectMetadata {
public metadataType: MetadataType;

View File

@@ -16,7 +16,7 @@ import { IViewsRegistry, Extensions } from 'vs/workbench/common/views';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { Registry } from 'vs/platform/registry/common/platform';
import { BackupAction, RestoreAction } from 'sql/workbench/common/actions';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/electron-browser/notebookActions';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
export const DISCONNECT_COMMAND_ID = 'dataExplorer.disconnect';
export const MANAGE_COMMAND_ID = 'dataExplorer.manage';

View File

@@ -13,12 +13,12 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
import * as DOM from 'vs/base/browser/dom';
import { INotebookService } from 'sql/workbench/services/notebook/common/notebookService';
import { CellActionBase, CellContext } from 'sql/workbench/parts/notebook/electron-browser/cellViews/codeActions';
import { CellActionBase, CellContext } from 'sql/workbench/parts/notebook/browser/cellViews/codeActions';
import { CellTypes, CellType } from 'sql/workbench/parts/notebook/common/models/contracts';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { ToggleMoreWidgetAction } from 'sql/workbench/parts/dashboard/browser/core/actions';
import { CellModel } from 'sql/workbench/parts/notebook/node/models/cell';
import { CellModel } from 'sql/workbench/parts/notebook/common/models/cell';
export const HIDDEN_CLASS = 'actionhidden';

View File

@@ -8,11 +8,11 @@ import { OnInit, Component, Input, Inject, ElementRef, ViewChild, Output, EventE
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { QueryTextEditor } from 'sql/workbench/browser/modelComponents/queryTextEditor';
import { CellToggleMoreActions } from 'sql/workbench/parts/notebook/electron-browser/cellToggleMoreActions';
import { ICellModel, notebookConstants, CellExecutionState } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { CellToggleMoreActions } from 'sql/workbench/parts/notebook/browser/cellToggleMoreActions';
import { ICellModel, notebookConstants, CellExecutionState } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
import { RunCellAction, CellContext } from 'sql/workbench/parts/notebook/electron-browser/cellViews/codeActions';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { RunCellAction, CellContext } from 'sql/workbench/parts/notebook/browser/cellViews/codeActions';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import * as themeColors from 'vs/workbench/common/theme';
@@ -29,7 +29,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { Event, Emitter } from 'vs/base/common/event';
import { CellTypes } from 'sql/workbench/parts/notebook/common/models/contracts';
import { OVERRIDE_EDITOR_THEMING_SETTING } from 'sql/workbench/services/notebook/common/notebookService';
import * as notebookUtils from 'sql/workbench/parts/notebook/node/models/notebookUtils';
import * as notebookUtils from 'sql/workbench/parts/notebook/common/models/notebookUtils';
import { UntitledEditorModel } from 'vs/workbench/common/editor/untitledEditorModel';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { ILogService } from 'vs/platform/log/common/log';

View File

@@ -9,10 +9,10 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import * as types from 'vs/base/common/types';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { ICellModel, CellExecutionState } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { ICellModel, CellExecutionState } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { MultiStateAction, IMultiStateData } from 'sql/workbench/parts/notebook/electron-browser/notebookActions';
import { MultiStateAction, IMultiStateData } from 'sql/workbench/parts/notebook/browser/notebookActions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ILogService } from 'vs/platform/log/common/log';
import { getErrorMessage } from 'vs/base/common/errors';

View File

@@ -5,9 +5,9 @@
import { nb } from 'azdata';
import { OnInit, Component, Input, Inject, forwardRef, ChangeDetectorRef, SimpleChange, OnChanges, HostListener } from '@angular/core';
import { CellView } from 'sql/workbench/parts/notebook/electron-browser/cellViews/interfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { CellView } from 'sql/workbench/parts/notebook/browser/cellViews/interfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { Deferred } from 'sql/base/common/promise';

View File

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 317 B

View File

@@ -9,12 +9,12 @@ import { OnInit, Component, Input, Inject, ElementRef, ViewChild, SimpleChange,
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { Event } from 'vs/base/common/event';
import { nb } from 'azdata';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import * as outputProcessor from 'sql/workbench/parts/notebook/common/models/outputProcessor';
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
import * as DOM from 'vs/base/browser/dom';
import { ComponentHostDirective } from 'sql/workbench/parts/dashboard/browser/core/componentHost.directive';
import { Extensions, IMimeComponent, IMimeComponentRegistry } from 'sql/workbench/parts/notebook/electron-browser/outputs/mimeRegistry';
import { Extensions, IMimeComponent, IMimeComponentRegistry } from 'sql/workbench/parts/notebook/browser/outputs/mimeRegistry';
import * as colors from 'vs/platform/theme/common/colorRegistry';
import * as themeColors from 'vs/workbench/common/theme';
import { Registry } from 'vs/platform/registry/common/platform';

View File

@@ -6,7 +6,7 @@ import 'vs/css!./code';
import 'vs/css!./outputArea';
import { OnInit, Component, Input, Inject, ElementRef, ViewChild, forwardRef, ChangeDetectorRef } from '@angular/core';
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import * as themeColors from 'vs/workbench/common/theme';
import { IWorkbenchThemeService, IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { URI } from 'vs/base/common/uri';

View File

@@ -5,9 +5,9 @@
import 'vs/css!./placeholder';
import { OnInit, Component, Input, Inject, forwardRef, ElementRef, ChangeDetectorRef, OnDestroy, ViewChild, SimpleChange, OnChanges } from '@angular/core';
import { CellView } from 'sql/workbench/parts/notebook/electron-browser/cellViews/interfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { CellView } from 'sql/workbench/parts/notebook/browser/cellViews/interfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { localize } from 'vs/nls';
import { CellType } from 'sql/workbench/parts/notebook/common/models/contracts';

View File

@@ -23,7 +23,7 @@ import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
import { attachInputBoxStyler } from 'sql/platform/theme/common/styler';
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { Deferred } from 'sql/base/common/promise';
import { ICellModel, CellExecutionState } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModel, CellExecutionState } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
export const STDIN_SELECTOR: string = 'stdin-component';
@Component({

View File

@@ -22,14 +22,14 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { toDisposable } from 'vs/base/common/lifecycle';
import { IMarkdownRenderResult } from 'vs/editor/contrib/markdown/markdownRenderer';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { NotebookMarkdownRenderer } from 'sql/workbench/parts/notebook/outputs/notebookMarkdown';
import { CellView } from 'sql/workbench/parts/notebook/electron-browser/cellViews/interfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { ISanitizer, defaultSanitizer } from 'sql/workbench/parts/notebook/electron-browser/outputs/sanitizer';
import { CellToggleMoreActions } from 'sql/workbench/parts/notebook/electron-browser/cellToggleMoreActions';
import { NotebookMarkdownRenderer } from 'sql/workbench/parts/notebook/browser/outputs/notebookMarkdown';
import { CellView } from 'sql/workbench/parts/notebook/browser/cellViews/interfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { ISanitizer, defaultSanitizer } from 'sql/workbench/parts/notebook/browser/outputs/sanitizer';
import { CellToggleMoreActions } from 'sql/workbench/parts/notebook/browser/cellToggleMoreActions';
import { CommonServiceInterface } from 'sql/platform/bootstrap/browser/commonServiceInterface.service';
import { useInProcMarkdown, convertVscodeResourceToFileInSubDirectories } from 'sql/workbench/parts/notebook/node/models/notebookUtils';
import { useInProcMarkdown, convertVscodeResourceToFileInSubDirectories } from 'sql/workbench/parts/notebook/common/models/notebookUtils';
export const TEXT_SELECTOR: string = 'text-cell-component';
const USER_SELECT_CLASS = 'actionselect';

View File

@@ -23,24 +23,24 @@ import * as DOM from 'vs/base/browser/dom';
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { CellTypes, CellType } from 'sql/workbench/parts/notebook/common/models/contracts';
import { ICellModel, IModelFactory, INotebookModel, NotebookContentChange } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModel, IModelFactory, INotebookModel, NotebookContentChange } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { INotebookService, INotebookParams, INotebookManager, INotebookEditor, DEFAULT_NOTEBOOK_PROVIDER, SQL_NOTEBOOK_PROVIDER, INotebookSection, INavigationProvider } from 'sql/workbench/services/notebook/common/notebookService';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { ModelFactory } from 'sql/workbench/parts/notebook/node/models/modelFactory';
import * as notebookUtils from 'sql/workbench/parts/notebook/node/models/notebookUtils';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { ModelFactory } from 'sql/workbench/parts/notebook/common/models/modelFactory';
import * as notebookUtils from 'sql/workbench/parts/notebook/common/models/notebookUtils';
import { Deferred } from 'sql/base/common/promise';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
import { KernelsDropdown, AttachToDropdown, AddCellAction, TrustedAction, RunAllCellsAction, ClearAllOutputsAction } from 'sql/workbench/parts/notebook/electron-browser/notebookActions';
import { KernelsDropdown, AttachToDropdown, AddCellAction, TrustedAction, RunAllCellsAction, ClearAllOutputsAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
import * as TaskUtilities from 'sql/workbench/common/taskUtilities';
import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IConnectionDialogService } from 'sql/workbench/services/connection/common/connectionDialogService';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
import { CellMagicMapper } from 'sql/workbench/parts/notebook/node/models/cellMagicMapper';
import { CellMagicMapper } from 'sql/workbench/parts/notebook/common/models/cellMagicMapper';
import { IExtensionsViewlet, VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions';
import { CellModel } from 'sql/workbench/parts/notebook/node/models/cell';
import { CellModel } from 'sql/workbench/parts/notebook/common/models/cell';
import { FileOperationError, FileOperationResult } from 'vs/platform/files/common/files';
import { isValidBasename } from 'vs/base/common/extpath';
import { basename } from 'vs/base/common/resources';

View File

@@ -8,24 +8,22 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
import { SyncActionDescriptor, registerAction } from 'vs/platform/actions/common/actions';
import { NotebookInput } from 'sql/workbench/parts/notebook/node/notebookInput';
import { NotebookEditor } from 'sql/workbench/parts/notebook/electron-browser/notebookEditor';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/electron-browser/notebookActions';
import { NotebookInput } from 'sql/workbench/parts/notebook/common/models/notebookInput';
import { NotebookEditor } from 'sql/workbench/parts/notebook/browser/notebookEditor';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
import { KeyMod } from 'vs/editor/common/standalone/standaloneBase';
import { KeyCode } from 'vs/base/common/keyCodes';
import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { localize } from 'vs/nls';
import product from 'vs/platform/product/node/product';
import { GridOutputComponent } from 'sql/workbench/parts/notebook/outputs/gridOutput.component';
import { PlotlyOutputComponent } from 'sql/workbench/parts/notebook/outputs/plotlyOutput.component';
import { registerComponentType } from 'sql/workbench/parts/notebook/electron-browser/outputs/mimeRegistry';
import { MimeRendererComponent } from 'sql/workbench/parts/notebook/electron-browser/outputs/mimeRenderer.component';
import { MarkdownOutputComponent } from 'sql/workbench/parts/notebook/electron-browser/outputs/markdownOutput.component';
import { GridOutputComponent } from 'sql/workbench/parts/notebook/browser/outputs/gridOutput.component';
import { PlotlyOutputComponent } from 'sql/workbench/parts/notebook/browser/outputs/plotlyOutput.component';
import { registerComponentType } from 'sql/workbench/parts/notebook/browser/outputs/mimeRegistry';
import { MimeRendererComponent } from 'sql/workbench/parts/notebook/browser/outputs/mimeRenderer.component';
import { MarkdownOutputComponent } from 'sql/workbench/parts/notebook/browser/outputs/markdownOutput.component';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { URI } from 'vs/base/common/uri';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { Uri } from 'vscode';
// Model View editor registration
const viewModelEditorDescriptor = new EditorDescriptor(
@@ -53,7 +51,7 @@ actionRegistry.registerWorkbenchAction(
registerAction({
id: 'workbench.action.setWorkspaceAndOpen',
handler: async (accessor, options: { forceNewWindow: boolean, folderPath: Uri }) => {
handler: async (accessor, options: { forceNewWindow: boolean, folderPath: URI }) => {
const viewletService = accessor.get(IViewletService);
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
const windowService = accessor.get(IWindowService);

View File

@@ -12,22 +12,22 @@ import { ComponentHostDirective } from 'sql/workbench/parts/dashboard/browser/co
import { providerIterator } from 'sql/platform/bootstrap/browser/bootstrapService';
import { CommonServiceInterface } from 'sql/platform/bootstrap/browser/commonServiceInterface.service';
import { EditableDropDown } from 'sql/platform/browser/editableDropdown/editableDropdown.component';
import { NotebookComponent } from 'sql/workbench/parts/notebook/electron-browser/notebook.component';
import { NotebookComponent } from 'sql/workbench/parts/notebook/browser/notebook.component';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { CodeComponent } from 'sql/workbench/parts/notebook/electron-browser/cellViews/code.component';
import { CodeCellComponent } from 'sql/workbench/parts/notebook/electron-browser/cellViews/codeCell.component';
import { TextCellComponent } from 'sql/workbench/parts/notebook/electron-browser/cellViews/textCell.component';
import { OutputAreaComponent } from 'sql/workbench/parts/notebook/electron-browser/cellViews/outputArea.component';
import { OutputComponent } from 'sql/workbench/parts/notebook/electron-browser/cellViews/output.component';
import { StdInComponent } from 'sql/workbench/parts/notebook/electron-browser/cellViews/stdin.component';
import { PlaceholderCellComponent } from 'sql/workbench/parts/notebook/electron-browser/cellViews/placeholderCell.component';
import { CodeComponent } from 'sql/workbench/parts/notebook/browser/cellViews/code.component';
import { CodeCellComponent } from 'sql/workbench/parts/notebook/browser/cellViews/codeCell.component';
import { TextCellComponent } from 'sql/workbench/parts/notebook/browser/cellViews/textCell.component';
import { OutputAreaComponent } from 'sql/workbench/parts/notebook/browser/cellViews/outputArea.component';
import { OutputComponent } from 'sql/workbench/parts/notebook/browser/cellViews/output.component';
import { StdInComponent } from 'sql/workbench/parts/notebook/browser/cellViews/stdin.component';
import { PlaceholderCellComponent } from 'sql/workbench/parts/notebook/browser/cellViews/placeholderCell.component';
import LoadingSpinner from 'sql/workbench/browser/modelComponents/loadingSpinner.component';
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox.component';
import { SelectBox } from 'sql/platform/browser/selectBox/selectBox.component';
import { InputBox } from 'sql/platform/browser/inputbox/inputBox.component';
import { IMimeComponentRegistry, Extensions } from 'sql/workbench/parts/notebook/electron-browser/outputs/mimeRegistry';
import { IMimeComponentRegistry, Extensions } from 'sql/workbench/parts/notebook/browser/outputs/mimeRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import { LinkHandlerDirective } from 'sql/workbench/parts/notebook/electron-browser/cellViews/linkHandler.directive';
import { LinkHandlerDirective } from 'sql/workbench/parts/notebook/browser/cellViews/linkHandler.directive';
import { IBootstrapParams, ISelector } from 'sql/platform/bootstrap/common/bootstrapParams';
export const NotebookModule = (params, selector: string, instantiationService: IInstantiationService): any => {

View File

@@ -16,15 +16,15 @@ import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilit
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { noKernel } from 'sql/workbench/services/notebook/common/sessionManager';
import { IConnectionDialogService } from 'sql/workbench/services/connection/common/connectionDialogService';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { generateUri } from 'sql/platform/connection/common/utils';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ILogService } from 'vs/platform/log/common/log';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { CellType } from 'sql/workbench/parts/notebook/common/models/contracts';
import { NotebookComponent } from 'sql/workbench/parts/notebook/electron-browser/notebook.component';
import { NotebookComponent } from 'sql/workbench/parts/notebook/browser/notebook.component';
import { getErrorMessage } from 'vs/base/common/errors';
import { INotebookModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { INotebookModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
const msgLoading = localize('loading', "Loading kernels...");
const msgChanging = localize('changing', "Changing kernel...");

View File

@@ -11,9 +11,9 @@ import { bootstrapAngular } from 'sql/platform/bootstrap/browser/bootstrapServic
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { CancellationToken } from 'vs/base/common/cancellation';
import { NotebookInput } from 'sql/workbench/parts/notebook/node/notebookInput';
import { NotebookModule } from 'sql/workbench/parts/notebook/electron-browser/notebook.module';
import { NOTEBOOK_SELECTOR } from 'sql/workbench/parts/notebook/electron-browser/notebook.component';
import { NotebookInput } from 'sql/workbench/parts/notebook/common/models/notebookInput';
import { NotebookModule } from 'sql/workbench/parts/notebook/browser/notebook.module';
import { NOTEBOOK_SELECTOR } from 'sql/workbench/parts/notebook/browser/notebook.component';
import { INotebookParams } from 'sql/workbench/services/notebook/common/notebookService';
import { IStorageService } from 'vs/platform/storage/common/storage';

View File

@@ -23,8 +23,8 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { localize } from 'vs/nls';
import { IAction } from 'vs/base/common/actions';
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { IMimeComponent } from 'sql/workbench/parts/notebook/electron-browser/outputs/mimeRegistry';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { IMimeComponent } from 'sql/workbench/parts/notebook/browser/outputs/mimeRegistry';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { MimeModel } from 'sql/workbench/parts/notebook/common/models/mimemodel';
import { GridTableState } from 'sql/workbench/parts/query/common/gridPanelState';
import { GridTableBase } from 'sql/workbench/parts/query/browser/gridPanel';

View File

@@ -9,16 +9,16 @@ import 'vs/css!../cellViews/media/highlight';
import { OnInit, Component, Input, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild } from '@angular/core';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ISanitizer, defaultSanitizer } from 'sql/workbench/parts/notebook/electron-browser/outputs/sanitizer';
import { ISanitizer, defaultSanitizer } from 'sql/workbench/parts/notebook/browser/outputs/sanitizer';
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { IMimeComponent } from 'sql/workbench/parts/notebook/electron-browser/outputs/mimeRegistry';
import { IMimeComponent } from 'sql/workbench/parts/notebook/browser/outputs/mimeRegistry';
import { INotebookService } from 'sql/workbench/services/notebook/common/notebookService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { NotebookMarkdownRenderer } from 'sql/workbench/parts/notebook/outputs/notebookMarkdown';
import { NotebookMarkdownRenderer } from 'sql/workbench/parts/notebook/browser/outputs/notebookMarkdown';
import { MimeModel } from 'sql/workbench/parts/notebook/common/models/mimemodel';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { useInProcMarkdown, convertVscodeResourceToFileInSubDirectories } from 'sql/workbench/parts/notebook/node/models/notebookUtils';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { useInProcMarkdown, convertVscodeResourceToFileInSubDirectories } from 'sql/workbench/parts/notebook/common/models/notebookUtils';
import { URI } from 'vs/base/common/uri';
@Component({

View File

@@ -8,7 +8,7 @@ import * as platform from 'vs/platform/registry/common/platform';
import { ReadonlyJSONObject } from 'sql/workbench/parts/notebook/common/models/jsonext';
import { MimeModel } from 'sql/workbench/parts/notebook/common/models/mimemodel';
import * as types from 'vs/base/common/types';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
export type FactoryIdentifier = string;

View File

@@ -3,12 +3,12 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IMimeComponent } from 'sql/workbench/parts/notebook/electron-browser/outputs/mimeRegistry';
import { IMimeComponent } from 'sql/workbench/parts/notebook/browser/outputs/mimeRegistry';
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { ElementRef, forwardRef, Inject, Component, OnInit, Input } from '@angular/core';
import { MimeModel } from 'sql/workbench/parts/notebook/common/models/mimemodel';
import { INotebookService } from 'sql/workbench/services/notebook/common/notebookService';
import { RenderMimeRegistry } from 'sql/workbench/parts/notebook/electron-browser/outputs/registry';
import { RenderMimeRegistry } from 'sql/workbench/parts/notebook/browser/outputs/registry';
import { localize } from 'vs/nls';
@Component({

View File

@@ -6,7 +6,6 @@ import * as path from 'path';
import { URI } from 'vs/base/common/uri';
import { dispose } from 'vs/base/common/lifecycle';
import { RenderOptions } from 'vs/base/browser/htmlContentRenderer';
import { IMarkdownString, removeMarkdownEscapes } from 'vs/base/common/htmlContent';
import { IMarkdownRenderResult } from 'vs/editor/contrib/markdown/markdownRenderer';

View File

@@ -9,8 +9,8 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { localize } from 'vs/nls';
import * as types from 'vs/base/common/types';
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { IMimeComponent } from 'sql/workbench/parts/notebook/electron-browser/outputs/mimeRegistry';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { IMimeComponent } from 'sql/workbench/parts/notebook/browser/outputs/mimeRegistry';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { MimeModel } from 'sql/workbench/parts/notebook/common/models/mimemodel';
import { getErrorMessage } from 'vs/base/common/errors';

View File

@@ -9,11 +9,10 @@ import { Event, Emitter } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { localize } from 'vs/nls';
import * as notebookUtils from './notebookUtils';
import * as notebookUtils from 'sql/workbench/parts/notebook/common/models/notebookUtils';
import { CellTypes, CellType, NotebookChangeType } from 'sql/workbench/parts/notebook/common/models/contracts';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { ICellModel, notebookConstants, IOutputChangedEvent } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModelOptions, FutureInternal, CellExecutionState } from './modelInterfaces';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { ICellModel, notebookConstants, IOutputChangedEvent, FutureInternal, CellExecutionState, ICellModelOptions } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ICellMagicMapper } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellMagicMapper } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { ILanguageMagic } from 'sql/workbench/services/notebook/common/notebookService';
const defaultKernel = '*';

View File

@@ -9,13 +9,12 @@ import { nb } from 'azdata';
import { URI } from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
import { localize } from 'vs/nls';
import { getErrorMessage } from 'vs/base/common/errors';
import { IClientSession, IKernelPreference, IClientSessionOptions } from './modelInterfaces';
import { IClientSession, IKernelPreference, IClientSessionOptions } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { Deferred } from 'sql/base/common/promise';
import { INotebookManager } from 'sql/workbench/services/notebook/common/notebookService';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { getErrorMessage } from 'vs/base/common/errors';
type KernelChangeHandler = (kernel: nb.IKernelChangedArgs) => Promise<void>;
/**

View File

@@ -5,9 +5,9 @@
import { nb } from 'azdata';
import { CellModel } from './cell';
import { IClientSession, IClientSessionOptions, ICellModelOptions, ICellModel, IModelFactory } from './modelInterfaces';
import { ClientSession } from './clientSession';
import { CellModel } from 'sql/workbench/parts/notebook/common/models/cell';
import { IClientSession, IClientSessionOptions, ICellModelOptions, ICellModel, IModelFactory } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { ClientSession } from 'sql/workbench/parts/notebook/common/models/clientSession';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export class ModelFactory implements IModelFactory {

View File

@@ -16,11 +16,11 @@ import { INotebookManager, ILanguageMagic } from 'sql/workbench/services/noteboo
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IStandardKernelWithProvider } from 'sql/workbench/parts/notebook/node/models/notebookUtils';
import { IStandardKernelWithProvider } from 'sql/workbench/parts/notebook/common/models/notebookUtils';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
import { localize } from 'vs/nls';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
export interface IClientSessionOptions {

View File

@@ -6,7 +6,7 @@
import { nb } from 'azdata';
import { localize } from 'vs/nls';
import { IDefaultConnection, notebookConstants } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { IDefaultConnection, notebookConstants } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';

View File

@@ -10,17 +10,17 @@ import { URI } from 'vs/base/common/uri';
import * as resources from 'vs/base/common/resources';
import * as azdata from 'azdata';
import { IStandardKernelWithProvider, getProvidersForFileName, getStandardKernelsForProvider } from 'sql/workbench/parts/notebook/node/models/notebookUtils';
import { IStandardKernelWithProvider, getProvidersForFileName, getStandardKernelsForProvider } from 'sql/workbench/parts/notebook/common/models/notebookUtils';
import { INotebookService, DEFAULT_NOTEBOOK_PROVIDER, IProviderInfo } from 'sql/workbench/services/notebook/common/notebookService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { INotebookModel, IContentManager, NotebookContentChange } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { INotebookModel, IContentManager, NotebookContentChange } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { Range } from 'vs/editor/common/core/range';
import { UntitledEditorModel } from 'vs/workbench/common/editor/untitledEditorModel';
import { Schemas } from 'vs/base/common/network';
import { ITextFileService, ISaveOptions, StateChange } from 'vs/workbench/services/textfile/common/textfiles';
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
@@ -198,7 +198,7 @@ export class NotebookInput extends EditorInput {
public get contentManager(): IContentManager {
if (!this._contentManager) {
this._contentManager = new NotebookEditorContentManager(this);
this._contentManager = this.instantiationService.createInstance(NotebookEditorContentManager, this);
}
return this._contentManager;
}
@@ -398,12 +398,14 @@ export class NotebookInput extends EditorInput {
}
class NotebookEditorContentManager implements IContentManager {
constructor(private notebookInput: NotebookInput) {
constructor(
private notebookInput: NotebookInput,
@IInstantiationService private readonly instantiationService: IInstantiationService) {
}
async loadContent(): Promise<azdata.nb.INotebookContents> {
let notebookEditorModel = await this.notebookInput.resolve();
let contentManager = new LocalContentManager();
let contentManager = this.instantiationService.createInstance(LocalContentManager);
let contents = await contentManager.loadFromContentString(notebookEditorModel.contentString);
return contents;
}

View File

@@ -9,13 +9,13 @@ import { localize } from 'vs/nls';
import { Event, Emitter } from 'vs/base/common/event';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { IClientSession, INotebookModel, IDefaultConnection, INotebookModelOptions, ICellModel, NotebookContentChange, notebookConstants } from './modelInterfaces';
import { IClientSession, INotebookModel, IDefaultConnection, INotebookModelOptions, ICellModel, NotebookContentChange, notebookConstants } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { NotebookChangeType, CellType, CellTypes } from 'sql/workbench/parts/notebook/common/models/contracts';
import { nbversion } from '../../common/models/notebookConstants';
import * as notebookUtils from './notebookUtils';
import { nbversion } from 'sql/workbench/parts/notebook/common/models/notebookConstants';
import * as notebookUtils from 'sql/workbench/parts/notebook/common/models/notebookUtils';
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
import { INotebookManager, SQL_NOTEBOOK_PROVIDER, DEFAULT_NOTEBOOK_PROVIDER } from 'sql/workbench/services/notebook/common/notebookService';
import { NotebookContexts } from 'sql/workbench/parts/notebook/node/models/notebookContexts';
import { NotebookContexts } from 'sql/workbench/parts/notebook/common/models/notebookContexts';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { INotification, Severity, INotificationService } from 'vs/platform/notification/common/notification';
import { URI } from 'vs/base/common/uri';

View File

@@ -5,14 +5,10 @@
import * as path from 'path';
import { nb } from 'azdata';
import * as os from 'os';
import * as pfs from 'vs/base/node/pfs';
import { localize } from 'vs/nls';
import { DEFAULT_NOTEBOOK_PROVIDER, DEFAULT_NOTEBOOK_FILETYPE, INotebookService } from 'sql/workbench/services/notebook/common/notebookService';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { IOutputChannel } from 'vs/workbench/contrib/output/common/output';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
/**
@@ -26,15 +22,6 @@ export function getUserHome(): string {
return process.env.HOME || process.env.USERPROFILE;
}
export async function mkDir(dirPath: string, outputChannel?: IOutputChannel): Promise<void> {
let exists = await pfs.dirExists(dirPath);
if (!exists) {
if (outputChannel) {
outputChannel.append(localize('mkdirOutputMsg', '... Creating {0}', dirPath) + os.EOL);
}
await pfs.mkdirp(dirPath);
}
}
export function getProvidersForFileName(fileName: string, notebookService: INotebookService): string[] {
let fileExt = path.extname(fileName);

View File

@@ -10,10 +10,10 @@ import { nb } from 'azdata';
import * as objects from 'vs/base/common/objects';
import { CellTypes } from 'sql/workbench/parts/notebook/common/models/contracts';
import { ModelFactory } from 'sql/workbench/parts/notebook/node/models/modelFactory';
import { ModelFactory } from 'sql/workbench/parts/notebook/common/models/modelFactory';
import { NotebookModelStub } from './common';
import { EmptyFuture } from 'sql/workbench/services/notebook/common/sessionManager';
import { ICellModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { Deferred } from 'sql/base/common/promise';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';

View File

@@ -11,7 +11,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import { URI } from 'vs/base/common/uri';
import { ClientSession } from 'sql/workbench/parts/notebook/node/models/clientSession';
import { ClientSession } from 'sql/workbench/parts/notebook/common/models/clientSession';
import { SessionManager, EmptySession } from 'sql/workbench/services/notebook/common/sessionManager';
import { NotebookManagerStub, ServerManagerStub } from './common';

View File

@@ -6,11 +6,11 @@
import { nb, IConnectionProfile } from 'azdata';
import { Event, Emitter } from 'vs/base/common/event';
import { INotebookModel, ICellModel, IClientSession, IDefaultConnection, NotebookContentChange } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { INotebookModel, ICellModel, IClientSession, IDefaultConnection, NotebookContentChange } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { NotebookChangeType, CellType } from 'sql/workbench/parts/notebook/common/models/contracts';
import { INotebookManager } from 'sql/workbench/services/notebook/common/notebookService';
import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IStandardKernelWithProvider } from 'sql/workbench/parts/notebook/node/models/notebookUtils';
import { IStandardKernelWithProvider } from 'sql/workbench/parts/notebook/common/models/notebookUtils';
export class NotebookModelStub implements INotebookModel {
constructor(private _languageInfo?: nb.ILanguageInfo) {

View File

@@ -5,12 +5,18 @@
import * as should from 'should';
import { nb } from 'azdata';
import * as typemoq from 'typemoq';
import { URI } from 'vs/base/common/uri';
import * as tempWrite from 'temp-write';
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
import * as testUtils from '../../../../../../sqltest/utils/testUtils';
import { CellTypes } from 'sql/workbench/parts/notebook/common/models/contracts';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { TestFileService } from 'vs/workbench/test/workbenchTestServices';
import { IFileService, IReadFileOptions, IFileContent, IWriteFileOptions, IFileStatWithMetadata } from 'vs/platform/files/common/files';
import * as pfs from 'vs/base/node/pfs';
import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
let expectedNotebookContent: nb.INotebookContents = {
cells: [{
@@ -40,7 +46,23 @@ function verifyMatchesExpectedNotebook(notebook: nb.INotebookContents): void {
}
suite('Local Content Manager', function (): void {
let contentManager = new LocalContentManager();
let contentManager: LocalContentManager;
setup(() => {
const instantiationService = new TestInstantiationService();
const fileService = new class extends TestFileService {
async readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
const content = await pfs.readFile(resource.fsPath);
return { name: ',', size: 0, etag: '', mtime: 0, value: VSBuffer.fromString(content.toString()), resource };
}
async writeFile(resource: URI, bufferOrReadable: VSBuffer | VSBufferReadable, options?: IWriteFileOptions): Promise<IFileStatWithMetadata> {
await pfs.writeFile(resource.fsPath, bufferOrReadable.toString());
return { resource: resource, mtime: 0, etag: '', size: 0, name: '', isDirectory: false };
}
};
instantiationService.set(IFileService, fileService);
contentManager = instantiationService.createInstance(LocalContentManager);
});
test('Should return undefined if path is undefined', async function (): Promise<void> {
let content = await contentManager.getNotebookContents(undefined);

View File

@@ -11,12 +11,12 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import { URI } from 'vs/base/common/uri';
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
import { NotebookManagerStub } from './common';
import { NotebookModel } from 'sql/workbench/parts/notebook/node/models/notebookModel';
import { ModelFactory } from 'sql/workbench/parts/notebook/node/models/modelFactory';
import { IClientSession, ICellModel, INotebookModelOptions, NotebookContentChange } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ClientSession } from 'sql/workbench/parts/notebook/node/models/clientSession';
import { NotebookModel } from 'sql/workbench/parts/notebook/common/models/notebookModel';
import { ModelFactory } from 'sql/workbench/parts/notebook/common/models/modelFactory';
import { IClientSession, ICellModel, INotebookModelOptions, NotebookContentChange } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { ClientSession } from 'sql/workbench/parts/notebook/common/models/clientSession';
import { CellTypes, NotebookChangeType } from 'sql/workbench/parts/notebook/common/models/contracts';
import { Deferred } from 'sql/base/common/promise';
import { ConnectionManagementService } from 'sql/platform/connection/common/connectionManagementService';

View File

@@ -8,7 +8,7 @@ import { IConnectionProfile } from 'azdata';
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { formatServerNameWithDatabaseNameForAttachTo, getServerFromFormattedAttachToName, getDatabaseFromFormattedAttachToName } from 'sql/workbench/parts/notebook/node/models/notebookUtils';
import { formatServerNameWithDatabaseNameForAttachTo, getServerFromFormattedAttachToName, getDatabaseFromFormattedAttachToName } from 'sql/workbench/parts/notebook/common/models/notebookUtils';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
suite('notebookUtils', function (): void {

View File

@@ -31,7 +31,7 @@ import { IQueryManagementService } from 'sql/platform/query/common/queryManageme
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/electron-browser/notebookActions';
import { NewNotebookAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
/**
* Provides actions for the server tree elements

View File

@@ -8,19 +8,22 @@
import { nb } from 'azdata';
import * as json from 'vs/base/common/json';
import * as pfs from 'vs/base/node/pfs';
import { URI } from 'vs/base/common/uri';
import { localize } from 'vs/nls';
import { IFileService } from 'vs/platform/files/common/files';
import { JSONObject } from 'sql/workbench/parts/notebook/common/models/jsonext';
import { OutputTypes } from 'sql/workbench/parts/notebook/common/models/contracts';
import { nbversion } from 'sql/workbench/parts/notebook/common/models/notebookConstants';
import { nbformat } from 'sql/workbench/parts/notebook/common/models/nbformat';
import { VSBuffer } from 'vs/base/common/buffer';
type MimeBundle = { [key: string]: string | string[] | undefined };
export class LocalContentManager implements nb.ContentManager {
constructor(@IFileService private readonly fileService: IFileService) { }
public async loadFromContentString(contentString: string): Promise<nb.INotebookContents> {
let contents: JSONObject = json.parse(contentString);
@@ -47,11 +50,9 @@ export class LocalContentManager implements nb.ContentManager {
if (!notebookUri) {
return undefined;
}
// TODO validate this is an actual file URI, and error if not
let path = notebookUri.fsPath;
// Note: intentionally letting caller handle exceptions
let notebookFileBuffer = await pfs.readFile(path);
let stringContents = notebookFileBuffer.toString();
let notebookFileBuffer = await this.fileService.readFile(notebookUri);
let stringContents = notebookFileBuffer.value.toString();
let contents: JSONObject = json.parse(stringContents);
if (contents) {
@@ -76,8 +77,7 @@ export class LocalContentManager implements nb.ContentManager {
public async save(notebookUri: URI, notebook: nb.INotebookContents): Promise<nb.INotebookContents> {
// Convert to JSON with pretty-print functionality
let contents = JSON.stringify(notebook, undefined, ' ');
let path = notebookUri.fsPath;
await pfs.writeFile(path, contents);
await this.fileService.writeFile(notebookUri, VSBuffer.fromString(contents));
return notebook;
}

View File

@@ -8,12 +8,12 @@ import * as azdata from 'azdata';
import { Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { URI } from 'vs/base/common/uri';
import { RenderMimeRegistry } from 'sql/workbench/parts/notebook/electron-browser/outputs/registry';
import { ModelFactory } from 'sql/workbench/parts/notebook/node/models/modelFactory';
import { RenderMimeRegistry } from 'sql/workbench/parts/notebook/browser/outputs/registry';
import { ModelFactory } from 'sql/workbench/parts/notebook/common/models/modelFactory';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { NotebookInput } from 'sql/workbench/parts/notebook/node/notebookInput';
import { NotebookInput } from 'sql/workbench/parts/notebook/common/models/notebookInput';
import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes';
import { ICellModel, INotebookModel } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { ICellModel, INotebookModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { NotebookChangeType } from 'sql/workbench/parts/notebook/common/models/contracts';
import { IBootstrapParams } from 'sql/platform/bootstrap/common/bootstrapParams';

View File

@@ -12,8 +12,8 @@ import {
INotebookService, INotebookManager, INotebookProvider,
DEFAULT_NOTEBOOK_FILETYPE, INotebookEditor, SQL_NOTEBOOK_PROVIDER, OVERRIDE_EDITOR_THEMING_SETTING, INavigationProvider, ILanguageMagic
} from 'sql/workbench/services/notebook/common/notebookService';
import { RenderMimeRegistry } from 'sql/workbench/parts/notebook/electron-browser/outputs/registry';
import { standardRendererFactories } from 'sql/workbench/parts/notebook/electron-browser/outputs/factories';
import { RenderMimeRegistry } from 'sql/workbench/parts/notebook/browser/outputs/registry';
import { standardRendererFactories } from 'sql/workbench/parts/notebook/browser/outputs/factories';
import { Extensions, INotebookProviderRegistry, NotebookProviderRegistration } from 'sql/workbench/services/notebook/common/notebookRegistry';
import { Emitter, Event } from 'vs/base/common/event';
import { Memento } from 'vs/workbench/common/memento';
@@ -26,11 +26,11 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { NotebookEditorVisibleContext } from 'sql/workbench/services/notebook/common/notebookContext';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { NotebookEditor } from 'sql/workbench/parts/notebook/electron-browser/notebookEditor';
import { NotebookEditor } from 'sql/workbench/parts/notebook/browser/notebookEditor';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { registerNotebookThemes } from 'sql/workbench/parts/notebook/browser/notebookStyles';
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
import { notebookConstants } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { notebookConstants } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { SqlNotebookProvider } from 'sql/workbench/services/notebook/sql/sqlNotebookProvider';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';

View File

@@ -5,7 +5,7 @@
import { nb } from 'azdata';
import { localize } from 'vs/nls';
import { FutureInternal } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { FutureInternal } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
export const noKernel: string = localize('noKernel', "No Kernel");

View File

@@ -8,16 +8,16 @@ import * as vscode from 'vscode';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { SQL_NOTEBOOK_PROVIDER } from 'sql/workbench/services/notebook/common/notebookService';
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
import { SqlSessionManager } from 'sql/workbench/services/notebook/sql/sqlSessionManager';
export class SqlNotebookManager implements nb.NotebookProvider {
private _contentManager: nb.ContentManager;
private _sessionManager: nb.SessionManager;
constructor(private _instantiationService: IInstantiationService) {
this._contentManager = new LocalContentManager();
this._sessionManager = new SqlSessionManager(this._instantiationService);
constructor(instantiationService: IInstantiationService) {
this._contentManager = instantiationService.createInstance(LocalContentManager);
this._sessionManager = new SqlSessionManager(instantiationService);
}
public get providerId(): string {

View File

@@ -6,7 +6,7 @@
import * as os from 'os';
import { nb, QueryExecuteSubsetResult, IDbColumn, BatchSummary, IResultMessage, ResultSetSummary } from 'azdata';
import { localize } from 'vs/nls';
import { FutureInternal, notebookConstants } from 'sql/workbench/parts/notebook/node/models/modelInterfaces';
import { FutureInternal, notebookConstants } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
import QueryRunner from 'sql/platform/query/common/queryRunner';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -17,7 +17,7 @@ import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMess
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { escape } from 'sql/base/common/strings';
import * as notebookUtils from 'sql/workbench/parts/notebook/node/models/notebookUtils';
import * as notebookUtils from 'sql/workbench/parts/notebook/common/models/notebookUtils';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
import { ILogService } from 'vs/platform/log/common/log';

View File

@@ -14,10 +14,12 @@ import { MainThreadNotebook } from 'sql/workbench/api/browser/mainThreadNotebook
import { NotebookService } from 'sql/workbench/services/notebook/common/notebookServiceImpl';
import { INotebookProvider } from 'sql/workbench/services/notebook/common/notebookService';
import { INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails } from 'sql/workbench/api/common/sqlExtHostTypes';
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
import { TestLifecycleService } from 'vs/workbench/test/workbenchTestServices';
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
import { ExtHostNotebookShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
suite('MainThreadNotebook Tests', () => {
@@ -32,9 +34,10 @@ suite('MainThreadNotebook Tests', () => {
let extContext = <IExtHostContext>{
getProxy: proxyType => mockProxy.object
};
mockNotebookService = TypeMoq.Mock.ofType(NotebookService, undefined, new TestLifecycleService(), undefined, undefined, undefined, undefined, new MockContextKeyService());
const instantiationService = new TestInstantiationService();
mockNotebookService = TypeMoq.Mock.ofType(NotebookService, undefined, new TestLifecycleService(), undefined, undefined, undefined, instantiationService, new MockContextKeyService());
notebookUri = URI.parse('file:/user/default/my.ipynb');
mainThreadNotebook = new MainThreadNotebook(extContext, mockNotebookService.object);
mainThreadNotebook = new MainThreadNotebook(extContext, mockNotebookService.object, instantiationService);
});
suite('On registering a provider', () => {