1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-22 21:15:09 +00:00

Merge pull request #1028 from bobjacobsen/bj-add-protocol-struct

Add Swift support for Protocol and Struct in class diagram
This commit is contained in:
PlantUML 2022-06-06 12:47:29 +02:00 committed by GitHub
commit f6b47e6ea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 30 deletions

View File

@ -80,7 +80,7 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
private static IRegex getRegexConcat() { private static IRegex getRegexConcat() {
return RegexConcat.build(CommandCreateClass.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandCreateClass.class.getName(), RegexLeaf.start(), //
new RegexLeaf("TYPE", // new RegexLeaf("TYPE", //
"(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|circle|diamond)"), // "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|circle|diamond|protocol|struct)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexOr(// new RegexOr(//
new RegexConcat(// new RegexConcat(//

View File

@ -92,7 +92,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
private static IRegex getRegexConcat() { private static IRegex getRegexConcat() {
return RegexConcat.build(CommandCreateClassMultilines.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandCreateClassMultilines.class.getName(), RegexLeaf.start(), //
new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacterInClassName() + ")?"), // new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacterInClassName() + ")?"), //
new RegexLeaf("TYPE", "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity)"), // new RegexLeaf("TYPE", "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|protocol|struct)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexOr(// new RegexOr(//
new RegexConcat(// new RegexConcat(//

View File

@ -163,6 +163,10 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS); gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS);
} else if (arg1.equalsIgnoreCase("annotation")) { } else if (arg1.equalsIgnoreCase("annotation")) {
gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION); gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION);
} else if (arg1.equalsIgnoreCase("protocol")) {
gender = EntityGenderUtils.byEntityType(LeafType.PROTOCOL);
} else if (arg1.equalsIgnoreCase("struct")) {
gender = EntityGenderUtils.byEntityType(LeafType.STRUCT);
} else if (arg1.startsWith("<<")) { } else if (arg1.startsWith("<<")) {
gender = EntityGenderUtils.byStereotype(arg1); gender = EntityGenderUtils.byStereotype(arg1);
} else { } else {

View File

@ -95,7 +95,7 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
private static String optionalKeywords(UmlDiagramType type) { private static String optionalKeywords(UmlDiagramType type) {
if (type == UmlDiagramType.CLASS) { if (type == UmlDiagramType.CLASS) {
return "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity)"; return "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|protocol|struct)";
} }
if (type == UmlDiagramType.OBJECT) { if (type == UmlDiagramType.OBJECT) {
return "(object)"; return "(object)";

View File

@ -42,7 +42,9 @@ public enum LeafType {
EMPTY_PACKAGE, EMPTY_PACKAGE,
ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, JSON, ASSOCIATION, ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION,
PROTOCOL, STRUCT,
LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, JSON, ASSOCIATION,
ENUM, CIRCLE, ENUM, CIRCLE,
USECASE, USECASE_BUSINESS, USECASE, USECASE_BUSINESS,
@ -76,7 +78,8 @@ public enum LeafType {
public boolean isLikeClass() { public boolean isLikeClass() {
return this == LeafType.ANNOTATION || this == LeafType.ABSTRACT_CLASS || this == LeafType.CLASS return this == LeafType.ANNOTATION || this == LeafType.ABSTRACT_CLASS || this == LeafType.CLASS
|| this == LeafType.INTERFACE || this == LeafType.ENUM || this == LeafType.ENTITY; || this == LeafType.INTERFACE || this == LeafType.ENUM || this == LeafType.ENTITY
|| this == LeafType.PROTOCOL || this == LeafType.STRUCT;
} }
public String toHtml() { public String toHtml() {

View File

@ -139,6 +139,8 @@ public enum SName {
spotAnnotation, // spotAnnotation, //
spotInterface, // spotInterface, //
spotEnum, // spotEnum, //
spotProtocol, //
spotStruct, //
spotEntity, // spotEntity, //
spotClass, // spotClass, //
spotAbstractClass, // spotAbstractClass, //

View File

@ -194,6 +194,10 @@ public class EntityImageClassHeader extends AbstractEntityImage {
return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotEnum); return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotEnum);
case ENTITY: case ENTITY:
return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotEntity); return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotEntity);
case PROTOCOL:
return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotProtocol);
case STRUCT:
return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotStruct);
} }
throw new IllegalStateException(); throw new IllegalStateException();
} }
@ -212,6 +216,10 @@ public class EntityImageClassHeader extends AbstractEntityImage {
return 'E'; return 'E';
case ENTITY: case ENTITY:
return 'E'; return 'E';
case PROTOCOL:
return 'P';
case STRUCT:
return 'S';
} }
assert false; assert false;
return '?'; return '?';