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

refactor: simplify constructor argument assignment VSCODE-441 #551

Merged
merged 4 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"type": "node",
"request": "attach",
"name": "Attach to Language Server",
"protocol": "inspector",
"port": 6009,
"sourceMaps": true,
"outFiles": [
Expand Down
14 changes: 9 additions & 5 deletions src/connectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,15 @@ export default class ConnectionController {
// Used by other parts of the extension that respond to changes in the connections.
private eventEmitter: EventEmitter = new EventEmitter();

constructor(
statusView: StatusView,
storageController: StorageController,
telemetryService: TelemetryService
) {
constructor({
statusView,
storageController,
telemetryService,
}: {
statusView: StatusView;
storageController: StorageController;
telemetryService: TelemetryService;
}) {
this._statusView = statusView;
this._storageController = storageController;
this._telemetryService = telemetryService;
Anemy marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
20 changes: 13 additions & 7 deletions src/editors/collectionDocumentsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ export default class CollectionViewProvider
_statusView: StatusView;
_editDocumentCodeLensProvider: EditDocumentCodeLensProvider;

constructor(
context: vscode.ExtensionContext,
connectionController: ConnectionController,
operationsStore: CollectionDocumentsOperationsStore,
statusView: StatusView,
editDocumentCodeLensProvider: EditDocumentCodeLensProvider
) {
constructor({
context,
connectionController,
operationsStore,
statusView,
editDocumentCodeLensProvider,
}: {
context: vscode.ExtensionContext;
connectionController: ConnectionController;
operationsStore: CollectionDocumentsOperationsStore;
statusView: StatusView;
editDocumentCodeLensProvider: EditDocumentCodeLensProvider;
}) {
this._context = context;
this._connectionController = connectionController;
this._operationsStore = operationsStore;
Expand Down
62 changes: 37 additions & 25 deletions src/editors/editorsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,40 +104,52 @@ export default class EditorsController {
_editDocumentCodeLensProvider: EditDocumentCodeLensProvider;
_collectionDocumentsCodeLensProvider: CollectionDocumentsCodeLensProvider;

constructor(
context: vscode.ExtensionContext,
connectionController: ConnectionController,
playgroundController: PlaygroundController,
statusView: StatusView,
telemetryService: TelemetryService,
playgroundResultViewProvider: PlaygroundResultProvider,
activeConnectionCodeLensProvider: ActiveConnectionCodeLensProvider,
exportToLanguageCodeLensProvider: ExportToLanguageCodeLensProvider,
playgroundSelectedCodeActionProvider: PlaygroundSelectedCodeActionProvider,
playgroundDiagnosticsCodeActionProvider: PlaygroundDiagnosticsCodeActionProvider,
editDocumentCodeLensProvider: EditDocumentCodeLensProvider
) {
constructor({
context,
connectionController,
playgroundController,
statusView,
telemetryService,
playgroundResultViewProvider,
activeConnectionCodeLensProvider,
exportToLanguageCodeLensProvider,
playgroundSelectedCodeActionProvider,
playgroundDiagnosticsCodeActionProvider,
editDocumentCodeLensProvider,
}: {
context: vscode.ExtensionContext;
connectionController: ConnectionController;
playgroundController: PlaygroundController;
statusView: StatusView;
telemetryService: TelemetryService;
playgroundResultViewProvider: PlaygroundResultProvider;
activeConnectionCodeLensProvider: ActiveConnectionCodeLensProvider;
exportToLanguageCodeLensProvider: ExportToLanguageCodeLensProvider;
playgroundSelectedCodeActionProvider: PlaygroundSelectedCodeActionProvider;
playgroundDiagnosticsCodeActionProvider: PlaygroundDiagnosticsCodeActionProvider;
editDocumentCodeLensProvider: EditDocumentCodeLensProvider;
}) {
this._connectionController = connectionController;
this._playgroundController = playgroundController;
this._context = context;
this._statusView = statusView;
this._telemetryService = telemetryService;
this._memoryFileSystemProvider = new MemoryFileSystemProvider();
this._documentIdStore = new DocumentIdStore();
this._mongoDBDocumentService = new MongoDBDocumentService(
this._context,
this._connectionController,
this._statusView,
this._telemetryService
);
this._mongoDBDocumentService = new MongoDBDocumentService({
context: this._context,
connectionController: this._connectionController,
statusView: this._statusView,
telemetryService: this._telemetryService,
});
this._editDocumentCodeLensProvider = editDocumentCodeLensProvider;
this._collectionViewProvider = new CollectionDocumentsProvider(
this._context,
this._collectionViewProvider = new CollectionDocumentsProvider({
context: this._context,
connectionController,
this._collectionDocumentsOperationsStore,
new StatusView(context),
this._editDocumentCodeLensProvider
);
operationsStore: this._collectionDocumentsOperationsStore,
statusView: new StatusView(context),
editDocumentCodeLensProvider: this._editDocumentCodeLensProvider,
});
this._playgroundResultViewProvider = playgroundResultViewProvider;
this._activeConnectionCodeLensProvider = activeConnectionCodeLensProvider;
this._exportToLanguageCodeLensProvider = exportToLanguageCodeLensProvider;
Expand Down
17 changes: 11 additions & 6 deletions src/editors/mongoDBDocumentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ export default class MongoDBDocumentService {
_statusView: StatusView;
_telemetryService: TelemetryService;

constructor(
context: vscode.ExtensionContext,
connectionController: ConnectionController,
statusView: StatusView,
telemetryService: TelemetryService
) {
constructor({
context,
connectionController,
statusView,
telemetryService,
}: {
context: vscode.ExtensionContext;
connectionController: ConnectionController;
statusView: StatusView;
telemetryService: TelemetryService;
}) {
this._context = context;
this._connectionController = connectionController;
this._statusView = statusView;
Expand Down
40 changes: 21 additions & 19 deletions src/editors/playgroundController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import ConnectionController, {
DataServiceEventTypes,
} from '../connectionController';
import { createLogger } from '../logging';
import {
ExplorerController,
ConnectionTreeItem,
DatabaseTreeItem,
} from '../explorer';
import { ConnectionTreeItem, DatabaseTreeItem } from '../explorer';
import ExportToLanguageCodeLensProvider from './exportToLanguageCodeLensProvider';
import formatError from '../utils/formatError';
import { LanguageServerController } from '../language';
Expand Down Expand Up @@ -118,21 +114,28 @@ export default class PlaygroundController {
private _playgroundResultTextDocument?: vscode.TextDocument;
private _statusView: StatusView;
private _playgroundResultViewProvider: PlaygroundResultProvider;
private _explorerController: ExplorerController;

private _codeToEvaluate = '';

constructor(
connectionController: ConnectionController,
languageServerController: LanguageServerController,
telemetryService: TelemetryService,
statusView: StatusView,
playgroundResultViewProvider: PlaygroundResultProvider,
activeConnectionCodeLensProvider: ActiveConnectionCodeLensProvider,
exportToLanguageCodeLensProvider: ExportToLanguageCodeLensProvider,
playgroundSelectedCodeActionProvide: PlaygroundSelectedCodeActionProvider,
explorerController: ExplorerController
) {
constructor({
connectionController,
languageServerController,
telemetryService,
statusView,
playgroundResultViewProvider,
activeConnectionCodeLensProvider,
exportToLanguageCodeLensProvider,
playgroundSelectedCodeActionProvider,
}: {
connectionController: ConnectionController;
languageServerController: LanguageServerController;
telemetryService: TelemetryService;
statusView: StatusView;
playgroundResultViewProvider: PlaygroundResultProvider;
activeConnectionCodeLensProvider: ActiveConnectionCodeLensProvider;
exportToLanguageCodeLensProvider: ExportToLanguageCodeLensProvider;
playgroundSelectedCodeActionProvider: PlaygroundSelectedCodeActionProvider;
}) {
this._connectionController = connectionController;
this._activeTextEditor = vscode.window.activeTextEditor;
this._languageServerController = languageServerController;
Expand All @@ -144,8 +147,7 @@ export default class PlaygroundController {
this._activeConnectionCodeLensProvider = activeConnectionCodeLensProvider;
this._exportToLanguageCodeLensProvider = exportToLanguageCodeLensProvider;
this._playgroundSelectedCodeActionProvider =
playgroundSelectedCodeActionProvide;
this._explorerController = explorerController;
playgroundSelectedCodeActionProvider;

this._connectionController.addEventListener(
DataServiceEventTypes.ACTIVE_CONNECTION_CHANGED,
Expand Down
Loading