Skip to content

Commit

Permalink
Service registration refactor part 3 (#10486)
Browse files Browse the repository at this point in the history
* KernelErrorHandler

* move extension recommendtation out of platform

* move active editor context reg out

* move amlcontext out

* move import tracker out

* move global activation to extension-side

* Move port attribute provider into kernel

* Kernel Errors

* telemetry

* notebookOrKernelLanguageTelemetry

* terminal telemetry typings

* Workspace Activation registration in extension

* activation manager and survey into extension top

* 💄

* revert typings change to telemetry/types

* update telemetry.

* fix build
  • Loading branch information
rebornix authored Jun 20, 2022
1 parent f75913f commit 95736ee
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 111 deletions.
28 changes: 14 additions & 14 deletions TELEMETRY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2734,14 +2734,14 @@ No properties for event

## Locations Used

[src/platform/common/utils.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/platform/common/utils.ts)
[src/notebooks/telemetry/notebookOrKernelLanguageTelemetry.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/notebooks/telemetry/notebookOrKernelLanguageTelemetry.ts)
```typescript
}

export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
import { getTelemetrySafeLanguage } from '../../telemetry/helpers';
export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
language = getTelemetrySafeLanguage(language);
```

Expand Down Expand Up @@ -8579,14 +8579,14 @@ No description provided

## Locations Used

[src/platform/common/utils.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/platform/common/utils.ts)
[src/notebooks/telemetry/notebookOrKernelLanguageTelemetry.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/notebooks/telemetry/notebookOrKernelLanguageTelemetry.ts)
```typescript
}

export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
import { getTelemetrySafeLanguage } from '../../telemetry/helpers';
export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
language = getTelemetrySafeLanguage(language);
```

Expand Down
7 changes: 2 additions & 5 deletions src/notebooks/controllers/vscodeNotebookController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ import {
} from '../../kernels/types';
import { KernelDeadError } from '../../kernels/errors/kernelDeadError';
import { DisplayOptions } from '../../kernels/displayOptions';
import {
getNotebookMetadata,
isJupyterNotebook,
sendNotebookOrKernelLanguageTelemetry
} from '../../platform/common/utils';
import { getNotebookMetadata, isJupyterNotebook } from '../../platform/common/utils';
import { ConsoleForegroundColors, TraceOptions } from '../../platform/logging/types';
import { KernelConnector } from './kernelConnector';
import { IVSCodeNotebookController } from './types';
Expand All @@ -94,6 +90,7 @@ import {
import { KernelMessage } from '@jupyterlab/services';
import { initializeInteractiveOrNotebookTelemetryBasedOnUserAction } from '../../kernels/telemetry/helper';
import { NotebookCellLanguageService } from '../languages/cellLanguageService';
import { sendNotebookOrKernelLanguageTelemetry } from '../telemetry/notebookOrKernelLanguageTelemetry';

export class VSCodeNotebookController implements Disposable, IVSCodeNotebookController {
private readonly _onNotebookControllerSelected: EventEmitter<{
Expand Down
14 changes: 14 additions & 0 deletions src/notebooks/telemetry/notebookOrKernelLanguageTelemetry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';

import { sendTelemetryEvent, Telemetry } from '../../telemetry';
import { getTelemetrySafeLanguage } from '../../telemetry/helpers';

export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
language = getTelemetrySafeLanguage(language);
sendTelemetryEvent(telemetryEvent, undefined, { language });
}
21 changes: 0 additions & 21 deletions src/platform/activation/serviceRegistry.node.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/platform/activation/serviceRegistry.web.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/platform/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import type * as nbformat from '@jupyterlab/nbformat';
import { ConfigurationTarget, Disposable, Event, Extension, ExtensionContext, OutputChannel, Uri, Range } from 'vscode';
import { IExtensionSingleActivationService } from '../activation/types';
import { PythonEnvironment } from '../pythonEnvironments/info';
import { CommandsWithoutArgs } from './application/commands';
import { ICommandManager } from './application/types';
Expand Down Expand Up @@ -249,9 +248,6 @@ export interface IJupyterExtensionBanner {
showBanner(type: BannerType): Promise<void>;
}

export const ISurveyBanner = Symbol('ISurveyBanner');
export interface ISurveyBanner extends IExtensionSingleActivationService, IJupyterExtensionBanner {}

export type DeprecatedSettingAndValue = {
setting: string;
values?: {}[];
Expand Down
14 changes: 1 addition & 13 deletions src/platform/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
import type * as nbformat from '@jupyterlab/nbformat';
import * as uriPath from '../../platform/vscode-path/resources';
import { NotebookData, NotebookDocument, TextDocument, Uri, workspace } from 'vscode';
import { sendTelemetryEvent } from '../../telemetry';
import { getTelemetrySafeLanguage } from '../../telemetry/helpers';

import {
InteractiveWindowView,
jupyterLanguageToMonacoLanguageMapping,
JupyterNotebookView,
PYTHON_LANGUAGE,
Telemetry
PYTHON_LANGUAGE
} from './constants';
import { traceError, traceInfo } from '../logging';

Expand Down Expand Up @@ -154,14 +150,6 @@ export function generateNewNotebookUri(
}
}

export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
language = getTelemetrySafeLanguage(language);
sendTelemetryEvent(telemetryEvent, undefined, { language });
}

/**
* Whether this is a Notebook we created/manage/use.
* Remember, there could be other notebooks such as GitHub Issues nb by VS Code.
Expand Down
2 changes: 0 additions & 2 deletions src/platform/serviceRegistry.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { IServiceManager } from '../platform/ioc/types';
import { registerTypes as registerApiTypes } from './api/serviceRegistry.node';
import { registerTypes as registerCommonTypes } from './common/serviceRegistry.node';
import { registerTypes as registerTerminalTypes } from './terminals/serviceRegistry.node';
import { registerTypes as registerActivationTypes } from './activation/serviceRegistry.node';
import { registerTypes as registerDevToolTypes } from './devTools/serviceRegistry';
import { DataScienceStartupTime } from './common/constants';
import { IExtensionSingleActivationService, IExtensionSyncActivationService } from './activation/types';
Expand Down Expand Up @@ -35,7 +34,6 @@ export function registerTypes(context: IExtensionContext, serviceManager: IServi
serviceManager.addSingleton<IApplicationShell>(IApplicationShell, ApplicationShell);
serviceManager.addSingleton<IConfigurationService>(IConfigurationService, ConfigurationService);

registerActivationTypes(serviceManager);
registerApiTypes(serviceManager);
registerCommonTypes(serviceManager);
registerTerminalTypes(serviceManager);
Expand Down
2 changes: 0 additions & 2 deletions src/platform/serviceRegistry.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
import { ConfigurationService } from './common/configuration/service.web';
import { registerTypes as registerApiTypes } from './api/serviceRegistry.web';
import { registerTypes as registerCommonTypes } from './common/serviceRegistry.web';
import { registerTypes as registerActivationTypes } from './activation/serviceRegistry.web';
import { registerTypes as registerDevToolTypes } from './devTools/serviceRegistry';
import { IConfigurationService, IDataScienceCommandListener, IExtensionContext } from './common/types';
import { IServiceManager } from './ioc/types';
Expand Down Expand Up @@ -42,7 +41,6 @@ export function registerTypes(context: IExtensionContext, serviceManager: IServi

registerCommonTypes(serviceManager);
registerApiTypes(serviceManager);
registerActivationTypes(serviceManager);
registerDevToolTypes(context, serviceManager, isDevMode);

serviceManager.addSingleton<IExtensionSyncActivationService>(
Expand Down
17 changes: 0 additions & 17 deletions src/platform/terminals/commandPrompt.node.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IExtensionActivationManager,
IExtensionSingleActivationService,
IExtensionSyncActivationService
} from './types';
} from '../../platform/activation/types';

@injectable()
export class ExtensionActivationManager implements IExtensionActivationManager {
Expand Down
18 changes: 17 additions & 1 deletion src/webviews/extension-side/serviceRegistry.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// Licensed under the MIT License.
'use strict';

import { IExtensionSingleActivationService, IExtensionSyncActivationService } from '../../platform/activation/types';
import {
IExtensionActivationManager,
IExtensionSingleActivationService,
IExtensionSyncActivationService
} from '../../platform/activation/types';
import { IWebviewViewProvider, IWebviewPanelProvider } from '../../platform/common/application/types';
import { IServiceManager } from '../../platform/ioc/types';
import { INotebookWatcher, IVariableViewProvider } from './variablesView/types';
Expand Down Expand Up @@ -44,10 +48,17 @@ import { GlobalActivation } from './globalActivation';
import { JupyterKernelServiceFactory } from './api/kernelApi';
import { IExportedKernelServiceFactory } from './api/api';
import { ApiAccessService } from './api/apiAccessService';
import { WorkspaceActivation } from './workspaceActivation.node';
import { ExtensionActivationManager } from './activationManager';
import { DataScienceSurveyBanner, ISurveyBanner } from './survey/dataScienceSurveyBanner.node';

export function registerTypes(serviceManager: IServiceManager, _isDevMode: boolean) {
serviceManager.addSingleton<IExtensionSingleActivationService>(IExtensionSingleActivationService, GlobalActivation);
serviceManager.addSingleton<IExtensionSingleActivationService>(IExtensionSingleActivationService, ServerPreload);
serviceManager.addSingleton<IExtensionSingleActivationService>(
IExtensionSingleActivationService,
WorkspaceActivation
);
serviceManager.addSingleton<IExtensionSingleActivationService>(
IExtensionSyncActivationService,
RendererCommunication
Expand Down Expand Up @@ -109,6 +120,11 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole

serviceManager.addSingletonInstance<IExtensionSideRenderer>(IExtensionSideRenderer, new ExtensionSideRenderer());

serviceManager.addSingleton<ISurveyBanner>(ISurveyBanner, DataScienceSurveyBanner);
serviceManager.addBinding(ISurveyBanner, IExtensionSingleActivationService);
// Activation Manager
serviceManager.add<IExtensionActivationManager>(IExtensionActivationManager, ExtensionActivationManager);

// API
serviceManager.addSingleton<IExportedKernelServiceFactory>(
IExportedKernelServiceFactory,
Expand Down
6 changes: 5 additions & 1 deletion src/webviews/extension-side/serviceRegistry.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IWebviewViewProvider, IWebviewPanelProvider } from '../../platform/comm
import { IServiceManager } from '../../platform/ioc/types';
import { WebviewViewProvider } from './webviewViews/webviewViewProvider';
import { WebviewPanelProvider } from './webviewPanels/webviewPanelProvider';
import { IExtensionSingleActivationService } from '../../platform/activation/types';
import { IExtensionActivationManager, IExtensionSingleActivationService } from '../../platform/activation/types';
import { VariableViewActivationService } from './variablesView/variableViewActivationService';
import { INotebookWatcher, IVariableViewProvider } from './variablesView/types';
import { VariableViewProvider } from './variablesView/variableViewProvider';
Expand All @@ -31,6 +31,7 @@ import { JupyterExporter } from './import-export/jupyterExporter';
import { JupyterKernelServiceFactory } from './api/kernelApi';
import { IExportedKernelServiceFactory } from './api/api';
import { ApiAccessService } from './api/apiAccessService';
import { ExtensionActivationManager } from './activationManager';

export function registerTypes(serviceManager: IServiceManager, _isDevMode: boolean) {
serviceManager.addSingleton<IExtensionSingleActivationService>(IExtensionSingleActivationService, GlobalActivation);
Expand Down Expand Up @@ -69,6 +70,9 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
);

serviceManager.addSingletonInstance<IExtensionSideRenderer>(IExtensionSideRenderer, new ExtensionSideRenderer());

// Activation Manager
serviceManager.add<IExtensionActivationManager>(IExtensionActivationManager, ExtensionActivationManager);
serviceManager.add<INotebookExporter>(INotebookExporter, JupyterExporter);

// API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

import { inject, injectable } from 'inversify';
import { NotebookCellExecutionState, NotebookCellExecutionStateChangeEvent, UIKind } from 'vscode';
import { IExtensionSingleActivationService } from '../activation/types';
import { IApplicationEnvironment, IApplicationShell, IVSCodeNotebook } from './application/types';
import './extensions';
import { traceError } from '../logging';
import { IExtensionSingleActivationService } from '../../../platform/activation/types';
import {
IApplicationEnvironment,
IApplicationShell,
IVSCodeNotebook
} from '../../../platform/common/application/types';
import '../../../platform/common/extensions';
import { traceError } from '../../../platform/logging';
import {
BannerType,
IBrowserService,
Expand All @@ -17,11 +21,14 @@ import {
IPersistentState,
IPersistentStateFactory,
IsCodeSpace
} from './types';
import * as localize from './utils/localize';
import { MillisecondsInADay } from '../constants.node';
import { isJupyterNotebook } from './utils';
import { noop } from './utils/misc';
} from '../../../platform/common/types';
import * as localize from '../../../platform/common/utils/localize';
import { MillisecondsInADay } from '../../../platform/constants.node';
import { isJupyterNotebook } from '../../../platform/common/utils';
import { noop } from '../../../platform/common/utils/misc';

export const ISurveyBanner = Symbol('ISurveyBanner');
export interface ISurveyBanner extends IExtensionSingleActivationService, IJupyterExtensionBanner {}

export enum InsidersNotebookSurveyStateKeys {
ShowBanner = 'ShowInsidersNotebookSurveyBanner',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { inject, injectable } from 'inversify';
import { TextDocument } from 'vscode';
import { sendActivationTelemetry } from '../../telemetry/envFileTelemetry.node';
import { IPythonExtensionChecker } from '../api/types';
import { IWorkspaceService, IActiveResourceService, IDocumentManager } from '../common/application/types';
import { PYTHON_LANGUAGE } from '../common/constants';
import { IFileSystemNode } from '../common/platform/types.node';
import { IDisposable, Resource } from '../common/types';
import { Deferred } from '../common/utils/async';
import { IInterpreterService } from '../interpreter/contracts';
import { traceDecoratorError } from '../logging';
import { IExtensionSingleActivationService } from './types';
import { IPythonExtensionChecker } from '../../platform/api/types';
import { IWorkspaceService, IActiveResourceService, IDocumentManager } from '../../platform/common/application/types';
import { PYTHON_LANGUAGE } from '../../platform/common/constants';
import { IFileSystemNode } from '../../platform/common/platform/types.node';
import { IDisposable, Resource } from '../../platform/common/types';
import { Deferred } from '../../platform/common/utils/async';
import { IInterpreterService } from '../../platform/interpreter/contracts';
import { traceDecoratorError } from '../../platform/logging';
import { IExtensionSingleActivationService } from '../../platform/activation/types';

@injectable()
export class WorkspaceActivation implements IExtensionSingleActivationService {
Expand Down

0 comments on commit 95736ee

Please sign in to comment.