Skip to content

Commit dd1e60f

Browse files
Treat introduction after ancestor deprecation as lack of support for Darwin. (#1026)
If something gets renamed and the old name is deprecated, then a new thing inside the renamed thing is added (e.g. a new value for an enum that got renamed), we should not generate the new thing combined with the old name.
1 parent 869c925 commit dd1e60f

File tree

1 file changed

+51
-23
lines changed
  • src-electron/generator/matter/darwin/Framework/CHIP/templates

1 file changed

+51
-23
lines changed

src-electron/generator/matter/darwin/Framework/CHIP/templates/helper.js

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,42 @@ function findPathToContainer(availabilityPath) {
589589
}
590590
}
591591

592+
/**
593+
* Finds the release in which this path, or one of its ancestors, was
594+
* deprecated, if such a release exists. If no such release exists, returns
595+
* undefined.
596+
*/
597+
function findDeprecationRelease(global, path, options) {
598+
if (path === undefined) {
599+
return undefined;
600+
}
601+
602+
const data = fetchAvailabilityData(global);
603+
let deprecatedRelease = undefined;
604+
let deprecationPath = [...path];
605+
while (deprecatedRelease === undefined && deprecationPath != undefined) {
606+
deprecatedRelease = findReleaseForPath(
607+
data,
608+
['deprecated', ...deprecationPath],
609+
options
610+
);
611+
deprecationPath = findPathToContainer(deprecationPath);
612+
}
613+
if (options.hash.deprecatedRelease) {
614+
let minimalDeprecatedRelease = findReleaseByName(
615+
data,
616+
options.hash.deprecatedRelease
617+
);
618+
if (
619+
deprecatedRelease === undefined ||
620+
data.indexOf(deprecatedRelease) > data.indexOf(minimalDeprecatedRelease)
621+
) {
622+
deprecatedRelease = minimalDeprecatedRelease;
623+
}
624+
}
625+
return deprecatedRelease;
626+
}
627+
592628
async function availability(clusterName, options) {
593629
const data = fetchAvailabilityData(this.global);
594630
const path = makeAvailabilityPath(clusterName, options);
@@ -636,28 +672,7 @@ async function availability(clusterName, options) {
636672
}
637673
let introducedVersions = introducedRelease?.versions;
638674

639-
let deprecatedRelease = undefined;
640-
let deprecationPath = [...path];
641-
while (deprecatedRelease === undefined && deprecationPath != undefined) {
642-
deprecatedRelease = findReleaseForPath(
643-
data,
644-
['deprecated', ...deprecationPath],
645-
options
646-
);
647-
deprecationPath = findPathToContainer(deprecationPath);
648-
}
649-
if (options.hash.deprecatedRelease) {
650-
let minimalDeprecatedRelease = findReleaseByName(
651-
data,
652-
options.hash.deprecatedRelease
653-
);
654-
if (
655-
deprecatedRelease === undefined ||
656-
data.indexOf(deprecatedRelease) > data.indexOf(minimalDeprecatedRelease)
657-
) {
658-
deprecatedRelease = minimalDeprecatedRelease;
659-
}
660-
}
675+
let deprecatedRelease = findDeprecationRelease(this.global, path, options);
661676
const deprecatedVersions = deprecatedRelease?.versions;
662677

663678
if (introducedVersions === undefined && deprecatedVersions !== undefined) {
@@ -842,17 +857,30 @@ function pathsEqual(path1, path2) {
842857
}
843858

844859
function isSupported(cluster, options) {
860+
// Things that are removed are not supported.
845861
if (wasRemoved.call(this, cluster, options)) {
846862
return false;
847863
}
848864

865+
// Things that have a deprecated container and were not introduced before the
866+
// deprecation are not supported.
867+
let path = makeAvailabilityPath(cluster, options);
868+
let deprecationRelease = findDeprecationRelease(this.global, findPathToContainer(path), options);
869+
if (deprecationRelease !== undefined) {
870+
let comparisonStatus = compareIntroductionToReferenceRelease(this.global, path, options, deprecationRelease);
871+
// The only case where we might be supported is if we have an explicit
872+
// introduction and the introduction comes before the ancestor deprecation.
873+
if (comparisonStatus != -1) {
874+
return false;
875+
}
876+
}
877+
849878
let provisionalRelease = findReleaseForPathOrAncestorAndSection(this.global, cluster, options, 'provisional');
850879
if (provisionalRelease === undefined) {
851880
// Default to enabled, even if not explicitly introduced.
852881
return true;
853882
}
854883

855-
let path = makeAvailabilityPath(cluster, options);
856884
while (path !== undefined) {
857885
let comparisonStatus = compareIntroductionToReferenceRelease(
858886
this.global,

0 commit comments

Comments
 (0)