Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parser generation exception caused by unmodifiable collections us… #389

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/org/intellij/grammar/analysis/BnfFirstNextAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,15 @@ else if (GrammarUtil.isExternalReference(expression)) {
private static @NotNull Set<BnfExpression> exprSetIntersection(@NotNull Set<BnfExpression> a, @NotNull Set<BnfExpression> b) {
Set<BnfExpression> filter = newExprSet(a);
filter.retainAll(newExprSet(b));
Set<BnfExpression> result = union(a, b);
Set<BnfExpression> result = new HashSet<>(union(a, b));
result.retainAll(filter);
return result;
}

private static @NotNull Set<BnfExpression> exprSetDifference(@NotNull Set<BnfExpression> a, @NotNull Set<BnfExpression> b) {
Set<BnfExpression> filter = newExprSet(a);
filter.removeAll(newExprSet(b));
Set<BnfExpression> result = union(a, b);
Set<BnfExpression> result = new HashSet<>(union(a, b));
result.retainAll(filter);
return result;
}
Expand Down
8 changes: 5 additions & 3 deletions src/org/intellij/grammar/diagram/BnfDiagramProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ public String getElementTitle(BnfRule o) {
@Override
public Object @NotNull [] getNodeItems(BnfRule element) {
Map<PsiElement, RuleGraphHelper.Cardinality> map = myGraphHelper.getFor(element);
List<Item> entries = ContainerUtil.mapNotNull(map.entrySet(), p -> p.getKey() instanceof BnfRule o ? new Item(o, p.getValue()) : null);
Collections.sort(entries, (o, o1) -> Comparing.compare(o.rule.getName(), o1.rule.getName()));
return entries.toArray();
return map.entrySet().stream()
.map(p -> p.getKey() instanceof BnfRule o ? new Item(o, p.getValue()) : null)
.filter(Objects::nonNull)
.sorted((o, o1) -> Comparing.compare(o.rule.getName(), o1.rule.getName()))
.toArray();
}

@Override
Expand Down
Loading