Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move NotebookControllerManager into the DI container for web #9690

Merged
merged 9 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 8 additions & 17 deletions build/webpack/webpack.extension.web.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@ const config = {
},
module: {
rules: [
{
// JupyterServices imports node-fetch.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as I started importing these into the web bundle, this code failed to work.

I believe we don't need in the webbundle anymore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not seeing the node-fetch usage anymore in jupyterlab services.

test: /@jupyterlab[\\\/]services[\\\/].*js$/,
use: [
{
loader: path.join(__dirname, 'loaders', 'fixNodeFetch.js')
}
]
},
{
test: /\.ts$/,
use: [
{
loader: path.join(__dirname, 'loaders', 'externalizeDependencies.js')
}
]
},
{
test: /\.ts$/,
exclude: /node_modules/,
Expand Down Expand Up @@ -134,6 +117,14 @@ const config = {
path: path.resolve(constants.ExtensionRootDir, 'out'),
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]'
},
watchOptions: {
aggregateTimeout: 200,
poll: 1000,
ignored: /node_modules/
},
stats: {
builtAt: true
}
};
// tslint:disable-next-line:no-default-export
Expand Down
20 changes: 17 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@
"compiled": "deemon npm run compile",
"kill-compiled": "deemon --kill npm run compile",
"compile-webviews-watch": "webpack --config ./build/webpack/webpack.datascience-ui.config.js --watch",
"compile-web-watch": "webpack --config ./build/webpack/webpack.extension.web.config.js --stats-error-details --watch",
"compile-web-watch": "webpack --config ./build/webpack/webpack.extension.web.config.js --stats-error-details --watch --progress",
"compile-web": "webpack --config ./build/webpack/webpack.extension.web.config.js",
"compile-web-test": "cross-env VSC_TEST_BUNDLE=true npm run compile-web",
"compile-web-test-watch": "cross-env VSC_TEST_BUNDLE=true npm run compile-web-watch",
Expand Down Expand Up @@ -2287,6 +2287,7 @@
"@types/temp": "^0.8.32",
"@types/tmp": "0.0.33",
"@types/untildify": "^3.0.0",
"@types/url-parse": "^1.4.8",
"@types/uuid": "^3.4.3",
"@types/vscode-notebook-renderer": "^1.60.0",
"@types/webpack-bundle-analyzer": "^2.13.0",
Expand Down
2 changes: 2 additions & 0 deletions src/extension.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import { OutputChannelLogger } from './platform/logging/outputChannelLogger';
import { ConsoleLogger } from './platform/logging/consoleLogger';
import { FileLogger } from './platform/logging/fileLogger.node';
import { createWriteStream } from 'fs-extra';
import { initializeGlobals as initializeTelemetryGlobals } from './telemetry/telemetry';

durations.codeLoadingTime = stopWatch.elapsedTime;

Expand Down Expand Up @@ -160,6 +161,7 @@ async function activateUnsafe(

const [serviceManager, serviceContainer] = initializeGlobals(context);
activatedServiceContainer = serviceContainer;
initializeTelemetryGlobals(serviceContainer);
const activationPromise = activateComponents(context, serviceManager, serviceContainer);

//===============================================
Expand Down
10 changes: 10 additions & 0 deletions src/extension.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ import { sendErrorTelemetry, sendStartupTelemetry } from './platform/startupTele
import { noop } from './platform/common/utils/misc';
import { JUPYTER_OUTPUT_CHANNEL, PythonExtension } from './webviews/webview-side/common/constants';
import { registerTypes as registerPlatformTypes } from './platform/serviceRegistry.web';
import { registerTypes as registerTelemetryTypes } from './telemetry/serviceRegistry.web';
import { registerTypes as registerKernelTypes } from './kernels/serviceRegistry.web';
import { registerTypes as registerNotebookTypes } from './notebooks/serviceRegistry.web';
import { registerTypes as registerInteractiveTypes } from './interactive-window/serviceRegistry.web';
import { IExtensionActivationManager } from './platform/activation/types';
import { isCI, isTestExecution, STANDARD_OUTPUT_CHANNEL } from './platform/common/constants';
import { getJupyterOutputChannel } from './platform/devTools/jupyterOutputChannel';
Expand All @@ -72,6 +76,7 @@ import { ServiceContainer } from './platform/ioc/container';
import { ServiceManager } from './platform/ioc/serviceManager';
import { OutputChannelLogger } from './platform/logging/outputChannelLogger';
import { ConsoleLogger } from './platform/logging/consoleLogger';
import { initializeGlobals as initializeTelemetryGlobals } from './telemetry/telemetry';

durations.codeLoadingTime = stopWatch.elapsedTime;

Expand Down Expand Up @@ -146,6 +151,7 @@ async function activateUnsafe(

const [serviceManager, serviceContainer] = initializeGlobals(context);
activatedServiceContainer = serviceContainer;
initializeTelemetryGlobals(serviceContainer);
const activationPromise = activateComponents(context, serviceManager, serviceContainer);

//===============================================
Expand Down Expand Up @@ -270,6 +276,10 @@ async function activateLegacy(

// Register the rest of the types (platform is first because it's needed by others)
registerPlatformTypes(context, serviceManager, isDevMode);
registerTelemetryTypes(serviceManager);
registerNotebookTypes(serviceManager);
registerKernelTypes(serviceManager, isDevMode);
registerInteractiveTypes(serviceManager);

// Load the two data science experiments that we need to register types
// Await here to keep the register method sync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {
isPythonKernelConnection,
getKernelConnectionLanguage,
getLanguageInNotebookMetadata
} from '../kernels/helpers.node';
} from '../kernels/helpers';
import { KernelConnectionMetadata } from '../kernels/types';
import { isJupyterNotebook, getNotebookMetadata } from '../notebooks/helpers.node';
import { translateKernelLanguageToMonaco } from '../platform/common/utils.node';
import { isJupyterNotebook, getNotebookMetadata } from '../notebooks/helpers';
import { translateKernelLanguageToMonaco } from '../platform/common/utils';

export const LastSavedNotebookCellLanguage = 'DATASCIENCE.LAST_SAVED_CELL_LANGUAGE';
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { IDisposable } from '@fluentui/react';
import { injectable, inject } from 'inversify';
import {
CancellationToken,
Expand Down Expand Up @@ -30,10 +29,10 @@ import { IExtensionSyncActivationService } from '../platform/activation/types';
import { IVSCodeNotebook, IDocumentManager } from '../platform/common/application/types';
import { PYTHON_LANGUAGE } from '../platform/common/constants';
import { disposeAllDisposables } from '../platform/common/helpers';
import { IDisposableRegistry } from '../platform/common/types';
import { IDisposable, IDisposableRegistry } from '../platform/common/types';
import { DataScience } from '../platform/common/utils/localize';
import { JupyterNotebookView } from '../notebooks/constants';
import { getAssociatedJupyterNotebook } from '../notebooks/helpers.node';
import { getAssociatedJupyterNotebook } from '../notebooks/helpers';

type CellUri = string;
type CellVersion = number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { PYTHON_LANGUAGE } from '../platform/common/constants';
import { traceError } from '../platform/logging';
import { IDisposableRegistry } from '../platform/common/types';
import { noop } from '../platform/common/utils/misc';
import { chainWithPendingUpdates } from '../notebooks/execution/notebookUpdater.node';
import { isJupyterNotebook } from '../notebooks/helpers.node';
import { chainWithPendingUpdates } from '../notebooks/execution/notebookUpdater';
import { isJupyterNotebook } from '../notebooks/helpers';
import { INotebookControllerManager } from '../notebooks/types';
import { translateKernelLanguageToMonaco } from '../platform/common/utils.node';
import { translateKernelLanguageToMonaco } from '../platform/common/utils';
import { IVSCodeNotebookController } from '../notebooks/controllers/types';
/**
* If user creates a blank notebook, then they'll mostl likely end up with a blank cell with language, lets assume `Python`.
Expand Down
8 changes: 4 additions & 4 deletions src/intellisense/intellisenseProvider.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { IExtensionSyncActivationService } from '../platform/activation/types';
import { IPythonExtensionChecker } from '../platform/api/types';
import { IVSCodeNotebook, IWorkspaceService } from '../platform/common/application/types';
import { IDisposableRegistry, IConfigurationService, IsPreRelease } from '../platform/common/types';
import { IInterpreterService } from '../platform/interpreter/contracts.node';
import { IInterpreterService } from '../platform/interpreter/contracts';
import { PythonEnvironment } from '../platform/pythonEnvironments/info';
import { getInterpreterId } from '../platform/pythonEnvironments/info/interpreter.node';
import { isJupyterNotebook, findAssociatedNotebookDocument } from '../notebooks/helpers.node';
import { getInterpreterId } from '../platform/pythonEnvironments/info/interpreter';
import { isJupyterNotebook, findAssociatedNotebookDocument } from '../notebooks/helpers';
import { INotebookLanguageClientProvider, INotebookControllerManager } from '../notebooks/types';
import { LanguageServer } from './languageServer.node';
import { IInteractiveWindowProvider } from '../interactive-window/types';
Expand Down Expand Up @@ -84,7 +84,7 @@ export class IntellisenseProvider implements INotebookLanguageClientProvider, IE
}
const folder =
this.workspaceService.getWorkspaceFolder(fsPath ? Uri.file(fsPath) : undefined)?.uri ||
(this.workspaceService.rootPath ? Uri.file(this.workspaceService.rootPath) : undefined);
(this.workspaceService.rootFolder ? this.workspaceService.rootFolder : undefined);
const key = folder ? folder.fsPath : EmptyWorkspaceKey;
if (!this.activeInterpreterCache.has(key)) {
this.interpreterService
Expand Down
2 changes: 1 addition & 1 deletion src/intellisense/languageServer.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { createNotebookMiddleware, createPylanceMiddleware, NotebookMiddleware }
import * as uuid from 'uuid/v4';
import { NOTEBOOK_SELECTOR, PYTHON_LANGUAGE } from '../platform/common/constants';
import { traceInfo } from '../platform/logging';
import { getInterpreterId } from '../platform/pythonEnvironments/info/interpreter.node';
import { getInterpreterId } from '../platform/pythonEnvironments/info/interpreter';
import { noop } from '../platform/common/utils/misc';
import { sleep } from '../platform/common/utils/async';
import { PythonEnvironment } from '../platform/pythonEnvironments/info';
Expand Down
4 changes: 2 additions & 2 deletions src/intellisense/pythonKernelCompletionProvider.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import {
} from 'vscode';
import * as lsp from 'vscode-languageclient';
import { IVSCodeNotebook } from '../platform/common/application/types';
import { createPromiseFromCancellation } from '../platform/common/cancellation.node';
import { createPromiseFromCancellation } from '../platform/common/cancellation';
import { traceError, traceInfoIfCI, traceVerbose } from '../platform/logging';
import { getDisplayPath } from '../platform/common/platform/fs-paths';
import { IConfigurationService, IDisposableRegistry } from '../platform/common/types';
import { waitForPromise } from '../platform/common/utils/async';
import { isNotebookCell } from '../platform/common/utils/misc';
import { StopWatch } from '../platform/common/utils/stopWatch';
import { IJupyterSession, IKernelProvider } from '../kernels/types';
import { findAssociatedNotebookDocument, getAssociatedJupyterNotebook } from '../notebooks/helpers.node';
import { findAssociatedNotebookDocument, getAssociatedJupyterNotebook } from '../notebooks/helpers';
import { INotebookLanguageClientProvider } from '../notebooks/types';
import { mapJupyterKind } from './conversion.node';
import { IInteractiveWindowProvider } from '../interactive-window/types';
Expand Down
18 changes: 17 additions & 1 deletion src/intellisense/serviceRegistry.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
// Licensed under the MIT License.
'use strict';

import { IExtensionSingleActivationService } from '../platform/activation/types';
import { INotebookLanguageClientProvider } from '../notebooks/types';
import { IExtensionSingleActivationService, IExtensionSyncActivationService } from '../platform/activation/types';
import { IServiceManager } from '../platform/ioc/types';
import { NotebookCellLanguageService } from './cellLanguageService';
import { NotebookCellBangInstallDiagnosticsProvider } from './diagnosticsProvider';
import { EmptyNotebookCellLanguageService } from './emptyNotebookCellLanguageService';
import { IntellisenseProvider } from './intellisenseProvider.node';
import { PythonKernelCompletionProvider } from './pythonKernelCompletionProvider.node';
import { PythonKernelCompletionProviderRegistration } from './pythonKernelCompletionProviderRegistration.node';

Expand All @@ -16,4 +21,15 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
IExtensionSingleActivationService,
PythonKernelCompletionProviderRegistration
);
serviceManager.addSingleton<IExtensionSyncActivationService>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved a bunch of stuff here from the 'notebooks' serviceRegistry. Seemed weird that notebooks would register stuff from the intellisense folder.

IExtensionSyncActivationService,
NotebookCellBangInstallDiagnosticsProvider
);
serviceManager.addSingleton<NotebookCellLanguageService>(NotebookCellLanguageService, NotebookCellLanguageService);
serviceManager.addBinding(NotebookCellLanguageService, IExtensionSingleActivationService);
serviceManager.addSingleton<IExtensionSingleActivationService>(
IExtensionSingleActivationService,
EmptyNotebookCellLanguageService
);
serviceManager.addSingleton<INotebookLanguageClientProvider>(INotebookLanguageClientProvider, IntellisenseProvider);
}
6 changes: 3 additions & 3 deletions src/interactive-window/commands/activeEditorContext.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
import { inject, injectable } from 'inversify';
import { NotebookEditor, TextEditor } from 'vscode';
import { IKernel, IKernelProvider } from '../../kernels/types';
import { getNotebookMetadata, isJupyterNotebook, isPythonNotebook } from '../../notebooks/helpers.node';
import { getNotebookMetadata, isJupyterNotebook, isPythonNotebook } from '../../notebooks/helpers';
import { IExtensionSingleActivationService } from '../../platform/activation/types';
import { ICommandManager, IDocumentManager, IVSCodeNotebook } from '../../platform/common/application/types';
import { EditorContexts, PYTHON_LANGUAGE } from '../../platform/common/constants';
import { ContextKey } from '../../platform/common/contextKey.node';
import { IDisposable, IDisposableRegistry } from '../../platform/common/types';
import { isNotebookCell, noop } from '../../platform/common/utils/misc';
import { getActiveInteractiveWindow } from '../helpers.node';
import { getActiveInteractiveWindow } from '../helpers';
import { InteractiveWindowView, JupyterNotebookView } from '../../notebooks/constants';
import { INotebookControllerManager } from '../../notebooks/types';
import { IInteractiveWindowProvider, IInteractiveWindow } from '../types';
import { getAssociatedNotebookDocument } from '../../notebooks/controllers/kernelSelector.node';
import { getAssociatedNotebookDocument } from '../../notebooks/controllers/kernelSelector';

@injectable()
export class ActiveEditorContextService implements IExtensionSingleActivationService, IDisposable {
Expand Down
2 changes: 1 addition & 1 deletion src/interactive-window/commands/commandRegistry.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from '../../platform/common/types';
import { DataScience } from '../../platform/common/utils/localize';
import { isUri, noop } from '../../platform/common/utils/misc';
import { IInterpreterService } from '../../platform/interpreter/contracts.node';
import { IInterpreterService } from '../../platform/interpreter/contracts';
import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
import { EventName } from '../../telemetry/constants';
import { ExportCommands } from './exportCommands.node';
Expand Down
4 changes: 2 additions & 2 deletions src/interactive-window/commands/exportCommands.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { DataScience } from '../../platform/common/utils/localize';
import { isUri } from '../../platform/common/utils/misc';
import { PythonEnvironment } from '../../platform/pythonEnvironments/info';
import { sendTelemetryEvent } from '../../telemetry';
import { getActiveInteractiveWindow } from '../helpers.node';
import { getNotebookMetadata, isPythonNotebook } from '../../notebooks/helpers.node';
import { getActiveInteractiveWindow } from '../helpers';
import { getNotebookMetadata, isPythonNotebook } from '../../notebooks/helpers';
import { INotebookControllerManager } from '../../notebooks/types';
import { Commands, Telemetry } from '../../platform/common/constants';
import { FileConverter } from '../../platform/export/fileConverter.node';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type * as nbformat from '@jupyterlab/nbformat';
import { NotebookCell, NotebookCellKind, NotebookDocument, Range, TextDocument, Uri } from 'vscode';

import { appendLineFeed, generateMarkdownFromCodeLines, parseForComments } from '../../webviews/webview-side/common';
import { CellMatcher } from './cellMatcher.node';
import { getInteractiveCellMetadata } from '../../interactive-window/interactiveWindow.node';
import { createJupyterCellFromVSCNotebookCell } from '../../notebooks/helpers.node';
import { CellMatcher } from './cellMatcher';
import { createJupyterCellFromVSCNotebookCell } from '../../notebooks/helpers';
import { ICell, ICellRange, IJupyterSettings, Resource } from '../../platform/common/types';
import { noop } from '../../platform/common/utils/misc';
import { getInteractiveCellMetadata } from '../helpers';

export function createCodeCell(): nbformat.ICodeCell;
// eslint-disable-next-line @typescript-eslint/unified-signatures
Expand Down
Loading