Skip to content

Commit b7ee9f9

Browse files
authored
Merge pull request #3297 from github/koesie10/more-consistency-information
Add more information for consistency check errors
2 parents b3284d6 + 08dfd1a commit b7ee9f9

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

extensions/ql-vscode/src/model-editor/consistency-check.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import type { ModeledMethod } from "./modeled-method";
33
import type { BaseLogger } from "../common/logging";
44

55
interface Notifier {
6-
missingMethod(signature: string): void;
6+
missingMethod(
7+
signature: string,
8+
modeledMethods: readonly ModeledMethod[],
9+
): void;
710
inconsistentSupported(signature: string, expectedSupported: boolean): void;
811
}
912

@@ -21,14 +24,14 @@ export function checkConsistency(
2124
);
2225

2326
for (const signature in modeledMethods) {
27+
const modeledMethodsForSignature = modeledMethods[signature];
28+
2429
const method = methodsBySignature[signature];
2530
if (!method) {
26-
notifier.missingMethod(signature);
31+
notifier.missingMethod(signature, modeledMethodsForSignature);
2732
continue;
2833
}
2934

30-
const modeledMethodsForSignature = modeledMethods[signature];
31-
3235
checkMethodConsistency(method, modeledMethodsForSignature, notifier);
3336
}
3437
}
@@ -51,9 +54,14 @@ function checkMethodConsistency(
5154
export class DefaultNotifier implements Notifier {
5255
constructor(private readonly logger: BaseLogger) {}
5356

54-
missingMethod(signature: string) {
57+
missingMethod(signature: string, modeledMethods: readonly ModeledMethod[]) {
58+
const modelTypes = modeledMethods
59+
.map((m) => m.type)
60+
.filter((t) => t !== "none")
61+
.join(", ");
62+
5563
void this.logger.log(
56-
`Model editor query consistency check: Missing method ${signature} for method that is modeled.`,
64+
`Model editor query consistency check: Missing method ${signature} for method that is modeled as ${modelTypes}`,
5765
);
5866
}
5967

extensions/ql-vscode/test/unit-tests/model-editor/consistency-check.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@ describe("checkConsistency", () => {
1414
});
1515

1616
it("should call missingMethod when method is missing", () => {
17+
const modeledMethods = [createSourceModeledMethod()];
18+
1719
checkConsistency(
1820
[],
1921
{
2022
"Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SeparatedList`1(System.Collections.Generic.IEnumerable<TNode>)":
21-
[createSourceModeledMethod()],
23+
modeledMethods,
2224
},
2325
notifier,
2426
);
2527

2628
expect(notifier.missingMethod).toHaveBeenCalledWith(
2729
"Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SeparatedList`1(System.Collections.Generic.IEnumerable<TNode>)",
30+
modeledMethods,
2831
);
2932
expect(notifier.inconsistentSupported).not.toHaveBeenCalled();
3033
});

0 commit comments

Comments
 (0)