mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
This change makes it easier to run the script from directly `roll_py.deps` without having to fetch the dependencies first. This also makes it easier to track which dependencies our tooling have. Change-Id: I1ce55074ee6a1fffa6f2a2f05a56d0d74b4aca90 Bug: 1255619 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3431346 Reviewed-by: Mathias Bynens <mathias@chromium.org> Commit-Queue: Johan Bay <jobay@chromium.org>
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
// @ts-check
|
|
|
|
import { validationError } from "../error.js";
|
|
|
|
export function* checkInterfaceMemberDuplication(defs, i) {
|
|
const opNames = new Set(getOperations(i).map((op) => op.name));
|
|
const partials = defs.partials.get(i.name) || [];
|
|
const mixins = defs.mixinMap.get(i.name) || [];
|
|
for (const ext of [...partials, ...mixins]) {
|
|
const additions = getOperations(ext);
|
|
yield* forEachExtension(additions, opNames, ext, i);
|
|
for (const addition of additions) {
|
|
opNames.add(addition.name);
|
|
}
|
|
}
|
|
|
|
function* forEachExtension(additions, existings, ext, base) {
|
|
for (const addition of additions) {
|
|
const { name } = addition;
|
|
if (name && existings.has(name)) {
|
|
const message = `The operation "${name}" has already been defined for the base interface "${base.name}" either in itself or in a mixin`;
|
|
yield validationError(
|
|
addition.tokens.name,
|
|
ext,
|
|
"no-cross-overload",
|
|
message
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
function getOperations(i) {
|
|
return i.members.filter(({ type }) => type === "operation");
|
|
}
|
|
}
|