Skip to content

Commit 8832655

Browse files
Add modifiedMethodSignatures to ModeledMethodsChangedEvent
1 parent 63de6ce commit 8832655

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

extensions/ql-vscode/src/model-editor/method-modeling/method-modeling-view-provider.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ export class MethodModelingViewProvider extends AbstractWebviewViewProvider<
169169
modeledMethods,
170170
});
171171
}
172+
173+
if (e.modifiedMethodSignatures !== undefined) {
174+
await this.postMessage({
175+
t: "setMethodModified",
176+
isModified: e.modifiedMethodSignatures.has(this.method.signature),
177+
});
178+
}
172179
}
173180
}),
174181
);

extensions/ql-vscode/src/model-editor/model-editor-view.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,13 @@ export class ModelEditorView extends AbstractWebview<
824824
t: "setModeledMethods",
825825
methods: event.modeledMethods,
826826
});
827+
828+
if (event.modifiedMethodSignatures !== undefined) {
829+
await this.postMessage({
830+
t: "setModifiedMethods",
831+
methodSignatures: [...event.modifiedMethodSignatures],
832+
});
833+
}
827834
}
828835
}),
829836
);

extensions/ql-vscode/src/model-editor/modeling-events.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface ModeChangedEvent {
2525

2626
interface ModeledMethodsChangedEvent {
2727
readonly modeledMethods: Readonly<Record<string, ModeledMethod[]>>;
28+
readonly modifiedMethodSignatures: ReadonlySet<string>;
2829
readonly dbUri: string;
2930
readonly isActiveDb: boolean;
3031
}
@@ -211,11 +212,13 @@ export class ModelingEvents extends DisposableObject {
211212

212213
public fireModeledMethodsChangedEvent(
213214
modeledMethods: Record<string, ModeledMethod[]>,
215+
modifiedMethodSignatures: ReadonlySet<string>,
214216
dbUri: string,
215217
isActiveDb: boolean,
216218
) {
217219
this.onModeledMethodsChangedEventEmitter.fire({
218220
modeledMethods,
221+
modifiedMethodSignatures,
219222
dbUri,
220223
isActiveDb,
221224
});

extensions/ql-vscode/src/model-editor/modeling-store.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class ModelingStore extends DisposableObject {
216216
methods: Record<string, ModeledMethod[]>,
217217
setModified: boolean,
218218
) {
219-
this.changeModeledMethods(dbItem, setModified, (state) => {
219+
this.changeModeledMethods(dbItem, (state) => {
220220
const newModeledMethods = {
221221
...methods,
222222
// Keep all methods that are already modeled in some form in the state
@@ -242,7 +242,7 @@ export class ModelingStore extends DisposableObject {
242242
dbItem: DatabaseItem,
243243
methods: Record<string, ModeledMethod[]>,
244244
) {
245-
this.changeModeledMethods(dbItem, false, (state) => {
245+
this.changeModeledMethods(dbItem, (state) => {
246246
state.modeledMethods = { ...methods };
247247
});
248248
}
@@ -253,7 +253,7 @@ export class ModelingStore extends DisposableObject {
253253
modeledMethods: ModeledMethod[],
254254
setModified: boolean,
255255
) {
256-
this.changeModeledMethods(dbItem, setModified, (state) => {
256+
this.changeModeledMethods(dbItem, (state) => {
257257
const newModeledMethods = { ...state.modeledMethods };
258258
newModeledMethods[signature] = modeledMethods;
259259
state.modeledMethods = newModeledMethods;
@@ -417,7 +417,6 @@ export class ModelingStore extends DisposableObject {
417417

418418
private changeModeledMethods(
419419
dbItem: DatabaseItem,
420-
modifiedMethodsChanged: boolean,
421420
updateState: (state: InternalDbModelingState) => void,
422421
) {
423422
const state = this.getState(dbItem);
@@ -426,17 +425,10 @@ export class ModelingStore extends DisposableObject {
426425

427426
this.modelingEvents.fireModeledMethodsChangedEvent(
428427
state.modeledMethods,
428+
state.modifiedMethodSignatures,
429429
dbItem.databaseUri.toString(),
430430
dbItem.databaseUri.toString() === this.activeDb,
431431
);
432-
433-
if (modifiedMethodsChanged) {
434-
this.modelingEvents.fireModifiedMethodsChangedEvent(
435-
state.modifiedMethodSignatures,
436-
dbItem.databaseUri.toString(),
437-
dbItem.databaseUri.toString() === this.activeDb,
438-
);
439-
}
440432
}
441433

442434
private changeInProgressMethods(

0 commit comments

Comments
 (0)