Skip to content

Commit

Permalink
Merge pull request #115 from badsyntax/perf
Browse files Browse the repository at this point in the history
Fix ER diagram, refresh improvements, add refresh icons to treeview
  • Loading branch information
badsyntax authored Sep 22, 2024
2 parents 9121b92 + d5d8cae commit ccd46e6
Show file tree
Hide file tree
Showing 33 changed files with 1,292 additions and 865 deletions.
52 changes: 24 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,6 @@
"dark": "icons/files_dark.svg"
}
},
{
"command": "entityframework.setStartupProject",
"title": "Set as Startup Project",
"icon": {
"light": "icons/files_light.svg",
"dark": "icons/files_dark.svg"
}
},
{
"command": "entityframework.setProject",
"title": "Set as Project",
"icon": {
"light": "icons/files_light.svg",
"dark": "icons/files_dark.svg"
}
},
{
"command": "entityframework.generateERD",
"title": "Generate ER Diagram",
Expand All @@ -112,6 +96,14 @@
"dark": "icons/refresh_dark.svg"
}
},
{
"command": "entityframework.refreshTreeNoCache",
"title": "Refresh",
"icon": {
"light": "icons/refresh_light.svg",
"dark": "icons/refresh_dark.svg"
}
},
{
"command": "entityframework.refreshDbContextTree",
"title": "Refresh",
Expand Down Expand Up @@ -175,6 +167,10 @@
"command": "entityframework.refreshTree",
"when": "false"
},
{
"command": "entityframework.refreshTreeNoCache",
"when": "false"
},
{
"command": "entityframework.refreshProjectTree",
"when": "false"
Expand Down Expand Up @@ -227,7 +223,7 @@
"group": "navigation"
},
{
"command": "entityframework.refreshTree",
"command": "entityframework.refreshTreeNoCache",
"when": "view == entityframeworkTree",
"group": "navigation"
}
Expand Down Expand Up @@ -268,10 +264,15 @@
"when": "viewItem =~ /^migration-.*\\|?can-undo\\|?.*$/",
"group": "context@1"
},
{
"command": "entityframework.refreshDbContextTree",
"when": "viewItem == dbContext",
"group": "inline@1"
},
{
"command": "entityframework.addMigration",
"when": "viewItem == dbContext",
"group": "inline@4"
"group": "inline@2"
},
{
"command": "entityframework.addMigration",
Expand All @@ -297,6 +298,11 @@
{
"command": "entityframework.scaffold",
"when": "viewItem == project",
"group": "inline@2"
},
{
"command": "entityframework.refreshProjectTree",
"when": "viewItem == project",
"group": "inline@1"
},
{
Expand All @@ -308,16 +314,6 @@
"command": "entityframework.refreshProjectTree",
"when": "viewItem == project",
"group": "context@2"
},
{
"command": "entityframework.setProject",
"when": "viewItem == project",
"group": "context@3"
},
{
"command": "entityframework.setStartupProject",
"when": "viewItem == project",
"group": "context@4"
}
]
},
Expand Down
Binary file modified sample_dotnet/ExampleAPI/blogging.db
Binary file not shown.
Binary file added sample_dotnet/src/Infrastructure/blogging.db
Binary file not shown.
7 changes: 1 addition & 6 deletions src/actions/AddMigrationAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as vscode from 'vscode';
import { EFOutputParser } from '../cli/EFOutputParser';
import { CommandProvider } from '../commands/CommandProvider';
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
import { getCommandsConfig } from '../config/config';
import { TREE_VIEW_ID } from '../constants/constants';

Expand Down Expand Up @@ -74,10 +72,7 @@ export class AddMigrationAction extends TerminalAction {
'vscode.open',
vscode.Uri.file(parsedData.migrationFile),
);
await vscode.commands.executeCommand(
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
false,
);

return output;
},
);
Expand Down
13 changes: 2 additions & 11 deletions src/actions/ConfigureAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@ import * as vscode from 'vscode';
import { getProjectsConfig } from '../config/config';
import { EXTENSION_NAMESPACE } from '../constants/constants';
import { ProjectFilesProvider } from '../solution/ProjectFilesProvider';

