Add more information for consistency check errors
This commit is contained in:
@@ -3,7 +3,10 @@ import type { ModeledMethod } from "./modeled-method";
|
|||||||
import type { BaseLogger } from "../common/logging";
|
import type { BaseLogger } from "../common/logging";
|
||||||
|
|
||||||
interface Notifier {
|
interface Notifier {
|
||||||
missingMethod(signature: string): void;
|
missingMethod(
|
||||||
|
signature: string,
|
||||||
|
modeledMethods: readonly ModeledMethod[],
|
||||||
|
): void;
|
||||||
inconsistentSupported(signature: string, expectedSupported: boolean): void;
|
inconsistentSupported(signature: string, expectedSupported: boolean): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,14 +24,14 @@ export function checkConsistency(
|
|||||||
);
|
);
|
||||||
|
|
||||||
for (const signature in modeledMethods) {
|
for (const signature in modeledMethods) {
|
||||||
|
const modeledMethodsForSignature = modeledMethods[signature];
|
||||||
|
|
||||||
const method = methodsBySignature[signature];
|
const method = methodsBySignature[signature];
|
||||||
if (!method) {
|
if (!method) {
|
||||||
notifier.missingMethod(signature);
|
notifier.missingMethod(signature, modeledMethodsForSignature);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const modeledMethodsForSignature = modeledMethods[signature];
|
|
||||||
|
|
||||||
checkMethodConsistency(method, modeledMethodsForSignature, notifier);
|
checkMethodConsistency(method, modeledMethodsForSignature, notifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,9 +54,14 @@ function checkMethodConsistency(
|
|||||||
export class DefaultNotifier implements Notifier {
|
export class DefaultNotifier implements Notifier {
|
||||||
constructor(private readonly logger: BaseLogger) {}
|
constructor(private readonly logger: BaseLogger) {}
|
||||||
|
|
||||||
missingMethod(signature: string) {
|
missingMethod(signature: string, modeledMethods: readonly ModeledMethod[]) {
|
||||||
|
const modelTypes = modeledMethods
|
||||||
|
.map((m) => m.type)
|
||||||
|
.filter((t) => t !== "none")
|
||||||
|
.join(", ");
|
||||||
|
|
||||||
void this.logger.log(
|
void this.logger.log(
|
||||||
`Model editor query consistency check: Missing method ${signature} for method that is modeled.`,
|
`Model editor query consistency check: Missing method ${signature} for method that is modeled as ${modelTypes}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,17 +14,20 @@ describe("checkConsistency", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should call missingMethod when method is missing", () => {
|
it("should call missingMethod when method is missing", () => {
|
||||||
|
const modeledMethods = [createSourceModeledMethod()];
|
||||||
|
|
||||||
checkConsistency(
|
checkConsistency(
|
||||||
[],
|
[],
|
||||||
{
|
{
|
||||||
"Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SeparatedList`1(System.Collections.Generic.IEnumerable<TNode>)":
|
"Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SeparatedList`1(System.Collections.Generic.IEnumerable<TNode>)":
|
||||||
[createSourceModeledMethod()],
|
modeledMethods,
|
||||||
},
|
},
|
||||||
notifier,
|
notifier,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(notifier.missingMethod).toHaveBeenCalledWith(
|
expect(notifier.missingMethod).toHaveBeenCalledWith(
|
||||||
"Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SeparatedList`1(System.Collections.Generic.IEnumerable<TNode>)",
|
"Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SeparatedList`1(System.Collections.Generic.IEnumerable<TNode>)",
|
||||||
|
modeledMethods,
|
||||||
);
|
);
|
||||||
expect(notifier.inconsistentSupported).not.toHaveBeenCalled();
|
expect(notifier.inconsistentSupported).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user