Skip to content

Commit ccd46e6

Browse files
authored
Merge pull request #115 from badsyntax/perf
Fix ER diagram, refresh improvements, add refresh icons to treeview
2 parents 9121b92 + d5d8cae commit ccd46e6

33 files changed

+1292
-865
lines changed

package.json

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,6 @@
7272
"dark": "icons/files_dark.svg"
7373
}
7474
},
75-
{
76-
"command": "entityframework.setStartupProject",
77-
"title": "Set as Startup Project",
78-
"icon": {
79-
"light": "icons/files_light.svg",
80-
"dark": "icons/files_dark.svg"
81-
}
82-
},
83-
{
84-
"command": "entityframework.setProject",
85-
"title": "Set as Project",
86-
"icon": {
87-
"light": "icons/files_light.svg",
88-
"dark": "icons/files_dark.svg"
89-
}
90-
},
9175
{
9276
"command": "entityframework.generateERD",
9377
"title": "Generate ER Diagram",
@@ -112,6 +96,14 @@
11296
"dark": "icons/refresh_dark.svg"
11397
}
11498
},
99+
{
100+
"command": "entityframework.refreshTreeNoCache",
101+
"title": "Refresh",
102+
"icon": {
103+
"light": "icons/refresh_light.svg",
104+
"dark": "icons/refresh_dark.svg"
105+
}
106+
},
115107
{
116108
"command": "entityframework.refreshDbContextTree",
117109
"title": "Refresh",
@@ -175,6 +167,10 @@
175167
"command": "entityframework.refreshTree",
176168
"when": "false"
177169
},
170+
{
171+
"command": "entityframework.refreshTreeNoCache",
172+
"when": "false"
173+
},
178174
{
179175
"command": "entityframework.refreshProjectTree",
180176
"when": "false"
@@ -227,7 +223,7 @@
227223
"group": "navigation"
228224
},
229225
{
230-
"command": "entityframework.refreshTree",
226+
"command": "entityframework.refreshTreeNoCache",
231227
"when": "view == entityframeworkTree",
232228
"group": "navigation"
233229
}
@@ -268,10 +264,15 @@
268264
"when": "viewItem =~ /^migration-.*\\|?can-undo\\|?.*$/",
269265
"group": "context@1"
270266
},
267+
{
268+
"command": "entityframework.refreshDbContextTree",
269+
"when": "viewItem == dbContext",
270+
"group": "inline@1"
271+
},
271272
{
272273
"command": "entityframework.addMigration",
273274
"when": "viewItem == dbContext",
274-
"group": "inline@4"
275+
"group": "inline@2"
275276
},
276277
{
277278
"command": "entityframework.addMigration",
@@ -297,6 +298,11 @@
297298
{
298299
"command": "entityframework.scaffold",
299300
"when": "viewItem == project",
301+
"group": "inline@2"
302+
},
303+
{
304+
"command": "entityframework.refreshProjectTree",
305+
"when": "viewItem == project",
300306
"group": "inline@1"
301307
},
302308
{
@@ -308,16 +314,6 @@
308314
"command": "entityframework.refreshProjectTree",
309315
"when": "viewItem == project",
310316
"group": "context@2"
311-
},
312-
{
313-
"command": "entityframework.setProject",
314-
"when": "viewItem == project",
315-
"group": "context@3"
316-
},
317-
{
318-
"command": "entityframework.setStartupProject",
319-
"when": "viewItem == project",
320-
"group": "context@4"
321317
}
322318
]
323319
},

sample_dotnet/ExampleAPI/blogging.db

0 Bytes
Binary file not shown.
48 KB
Binary file not shown.

src/actions/AddMigrationAction.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import * as vscode from 'vscode';
22
import { EFOutputParser } from '../cli/EFOutputParser';
3-
import { CommandProvider } from '../commands/CommandProvider';
4-
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
53
import { getCommandsConfig } from '../config/config';
64
import { TREE_VIEW_ID } from '../constants/constants';
75

@@ -74,10 +72,7 @@ export class AddMigrationAction extends TerminalAction {
7472
'vscode.open',
7573
vscode.Uri.file(parsedData.migrationFile),
7674
);
77-
await vscode.commands.executeCommand(
78-
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
79-
false,
80-
);
75+
8176
return output;
8277
},
8378
);