import { InputWizard } from '../util/InputWizard';

import type { IAction } from './IAction';

export type ScaffoldResult = {
contextFile: string;
entityTypeFiles: string[];
};

export class ConfigureAction implements IAction {
constructor() {}

public async run() {
const { projectFiles } = await ProjectFilesProvider.getProjectFiles();

Expand All @@ -32,7 +23,7 @@ export class ConfigureAction implements IAction {
items: projects,
value: configProject,
options: {
title: 'Select Project (1/2)',
title: 'Select Project',
ignoreFocusOut: true,
},
required: true,
Expand All @@ -42,7 +33,7 @@ export class ConfigureAction implements IAction {
items: projects,
value: configStartupProject,
options: {
title: 'Select Startup Project (2/2)',
title: 'Select Startup Project',
ignoreFocusOut: true,
},
required: true,
Expand Down
1 change: 0 additions & 1 deletion src/actions/DBContextInfoCommandAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as vscode from 'vscode';
import { EFOutputParser } from '../cli/EFOutputParser';
import { getCommandsConfig } from '../config/config';
import { TREE_VIEW_ID } from '../constants/constants';

import type { TerminalProvider } from '../terminal/TerminalProvider';
import { TextDocumentProvider } from '../util/TextDocumentProvider';
import { TerminalAction } from './TerminalAction';
Expand Down
1 change: 1 addition & 0 deletions src/actions/GenerateERDAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class GenerateERDAction extends TerminalAction {
options: {
title: 'Connection String',
value: '',
prompt: 'EG: Data Source=blogging.db',
},
required: true,
},
Expand Down
2 changes: 1 addition & 1 deletion src/actions/IAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export interface IAction {
run(
params?: { [key: string]: string },
execArgs?: Partial<ExecOpts>,
): Promise<string | void>;
): Promise<string | number | void>;
}
7 changes: 5 additions & 2 deletions src/actions/RefreshTreeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import type { TreeDataProvider } from '../treeView/TreeDataProvider';
import type { IAction } from './IAction';

export class RefreshTreeAction implements IAction {
constructor(private readonly treeDataProvider: TreeDataProvider) {}
constructor(
private readonly treeDataProvider: TreeDataProvider,
private readonly clearCache: boolean,
) {}

public async run() {
this.treeDataProvider.refresh();
this.treeDataProvider.refresh(this.clearCache);
}
}
29 changes: 4 additions & 25 deletions src/actions/RemoveMigrationAction.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import * as vscode from 'vscode';
import { CommandProvider } from '../commands/CommandProvider';
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
import { getCommandsConfig } from '../config/config';
import { TREE_VIEW_ID } from '../constants/constants';
import type { TerminalProvider } from '../terminal/TerminalProvider';
import {
dbContextsCache,
DbContextTreeItem,
} from '../treeView/DbContextTreeItem';
import { TerminalAction } from './TerminalAction';

export class RemoveMigrationAction extends TerminalAction {
constructor(
terminalProvider: TerminalProvider,
private readonly workspaceRoot: string,
private readonly dbContext: string,
private readonly project: string,
private readonly refresh?: boolean,
readonly workspaceRoot: string,
readonly dbContext: string,
readonly project: string,
) {
super(
terminalProvider,
Expand All @@ -41,21 +34,7 @@ export class RemoveMigrationAction extends TerminalAction {
this.cancel();
});
await this.start();
const output = await this.getOutput();
const cacheId = DbContextTreeItem.getCacheId(
this.workspaceRoot,
this.project,
this.dbContext,
);
dbContextsCache.clear(cacheId);
const refresh = this.refresh || this.refresh === undefined;
if (refresh) {
await vscode.commands.executeCommand(
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
false,
);
}
return output;
return await this.getOutput();
},
);
}
Expand Down
11 changes: 1 addition & 10 deletions src/actions/RemoveMigrationsAction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import * as vscode from 'vscode';
import { CommandProvider } from '../commands/CommandProvider';
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
import type { TerminalProvider } from '../terminal/TerminalProvider';
import {
dbContextsCache,
Expand Down Expand Up @@ -38,14 +35,8 @@ export class RemoveMigrationsAction implements IAction {
this.workspaceRoot,
this.dbContext,
this.project,
false,
).run();
}
if (migrationsToRemove.length > 0) {
await vscode.commands.executeCommand(
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
false,
);
}
return migrationsToRemove.length;
}
}
9 changes: 2 additions & 7 deletions src/actions/ResetMigrationsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,20 @@ export class ResetMigrationsAction implements IAction {
return;
}
const migrationName = await vscode.window.showInputBox({
title: 'Enter Migration Name',
title: 'Enter New Migration Name',
prompt: 'EG: MigrationName',
ignoreFocusOut: true,
});
if (!migrationName) {
return '';
}
await new UndoMigrationCommand(
this.terminalProvider,
this.item,
false,
).run();
await new UndoMigrationCommand(this.terminalProvider, this.item).run();
for (let i = 0; i < migrationsToReset.length; i++) {
await new RemoveMigrationAction(
this.terminalProvider,
this.workspaceRoot,
this.dbContext,
this.project,
false,
).run();
}
await new AddMigrationAction(
Expand Down
22 changes: 0 additions & 22 deletions src/actions/RunMigrationAction.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import * as vscode from 'vscode';
import { CommandProvider } from '../commands/CommandProvider';
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
import { getCommandsConfig } from '../config/config';
import { TREE_VIEW_ID } from '../constants/constants';
import type { TerminalProvider } from '../terminal/TerminalProvider';
import {
dbContextsCache,
DbContextTreeItem,
} from '../treeView/DbContextTreeItem';
import { TerminalAction } from './TerminalAction';

export class RunMigrationAction extends TerminalAction {
Expand All @@ -17,7 +11,6 @@ export class RunMigrationAction extends TerminalAction {
private readonly dbContext: string,
private readonly project: string,
migrationId: string,
private readonly refresh?: boolean,
) {
super(
terminalProvider,
Expand All @@ -44,21 +37,6 @@ export class RunMigrationAction extends TerminalAction {
});
await this.start();
const output = await this.getOutput();

const cacheId = DbContextTreeItem.getCacheId(
this.workspaceRoot,
this.project,
this.dbContext,
);
dbContextsCache.clear(cacheId);

if (this.refresh) {
await vscode.commands.executeCommand(
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
false,
);
}

return output;
},
);
Expand Down
13 changes: 0 additions & 13 deletions src/actions/ScaffoldAction.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import type { Project } from 'nuget-deps-tree';
import * as vscode from 'vscode';
import { EFOutputParser } from '../cli/EFOutputParser';
import { CommandProvider } from '../commands/CommandProvider';
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
import { getCommandsConfig } from '../config/config';
import { DEFAULT_EFCORE_PROVIDERS, TREE_VIEW_ID } from '../constants/constants';
import { ProjectFilesProvider } from '../solution/ProjectFilesProvider';

import type { TerminalProvider } from '../terminal/TerminalProvider';
import { projectsCache, ProjectTreeItem } from '../treeView/ProjectTreeItem';
import type { ProjectFile } from '../types/ProjectFile';
import { InputWizard } from '../util/InputWizard';

Expand Down Expand Up @@ -142,16 +139,6 @@ export class ScaffoldAction extends TerminalAction {
const uri = vscode.Uri.file(output.contextFile);
const doc = await vscode.workspace.openTextDocument(uri);
await vscode.window.showTextDocument(doc);

const cacheId = ProjectTreeItem.getCacheId(
this.projectFile.workspaceRoot,
this.projectFile.name,
);
projectsCache.clear(cacheId);
await vscode.commands.executeCommand(
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
false,
);
return '';
},
);
Expand Down
Loading

0 comments on commit ccd46e6

Please sign in to comment.