Skip to content

Commit

Permalink
🐛 fix: classes cannot be nested
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudroques committed Dec 4, 2024
1 parent 24bde10 commit d4b7816
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import net.sourceforge.plantuml.klimt.creole.Display;
import net.sourceforge.plantuml.klimt.font.FontParam;
import net.sourceforge.plantuml.plasma.Quark;
import net.sourceforge.plantuml.project.Failable;
import net.sourceforge.plantuml.regex.IRegex;
import net.sourceforge.plantuml.regex.RegexConcat;
import net.sourceforge.plantuml.regex.RegexLeaf;
Expand Down Expand Up @@ -121,15 +122,17 @@ protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation l

final String stereo = arg.get("STEREO", 0);

final Quark<Entity> quark = diagram.quarkInContext(false, idShort);
final Failable<Quark<Entity>> quark = diagram.quarkInContextSafe(false, idShort);
if (quark.isFail())
return CommandExecutionResult.error(quark.getError());

Entity entity = quark.getData();
Entity entity = quark.get().getData();

if (entity == null) {
Display display = Display.getWithNewlines(diagram.getPragma(), displayString);
if (Display.isNull(display))
display = Display.getWithNewlines(diagram.getPragma(), quark.getName()).withCreoleMode(CreoleMode.SIMPLE_LINE);
entity = diagram.reallyCreateLeaf(quark, display, type, null);
display = Display.getWithNewlines(diagram.getPragma(), quark.get().getName()).withCreoleMode(CreoleMode.SIMPLE_LINE);
entity = diagram.reallyCreateLeaf(quark.get(), display, type, null);
} else {
if (entity.muteToType(type, null) == false)
return CommandExecutionResult.error("Bad name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import net.sourceforge.plantuml.klimt.creole.Display;
import net.sourceforge.plantuml.klimt.font.FontParam;
import net.sourceforge.plantuml.plasma.Quark;
import net.sourceforge.plantuml.project.Failable;
import net.sourceforge.plantuml.regex.IRegex;
import net.sourceforge.plantuml.regex.RegexConcat;
import net.sourceforge.plantuml.regex.RegexLeaf;
Expand Down Expand Up @@ -160,15 +161,17 @@ protected CommandExecutionResult executeNow(ClassDiagram diagram, BlocLines line

final String stereotype = line0.get("STEREO", 0);

final Quark<Entity> quark = diagram.quarkInContext(false, idShort);
final Failable<Quark<Entity>> quark = diagram.quarkInContextSafe(false, idShort);
if (quark.isFail())
return CommandExecutionResult.error(quark.getError());

Entity entity = quark.getData();
Entity entity = quark.get().getData();

Display display = Display.getWithNewlines(diagram.getPragma(), displayString);
if (entity == null) {
if (Display.isNull(display))
display = Display.getWithNewlines(diagram.getPragma(), quark.getName()).withCreoleMode(CreoleMode.SIMPLE_LINE);
entity = diagram.reallyCreateLeaf(quark, display, type, null);
display = Display.getWithNewlines(diagram.getPragma(), quark.get().getName()).withCreoleMode(CreoleMode.SIMPLE_LINE);
entity = diagram.reallyCreateLeaf(quark.get(), display, type, null);
} else {
if (entity.muteToType(type, null) == false)
return CommandExecutionResult.error("Cannot create " + idShort + " because it already exists");
Expand Down

0 comments on commit d4b7816

Please sign in to comment.