mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +00:00
Use RegexConcat in CommandReferenceMultilinesOverSeveral
This commit is contained in:
parent
410f1caf71
commit
51f90138b7
@ -45,6 +45,10 @@ import net.sourceforge.plantuml.UrlMode;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexOptional;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.sequencediagram.Participant;
|
||||
import net.sourceforge.plantuml.sequencediagram.Reference;
|
||||
@ -55,24 +59,41 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
|
||||
public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<SequenceDiagram> {
|
||||
|
||||
public CommandReferenceMultilinesOverSeveral() {
|
||||
super("^ref(#\\w+)?[%s]+over[%s]+((?:[%pLN_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[%pLN_.@]+|[%g][^%g]+[%g]))*)$");
|
||||
super(getConcat().getPattern());
|
||||
}
|
||||
|
||||
private static RegexConcat getConcat() {
|
||||
return RegexConcat.build(CommandReferenceMultilinesOverSeveral.class.getName(),
|
||||
RegexLeaf.start(), //
|
||||
new RegexLeaf("ref"), //
|
||||
new RegexLeaf("REF", "(#\\w+)?"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("over"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("PARTS", "((?:[%pLN_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[%pLN_.@]+|[%g][^%g]+[%g]))*)"), //
|
||||
RegexLeaf.end());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPatternEnd() {
|
||||
return "^end[%s]?(ref)?$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(final SequenceDiagram diagram, BlocLines lines) throws NoSuchColorException {
|
||||
final List<String> line0 = StringUtils.getSplit(getStartingPattern(),
|
||||
lines.getFirst().getTrimmed().getString());
|
||||
final String s1 = line0.get(0);
|
||||
String firstLine = lines.getFirst().getTrimmed().getString();
|
||||
RegexResult arg = getConcat().matcher(firstLine);
|
||||
if (arg == null) {
|
||||
return CommandExecutionResult.error("Cannot parse line " + firstLine);
|
||||
}
|
||||
|
||||
String s1 = arg.get("REF", 0);
|
||||
final HColor backColorElement = s1 == null ? null
|
||||
: diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s1);
|
||||
// final HtmlColor backColorGeneral =
|
||||
// HtmlColorSetSimple.instance().getColorIfValid(line0.get(1));
|
||||
|
||||
final List<String> participants = StringUtils.splitComma(line0.get(1));
|
||||
final List<String> participants = StringUtils.splitComma(arg.get("PARTS", 0));
|
||||
final List<Participant> p = new ArrayList<>();
|
||||
for (String s : participants) {
|
||||
p.add(diagram.getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)));
|
||||
|
Loading…
Reference in New Issue
Block a user