55 lines
2.3 KiB
Java
55 lines
2.3 KiB
Java
package com.discord.utilities.textprocessing;
|
|
|
|
import c.a.t.b.b.e;
|
|
import com.discord.simpleast.core.node.Node;
|
|
import com.discord.simpleast.core.node.StyleNode;
|
|
import com.discord.simpleast.core.parser.ParseSpec;
|
|
import com.discord.simpleast.core.parser.Parser;
|
|
import com.discord.simpleast.core.parser.Rule;
|
|
import d0.t.n;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
/* compiled from: Rules.kt */
|
|
public final class Rules$createTextReplacementRule$1 extends Rule<T, Node<T>, S> {
|
|
private final List<Rule<T, Node<T>, S>> innerRules = n.listOf((Object[]) new Rule[]{Rules.INSTANCE.createNamedEmojiRule(), e.h.d()});
|
|
public final /* synthetic */ Rules this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Rules$createTextReplacementRule$1(Rules rules, Pattern pattern) {
|
|
super(pattern);
|
|
this.this$0 = rules;
|
|
}
|
|
|
|
public final List<Rule<T, Node<T>, S>> getInnerRules() {
|
|
return this.innerRules;
|
|
}
|
|
|
|
@Override // com.discord.simpleast.core.parser.Rule
|
|
public ParseSpec<T, S> parse(Matcher matcher, Parser<T, ? super Node<T>, S> parser, S s2) {
|
|
Node node;
|
|
m.checkNotNullParameter(matcher, "matcher");
|
|
m.checkNotNullParameter(parser, "parser");
|
|
Rules rules = Rules.INSTANCE;
|
|
String group = matcher.group();
|
|
m.checkNotNullExpressionValue(group, "matcher.group()");
|
|
List parse = parser.parse(Rules.access$replaceEmojiSurrogates(rules, group), s2, this.innerRules);
|
|
if (parse.size() == 1) {
|
|
Object first = u.first((List<? extends Object>) parse);
|
|
Objects.requireNonNull(first, "null cannot be cast to non-null type com.discord.simpleast.core.node.Node<T>");
|
|
node = (Node) first;
|
|
} else {
|
|
StyleNode styleNode = new StyleNode(n.emptyList());
|
|
for (Object obj : parse) {
|
|
Objects.requireNonNull(obj, "null cannot be cast to non-null type com.discord.simpleast.core.node.Node<T>");
|
|
styleNode.addChild((Node) obj);
|
|
}
|
|
node = styleNode;
|
|
}
|
|
m.checkNotNullParameter(node, "node");
|
|
return new ParseSpec<>(node, s2);
|
|
}
|
|
}
|