src/actions/ConfigureAction.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@ import * as vscode from 'vscode';
22
import { getProjectsConfig } from '../config/config';
33
import { EXTENSION_NAMESPACE } from '../constants/constants';
44
import { ProjectFilesProvider } from '../solution/ProjectFilesProvider';
5-
65
import { InputWizard } from '../util/InputWizard';
7-
86
import type { IAction } from './IAction';
97

10-
export type ScaffoldResult = {
11-
contextFile: string;
12-
entityTypeFiles: string[];
13-
};
14-
158
export class ConfigureAction implements IAction {
16-
constructor() {}
17-
189
public async run() {
1910
const { projectFiles } = await ProjectFilesProvider.getProjectFiles();
2011

@@ -32,7 +23,7 @@ export class ConfigureAction implements IAction {
3223
items: projects,
3324
value: configProject,
3425
options: {
35-
title: 'Select Project (1/2)',
26+
title: 'Select Project',
3627
ignoreFocusOut: true,
3728
},
3829
required: true,
@@ -42,7 +33,7 @@ export class ConfigureAction implements IAction {
4233
items: projects,
4334
value: configStartupProject,
4435
options: {
45-
title: 'Select Startup Project (2/2)',
36+
title: 'Select Startup Project',
4637
ignoreFocusOut: true,
4738
},
4839
required: true,

src/actions/DBContextInfoCommandAction.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as vscode from 'vscode';
33
import { EFOutputParser } from '../cli/EFOutputParser';
44
import { getCommandsConfig } from '../config/config';
55
import { TREE_VIEW_ID } from '../constants/constants';
6-
76
import type { TerminalProvider } from '../terminal/TerminalProvider';
87
import { TextDocumentProvider } from '../util/TextDocumentProvider';
98
import { TerminalAction } from './TerminalAction';

src/actions/GenerateERDAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export class GenerateERDAction extends TerminalAction {
107107
options: {
108108
title: 'Connection String',
109109
value: '',
110+
prompt: 'EG: Data Source=blogging.db',
110111
},
111112
required: true,
112113
},

src/actions/IAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ export interface IAction {
44
run(
55
params?: { [key: string]: string },
66
execArgs?: Partial<ExecOpts>,
7-
): Promise<string | void>;
7+
): Promise<string | number | void>;
88
}

src/actions/RefreshTreeAction.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import type { TreeDataProvider } from '../treeView/TreeDataProvider';
22
import type { IAction } from './IAction';
33

44
export class RefreshTreeAction implements IAction {
5-
constructor(private readonly treeDataProvider: TreeDataProvider) {}
5+
constructor(
6+
private readonly treeDataProvider: TreeDataProvider,
7+
private readonly clearCache: boolean,
8+
) {}
69

710
public async run() {
8-
this.treeDataProvider.refresh();
11+
this.treeDataProvider.refresh(this.clearCache);
912
}
1013
}

src/actions/RemoveMigrationAction.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
import * as vscode from 'vscode';
2-
import { CommandProvider } from '../commands/CommandProvider';
3-
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
42
import { getCommandsConfig } from '../config/config';
53
import { TREE_VIEW_ID } from '../constants/constants';
64
import type { TerminalProvider } from '../terminal/TerminalProvider';
7-
import {
8-
dbContextsCache,
9-
DbContextTreeItem,
10-
} from '../treeView/DbContextTreeItem';
115
import { TerminalAction } from './TerminalAction';
126

137
export class RemoveMigrationAction extends TerminalAction {
148
constructor(
159
terminalProvider: TerminalProvider,
16-
private readonly workspaceRoot: string,
17-
private readonly dbContext: string,
18-
private readonly project: string,
19-
private readonly refresh?: boolean,
10+
readonly workspaceRoot: string,
11+
readonly dbContext: string,
12+
readonly project: string,
2013
) {
2114
super(
2215
terminalProvider,
@@ -41,21 +34,7 @@ export class RemoveMigrationAction extends TerminalAction {
4134
this.cancel();
4235
});
4336
await this.start();
44-
const output = await this.getOutput();
45-
const cacheId = DbContextTreeItem.getCacheId(
46-
this.workspaceRoot,
47-
this.project,
48-
this.dbContext,
49-
);
50-
dbContextsCache.clear(cacheId);
51-
const refresh = this.refresh || this.refresh === undefined;
52-
if (refresh) {
53-
await vscode.commands.executeCommand(
54-
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
55-
false,
56-
);
57-
}
58-
return output;
37+
return await this.getOutput();
5938
},
6039
);
6140
}

src/actions/RemoveMigrationsAction.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import * as vscode from 'vscode';
2-
import { CommandProvider } from '../commands/CommandProvider';
3-
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
41
import type { TerminalProvider } from '../terminal/TerminalProvider';
52
import {
63
dbContextsCache,
@@ -38,14 +35,8 @@ export class RemoveMigrationsAction implements IAction {
3835
this.workspaceRoot,
3936
this.dbContext,
4037
this.project,
41-
false,
4238
).run();
4339
}
44-
if (migrationsToRemove.length > 0) {
45-
await vscode.commands.executeCommand(
46-
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
47-
false,
48-
);
49-
}
40+
return migrationsToRemove.length;
5041
}
5142
}

