From 4044c73d0604a3a42032a4e316f781a7b6e55a79 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Fri, 16 Dec 2022 19:37:14 +0100 Subject: [PATCH] Fix https://github.com/plantuml/plantuml/issues/1216 --- .../sourceforge/plantuml/ComponentStyle.java | 2 +- src/net/sourceforge/plantuml/UrlBuilder.java | 27 ++++++++----------- .../classdiagram/command/CommandUrl.java | 3 ++- .../sequence/FactorySequenceNoteCommand.java | 3 ++- .../FactorySequenceNoteOnArrowCommand.java | 3 ++- ...FactorySequenceNoteOverSeveralCommand.java | 3 ++- .../plantuml/graphic/USymbols.java | 1 + .../sequencediagram/command/CommandUrl.java | 3 ++- .../sourceforge/plantuml/version/Version.java | 2 +- 9 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/net/sourceforge/plantuml/ComponentStyle.java b/src/net/sourceforge/plantuml/ComponentStyle.java index 4f0aa37c5..f2dc91e6c 100644 --- a/src/net/sourceforge/plantuml/ComponentStyle.java +++ b/src/net/sourceforge/plantuml/ComponentStyle.java @@ -49,7 +49,7 @@ public enum ComponentStyle { case UML2: return USymbols.COMPONENT2; case RECTANGLE: - return USymbols.RECTANGLE; + return USymbols.COMPONENT_RECTANGLE; } throw new AssertionError(); } diff --git a/src/net/sourceforge/plantuml/UrlBuilder.java b/src/net/sourceforge/plantuml/UrlBuilder.java index fba8d03df..8bf33efa6 100644 --- a/src/net/sourceforge/plantuml/UrlBuilder.java +++ b/src/net/sourceforge/plantuml/UrlBuilder.java @@ -94,49 +94,44 @@ public class UrlBuilder { public Url getUrl(String s) { Matcher2 m; m = QUOTED.matcher(s); - if (matchesOrFind(m)) { + if (matchesOrFind(m)) return new Url(withTopUrl(m.group(1)), m.group(2), m.group(3)); - } m = ONLY_TOOLTIP.matcher(s); - if (matchesOrFind(m)) { + if (matchesOrFind(m)) return new Url("", m.group(1), null); - } m = ONLY_TOOLTIP_AND_LABEL.matcher(s); - if (matchesOrFind(m)) { + if (matchesOrFind(m)) return new Url("", m.group(1), m.group(2)); - } m = LINK_TOOLTIP_NOLABEL.matcher(s); - if (matchesOrFind(m)) { + if (matchesOrFind(m)) return new Url(withTopUrl(m.group(1)), m.group(2), null); - } m = LINK_WITH_OPTIONAL_TOOLTIP_WITH_OPTIONAL_LABEL.matcher(s); - if (matchesOrFind(m)) { + if (matchesOrFind(m)) return new Url(withTopUrl(m.group(1)), m.group(2), m.group(3)); - } return null; } private boolean matchesOrFind(Matcher2 m) { - if (mode == UrlMode.STRICT) { + if (mode == UrlMode.STRICT) return m.matches(); - } else if (mode == UrlMode.ANYWHERE) { + else if (mode == UrlMode.ANYWHERE) return m.find(); - } else { + else throw new IllegalStateException(); - } + } private String withTopUrl(String url) { if (url.startsWith("http:") == false && url.startsWith("https:") == false && url.startsWith("file:") == false - && topurl != null) { + && topurl != null) return topurl + url; - } + return url; } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java index 82370bab3..424fd9a53 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java @@ -68,7 +68,8 @@ public class CommandUrl extends SingleLineCommand2 { RegexLeaf.spaceOneOrMore(), // new RegexOptional(new RegexLeaf("is")), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")"), RegexLeaf.end()); // + new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")"), // + RegexLeaf.end()); // } @Override diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java index af8241a08..1e7885d0a 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java @@ -82,7 +82,8 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), RegexLeaf.end()); + new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // + RegexLeaf.end()); } private IRegex getRegexConcatSingleLine() { diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java index 497543f49..3b98bf9b7 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java @@ -81,7 +81,8 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), RegexLeaf.end()); + new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // + RegexLeaf.end()); } private IRegex getRegexConcatSingleLine() { diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java index 629239785..9167410c4 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java @@ -87,7 +87,8 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), RegexLeaf.end() // + new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // + RegexLeaf.end() // ); } diff --git a/src/net/sourceforge/plantuml/graphic/USymbols.java b/src/net/sourceforge/plantuml/graphic/USymbols.java index b8133aa4f..d314e24bf 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbols.java +++ b/src/net/sourceforge/plantuml/graphic/USymbols.java @@ -83,6 +83,7 @@ public abstract class USymbols { public final static USymbol USECASE = null; public final static USymbol COMPONENT1 = record("COMPONENT1", new USymbolComponent1()); public final static USymbol COMPONENT2 = record("COMPONENT2", new USymbolComponent2()); + public final static USymbol COMPONENT_RECTANGLE = record("COMPONENT_RECTANGLE", new USymbolRectangle(SName.component)); public final static USymbol BOUNDARY = record("BOUNDARY", new USymbolBoundary()); public final static USymbol ENTITY_DOMAIN = record("ENTITY_DOMAIN", new USymbolEntityDomain()); public final static USymbol CONTROL = record("CONTROL", new USymbolControl()); diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java index 638bf59f5..aaf349824 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java @@ -65,7 +65,8 @@ public class CommandUrl extends SingleLineCommand2 { RegexLeaf.spaceOneOrMore(), // new RegexOptional(new RegexLeaf("is")), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")"), RegexLeaf.end()); // + new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")"), // + RegexLeaf.end()); // } @Override diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index a3978b46d..5e8e9824e 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -81,7 +81,7 @@ public class Version { } public static int beta() { - final int beta = 5; + final int beta = 6; return beta; }