Skip to content

Commit

Permalink
pragma: use ImmutableSeq
Browse files Browse the repository at this point in the history
  • Loading branch information
HoshinoTented committed Jan 7, 2025
1 parent 501392e commit 726afc0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
11 changes: 4 additions & 7 deletions producer/src/main/java/org/aya/producer/AyaProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import com.intellij.psi.tree.TokenSet;
import kala.collection.SeqView;
import kala.collection.immutable.ImmutableSeq;
import kala.collection.mutable.MutableEnumSet;
import kala.collection.mutable.MutableList;
import kala.collection.mutable.MutableSet;
import kala.collection.mutable.MutableSinglyLinkedList;
import kala.collection.mutable.*;
import kala.control.Either;
import kala.control.Option;
import kala.function.BooleanObjBiFunction;
Expand Down Expand Up @@ -304,7 +301,7 @@ private void pragma(GenericNode<?> node, Decl decl) {
switch (name) {
case Constants.PRAGMA_SUPPRESS -> {
// TODO: use MutableEnumSet
MutableSet<WithPos<Suppress>> sups = MutableSet.create();
MutableList<WithPos<Suppress>> sups = FreezableMutableList.create();

for (var arg : args) {
var resolved = Arrays.stream(Suppress.values())
Expand All @@ -315,11 +312,11 @@ private void pragma(GenericNode<?> node, Decl decl) {
if (resolved == null) {
reporter.report(new BadXWarn.BadWarnWarn(sourcePosOf(arg), arg.tokenText().toString()));
} else {
sups.add(new WithPos<>(sourcePosOf(arg), resolved));
sups.append(new WithPos<>(sourcePosOf(arg), resolved));
}
}

decl.pragmaInfo.suppressWarn = new PragmaInfo.SuppressWarn(namePos, sups.toImmutableSet());
decl.pragmaInfo.suppressWarn = new PragmaInfo.SuppressWarn(namePos, sups.toImmutableSeq());
}
default -> reporter.report(new BadXWarn.BadPragmaWarn(namePos, name));
}
Expand Down
3 changes: 1 addition & 2 deletions syntax/src/main/java/org/aya/prettier/ConcretePrettier.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ private Doc visitAccess(@NotNull Accessibility acc, @Nullable Accessibility theD

if (info.suppressWarn != null) {
var args = info.suppressWarn.args().view()
.map(x -> Doc.plain(x.data().name()))
.toImmutableSeq();
.map(x -> Doc.plain(x.data().name()));

lines.append(doPragma(Doc.styled(KEYWORD, Constants.PRAGMA_SUPPRESS), Doc.commaList(args)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.syntax.concrete.stmt.decl;

import kala.collection.immutable.ImmutableSet;
import kala.collection.immutable.ImmutableSeq;
import org.aya.generic.Suppress;
import org.aya.util.error.SourcePos;
import org.aya.util.error.WithPos;
Expand All @@ -12,7 +12,7 @@

public class PragmaInfo {
/// @param sourcePos the name, not the whole pragma
public record SuppressWarn(@NotNull SourcePos sourcePos, @NotNull ImmutableSet<WithPos<Suppress>> args) {
public record SuppressWarn(@NotNull SourcePos sourcePos, @NotNull ImmutableSeq<WithPos<Suppress>> args) {
}

public @Nullable SuppressWarn suppressWarn = null;
Expand Down

0 comments on commit 726afc0

Please sign in to comment.