diff options
author | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2020-03-10 16:38:20 +0100 |
---|---|---|
committer | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2020-03-10 16:38:20 +0100 |
commit | 7cc8c823de644a510fcc434f39b53e5fffe66bfd (patch) | |
tree | 8f4d027284bb366734f610040c621a0c5dd0a12a /src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java | |
parent | 567b200b91537405689ae0ca944f121201360a6b (diff) |
New upstream version 1.2020.2
Diffstat (limited to 'src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java')
-rw-r--r-- | src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java index c6bf8fd..b9f3f8d 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * (C) Copyright 2009-2017, Arnaud Roques + * (C) Copyright 2009-2020, Arnaud Roques * * Project Info: http://plantuml.com * @@ -35,26 +35,41 @@ */ package net.sourceforge.plantuml.objectdiagram.command; -import java.util.List; - +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; import net.sourceforge.plantuml.skin.VisibilityModifier; -public class CommandAddData extends SingleLineCommand<AbstractClassOrObjectDiagram> { +public class CommandAddData extends SingleLineCommand2<AbstractClassOrObjectDiagram> { public CommandAddData() { - super("(?i)^([\\p{L}0-9_.]+)[%s]*:[%s]*(.*)$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandAddData.class.getName(), RegexLeaf.start(), // + new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf(":"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("DATA", "(.*)"), RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, List<String> arg) { - final IEntity entity = diagram.getOrCreateLeaf(Code.of(arg.get(0)), null, null); + protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location, + RegexResult arg) { + final String name = arg.get("NAME", 0); + final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(name), + diagram.buildCode(name), null, null); - final String field = arg.get(1); + final String field = arg.get("DATA", 0); if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) { diagram.setVisibilityModifierPresent(true); } |