Skip to content

Commit aef6d2a

Browse files
committed
Filter ContributedPlatformReleases after fully building them
1 parent cec4f41 commit aef6d2a

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

Diff for: app/src/cc/arduino/contributions/packages/ui/ContributedPlatformReleases.java

-6
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ public boolean shouldContain(ContributedPlatform platform) {
6161
return platform.getArchitecture().equals(arch);
6262
}
6363

64-
public boolean contains(ContributedPlatform platform) {
65-
return (platform.getParentPackage().equals(packager)
66-
&& platform.getArchitecture().equals(arch)
67-
&& versions.contains(platform.getParsedVersion()));
68-
}
69-
7064
public void add(ContributedPlatform platform) {
7165
releases.add(platform);
7266
String version = platform.getParsedVersion();

Diff for: app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java

+15-16
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,32 @@ public void updateIndexFilter(String[] filters,
6060

6161
private void updateContributions() {
6262
contributions.clear();
63+
64+
// Generate ContributedPlatformReleases from all platform releases
6365
for (ContributedPackage pack : BaseNoGui.indexer.getPackages()) {
6466
for (ContributedPlatform platform : pack.getPlatforms()) {
67+
addContribution(platform);
68+
}
69+
}
70+
71+
// Filter ContributedPlatformReleases based on search terms
72+
contributions.removeIf(releases -> {
73+
for (ContributedPlatform platform : releases.releases) {
6574
String compoundTargetSearchText = platform.getName() + "\n"
6675
+ platform.getBoards().stream()
6776
.map(ContributedBoard::getName)
6877
.collect(Collectors.joining(" "));
69-
70-
// Add all the versions of the same core, even if there's no match
71-
for (ContributedPlatformReleases contribution : contributions) {
72-
if (contribution.shouldContain(platform)) {
73-
addContribution(platform);
74-
continue;
75-
}
76-
}
77-
7878
if (!filter.test(platform)) {
7979
continue;
8080
}
8181
if (!stringContainsAll(compoundTargetSearchText, filters))
8282
continue;
83-
84-
addContribution(platform);
83+
return false;
8584
}
86-
}
85+
return true;
86+
});
87+
88+
// Sort ContributedPlatformReleases and put deprecated platforms to the bottom
8789
Collections.sort(contributions, (x,y)-> {
8890
if (x.isDeprecated() != y.isDeprecated()) {
8991
return x.isDeprecated() ? 1 : -1;
@@ -96,6 +98,7 @@ private void updateContributions() {
9698
}
9799
return x1.getName().compareToIgnoreCase(y1.getName());
98100
});
101+
99102
fireTableDataChanged();
100103
}
101104

@@ -123,10 +126,6 @@ private void addContribution(ContributedPlatform platform) {
123126
if (!contribution.shouldContain(platform)) {
124127
continue;
125128
}
126-
if (contribution.contains(platform)) {
127-
// no duplicates
128-
return;
129-
}
130129
contribution.add(platform);
131130
return;
132131
}

0 commit comments

Comments
 (0)