src/actions/ResetMigrationsAction.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,20 @@ export class ResetMigrationsAction implements IAction {
4444
return;
4545
}
4646
const migrationName = await vscode.window.showInputBox({
47-
title: 'Enter Migration Name',
47+
title: 'Enter New Migration Name',
4848
prompt: 'EG: MigrationName',
4949
ignoreFocusOut: true,
5050
});
5151
if (!migrationName) {
5252
return '';
5353
}
54-
await new UndoMigrationCommand(
55-
this.terminalProvider,
56-
this.item,
57-
false,
58-
).run();
54+
await new UndoMigrationCommand(this.terminalProvider, this.item).run();
5955
for (let i = 0; i < migrationsToReset.length; i++) {
6056
await new RemoveMigrationAction(
6157
this.terminalProvider,
6258
this.workspaceRoot,
6359
this.dbContext,
6460
this.project,
65-
false,
6661
).run();
6762
}
6863
await new AddMigrationAction(

src/actions/RunMigrationAction.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import * as vscode from 'vscode';
2-
import { CommandProvider } from '../commands/CommandProvider';
3-
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
42
import { getCommandsConfig } from '../config/config';
53
import { TREE_VIEW_ID } from '../constants/constants';
64
import type { TerminalProvider } from '../terminal/TerminalProvider';
7-
import {
8-
dbContextsCache,
9-
DbContextTreeItem,
10-
} from '../treeView/DbContextTreeItem';
115
import { TerminalAction } from './TerminalAction';
126

137
export class RunMigrationAction extends TerminalAction {
@@ -17,7 +11,6 @@ export class RunMigrationAction extends TerminalAction {
1711
private readonly dbContext: string,
1812
private readonly project: string,
1913
migrationId: string,
20-
private readonly refresh?: boolean,
2114
) {
2215
super(
2316
terminalProvider,
@@ -44,21 +37,6 @@ export class RunMigrationAction extends TerminalAction {
4437
});
4538
await this.start();
4639
const output = await this.getOutput();
47-
48-
const cacheId = DbContextTreeItem.getCacheId(
49-
this.workspaceRoot,
50-
this.project,
51-
this.dbContext,
52-
);
53-
dbContextsCache.clear(cacheId);
54-
55-
if (this.refresh) {
56-
await vscode.commands.executeCommand(
57-
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
58-
false,
59-
);
60-
}
61-
6240
return output;
6341
},
6442
);

src/actions/ScaffoldAction.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import type { Project } from 'nuget-deps-tree';
22
import * as vscode from 'vscode';
33
import { EFOutputParser } from '../cli/EFOutputParser';
4-
import { CommandProvider } from '../commands/CommandProvider';
5-
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
64
import { getCommandsConfig } from '../config/config';
75
import { DEFAULT_EFCORE_PROVIDERS, TREE_VIEW_ID } from '../constants/constants';
86
import { ProjectFilesProvider } from '../solution/ProjectFilesProvider';
97

108
import type { TerminalProvider } from '../terminal/TerminalProvider';
11-
import { projectsCache, ProjectTreeItem } from '../treeView/ProjectTreeItem';
129
import type { ProjectFile } from '../types/ProjectFile';
1310
import { InputWizard } from '../util/InputWizard';
1411

@@ -142,16 +139,6 @@ export class ScaffoldAction extends TerminalAction {
142139
const uri = vscode.Uri.file(output.contextFile);
143140
const doc = await vscode.workspace.openTextDocument(uri);
144141
await vscode.window.showTextDocument(doc);
145-
146-
const cacheId = ProjectTreeItem.getCacheId(
147-
this.projectFile.workspaceRoot,
148-
this.projectFile.name,
149-
);
150-
projectsCache.clear(cacheId);
151-
await vscode.commands.executeCommand(
152-
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
153-
false,
154-
);
155142
return '';
156143
},
157144
);

0 commit comments

Comments
 (0)