Skip to content
Snippets Groups Projects
Commit 69e46138 authored by René Schöne's avatar René Schöne
Browse files

0.2.7

- mark NTA containment using colored arrow (configurable, default: blue)
- add relation role names
- dev package is not considered newer than the latest main build
- add sources and javadoc to package
parent 02eba235
Branches
No related tags found
No related merge requests found
Pipeline #14736 failed
...@@ -225,13 +225,18 @@ task printVersion() { ...@@ -225,13 +225,18 @@ task printVersion() {
task setDevVersionForCI() { task setDevVersionForCI() {
doFirst { doFirst {
def props = new Properties() def props = new Properties()
props['version'] = version + "-$System.env.CI_PIPELINE_IID" props['version'] = version + "-dev-$System.env.CI_PIPELINE_IID"
props.store(file(versionFile).newWriter(), null) props.store(file(versionFile).newWriter(), null)
} }
} }
group = 'de.tudresden.inf.st' group = 'de.tudresden.inf.st'
java {
withJavadocJar()
withSourcesJar()
}
publishing { publishing {
publications { publications {
maven(MavenPublication) { maven(MavenPublication) {
......
Grammar2Uml ::= Program <FileName> Folder* <StyleDefinition:StyleDefinition> ; Grammar2Uml ::= Program <FileName> Folder* StyleInformation <StyleDefinition:StyleDefinition> ;
Folder ::= <Name:String> <Active:boolean> ; Folder ::= <Name:String> <Active:boolean> ;
rel Folder.Type* <-> TypeDecl.SourceFolder?; rel Folder.Type* <-> TypeDecl.SourceFolder?;
Style ::= <BackgroundColor> <InlineAsSuperType:boolean> ; Style ::= <BackgroundColor> <InlineAsSuperType:boolean> ;
StyleInformation ::= <ComputedColor> ;
...@@ -2,11 +2,11 @@ MGrammar2Uml ::= Folder:MFolder* OtherType:MTypeDecl* Containment:MContainment* ...@@ -2,11 +2,11 @@ MGrammar2Uml ::= Folder:MFolder* OtherType:MTypeDecl* Containment:MContainment*
MFolder ::= InnerTypeDecl:MTypeDecl* <Active:boolean> ; MFolder ::= InnerTypeDecl:MTypeDecl* <Active:boolean> ;
MTypeDecl ::= InnerTokenComponent:MTokenComponent* <Name> Style; MTypeDecl ::= InnerTokenComponent:MTokenComponent* <Name> Style;
MTokenComponent; MTokenComponent;
abstract MContainment ::= <Label:String> ; abstract MContainment ::= <Label:String> <Computed:boolean> ;
MSingleContainment : MContainment; MSingleContainment : MContainment;
MOptContainment : MContainment; MOptContainment : MContainment;
MListContainment : MContainment; MListContainment : MContainment;
MRelation ::= <Label> <LeftModifier> <RightModifier> <Bidirectional:boolean>; MRelation ::= <Label> <LeftLabel> <RightLabel> <Bidirectional:boolean>;
MInheritance; MInheritance;
rel MGrammar2Uml.Grammar2Uml -> Grammar2Uml; rel MGrammar2Uml.Grammar2Uml -> Grammar2Uml;
...@@ -17,6 +17,5 @@ rel MContainment.Type -> MTypeDecl; ...@@ -17,6 +17,5 @@ rel MContainment.Type -> MTypeDecl;
rel MContainment.Component -> MTypeDecl; rel MContainment.Component -> MTypeDecl;
rel MRelation.Left -> MTypeDecl; rel MRelation.Left -> MTypeDecl;
rel MRelation.Right -> MTypeDecl; rel MRelation.Right -> MTypeDecl;
//rel MTypeDecl.SuperClass? -> MTypeDecl;
rel MInheritance.SuperClass -> MTypeDecl; rel MInheritance.SuperClass -> MTypeDecl;
rel MInheritance.SubClass -> MTypeDecl; rel MInheritance.SubClass -> MTypeDecl;
aspect Configuration { aspect Configuration {
public static StyleInformation StyleInformation.createDefault() {
return new StyleInformation().setComputedColor("blue");
}
} }
...@@ -47,6 +47,7 @@ aspect AttributesForMustache { ...@@ -47,6 +47,7 @@ aspect AttributesForMustache {
syn String MContainment.typeName() = "\"" + getType().getName() + "\""; syn String MContainment.typeName() = "\"" + getType().getName() + "\"";
syn String MContainment.componentName() = "\"" + getComponent().getName() + "\""; syn String MContainment.componentName() = "\"" + getComponent().getName() + "\"";
syn String MContainment.modifier(); syn String MContainment.modifier();
syn String MContainment.computedColor() = grammar2uml().getStyleInformation().getComputedColor();
eq MSingleContainment.modifier() = "\"1\""; eq MSingleContainment.modifier() = "\"1\"";
eq MOptContainment.modifier() = "\"0 .. 1\""; eq MOptContainment.modifier() = "\"0 .. 1\"";
eq MListContainment.modifier() = "\"*\""; eq MListContainment.modifier() = "\"*\"";
...@@ -82,27 +83,32 @@ aspect AttributesForMustache { ...@@ -82,27 +83,32 @@ aspect AttributesForMustache {
syn MRelation Relation.toMRelation(); syn MRelation Relation.toMRelation();
eq DirectedRelation.toMRelation() { eq DirectedRelation.toMRelation() {
MRelation result = new MRelation(); MRelation result = new MRelation();
result.setRightModifier(getSource().toMRelationModifier()); result.setRightLabel("\"" + getSource().toMRelationModifier() + getSource().maybeName() + "\"");
result.setBidirectional(false); result.setBidirectional(false);
return result; return result;
} }
eq BidirectionalRelation.toMRelation() { eq BidirectionalRelation.toMRelation() {
MRelation result = new MRelation(); MRelation result = new MRelation();
result.setLeftModifier(getRight().toMRelationModifier()); result.setLeftLabel("\"" + getRight().toMRelationModifier() + getRight().maybeName() + "\"");
result.setRightModifier(getLeft().toMRelationModifier()); result.setRightLabel("\"" + getLeft().toMRelationModifier() + getLeft().maybeName() + "\"");
result.setBidirectional(true); result.setBidirectional(true);
return result; return result;
} }
// --- toMRelationModifier --- // --- toMRelationModifier ---
syn String Role.toMRelationModifier(); syn String Role.toMRelationModifier();
eq NormalRole.toMRelationModifier() = "\"1\""; eq NormalRole.toMRelationModifier() = "1";
eq ListRole.toMRelationModifier() = "\"*\""; eq ListRole.toMRelationModifier() = "*";
eq OptRole.toMRelationModifier() = "\"0 .. 1\""; eq OptRole.toMRelationModifier() = "0 .. 1";
eq UnnamedRole.toMRelationModifier() { eq UnnamedRole.toMRelationModifier() {
throw new RuntimeException("UnnamedRole cannot be converted to MRelation"); throw new RuntimeException("UnnamedRole cannot be converted to MRelation");
} }
// --- maybeName ---
syn String Role.maybeName() = "";
eq NavigableRole.maybeName() = " " + getName();
// --- createDefaultStyle ---
private Style TypeDecl.createDefaultStyle() { private Style TypeDecl.createDefaultStyle() {
return new Style().setBackgroundColor("white"); return new Style().setBackgroundColor("white");
} }
...@@ -136,6 +142,9 @@ aspect AttributesForMustache { ...@@ -136,6 +142,9 @@ aspect AttributesForMustache {
if (!component.getName().isEmpty() && !component.getName().equals(component.asTypeComponent().getTypeDecl().getName())) { if (!component.getName().isEmpty() && !component.getName().equals(component.asTypeComponent().getTypeDecl().getName())) {
containment.setLabel(component.getName()); containment.setLabel(component.getName());
} }
if (component.getNTA()) {
containment.setComputed(true);
}
result.addContainment(containment); result.addContainment(containment);
} }
} }
......
...@@ -26,11 +26,16 @@ public class Grammar2UmlProcessor { ...@@ -26,11 +26,16 @@ public class Grammar2UmlProcessor {
private final List<String> inputGrammarFiles = new ArrayList<>(); private final List<String> inputGrammarFiles = new ArrayList<>();
private boolean verbose; private boolean verbose;
private boolean useDefaultFolders; private boolean useDefaultFolders;
private final List<Folder> folders = new ArrayList<>(); private final Grammar2Uml grammar2uml;
private Grammar2Uml grammar2uml = null;
private final List<Consumer<Grammar2Uml>> callbacks = new ArrayList<>(); private final List<Consumer<Grammar2Uml>> callbacks = new ArrayList<>();
private StyleDefinition styleDefinition = (typeDecl, style) -> {}; private StyleDefinition styleDefinition = (typeDecl, style) -> {};
public Grammar2UmlProcessor() {
grammar2uml = new Grammar2Uml();
grammar2uml.setStyleInformation(StyleInformation.createDefault());
}
public Grammar2UmlProcessor addGrammar(String... inputGrammarFiles) { public Grammar2UmlProcessor addGrammar(String... inputGrammarFiles) {
Collections.addAll(this.inputGrammarFiles, inputGrammarFiles); Collections.addAll(this.inputGrammarFiles, inputGrammarFiles);
return this; return this;
...@@ -52,7 +57,7 @@ public class Grammar2UmlProcessor { ...@@ -52,7 +57,7 @@ public class Grammar2UmlProcessor {
* @return this * @return this
*/ */
public Grammar2UmlProcessor addFolder(Folder... folders) { public Grammar2UmlProcessor addFolder(Folder... folders) {
Collections.addAll(this.folders, folders); Arrays.stream(folders).forEach(this.grammar2uml::addFolder);
return this; return this;
} }
...@@ -88,6 +93,11 @@ public class Grammar2UmlProcessor { ...@@ -88,6 +93,11 @@ public class Grammar2UmlProcessor {
return this; return this;
} }
public Grammar2UmlProcessor setComputedColor(String color) {
this.grammar2uml.getStyleInformation().setComputedColor(color);
return this;
}
/** /**
* Writes the representation to the given destination file. * Writes the representation to the given destination file.
* *
...@@ -189,24 +199,8 @@ public class Grammar2UmlProcessor { ...@@ -189,24 +199,8 @@ public class Grammar2UmlProcessor {
} }
} }
// private void debugAttributes() {
// for (Folder folder : grammar2uml.getFolderList()) {
// System.out.println(folder.getName() + ": active=" + folder.getActive() + ", mFolder.active=" + folder.toMustache().getActive());
// }
// for (TypeDecl typeDecl : grammar2uml.getProgram().typeDecls().stream()
// .sorted(Comparator.comparing(TypeDecl::getName))
// .collect(Collectors.toList())) {
// MTypeDecl mTypeDecl = typeDecl.toMustache();
// System.out.println(typeDecl.getName() + ": " + String.join(", ",
// "relates=" + typeDecl.relatesToActiveTypeDecl(),
// "folderInactive+Unrelated=" + mTypeDecl.folderInactiveAndUnrelated(),
// "folderInactive+Related=" + mTypeDecl.folderInactiveAndRelated(),
// "folderActive=" + mTypeDecl.containingFolderActive()));
// }
// }
private void build() throws CompilerException { private void build() throws CompilerException {
if (grammar2uml != null) { if (grammar2uml.getProgram() != null) {
return; // already built return; // already built
} }
...@@ -215,7 +209,6 @@ public class Grammar2UmlProcessor { ...@@ -215,7 +209,6 @@ public class Grammar2UmlProcessor {
} }
Program program = new Program(); Program program = new Program();
grammar2uml = new Grammar2Uml();
for (String inputGrammarFileName : inputGrammarFiles) { for (String inputGrammarFileName : inputGrammarFiles) {
printMessage("Parsing " + inputGrammarFileName); printMessage("Parsing " + inputGrammarFileName);
GrammarFile inputGrammar; GrammarFile inputGrammar;
...@@ -239,10 +232,6 @@ public class Grammar2UmlProcessor { ...@@ -239,10 +232,6 @@ public class Grammar2UmlProcessor {
} }
} }
for (Folder folder : folders) {
grammar2uml.addFolder(folder);
}
grammar2uml.setStyleDefinition(styleDefinition); grammar2uml.setStyleDefinition(styleDefinition);
grammar2uml.setProgram(program); grammar2uml.setProgram(program);
grammar2uml.treeResolveAll(); grammar2uml.treeResolveAll();
......
{{#atLeastOneInActiveFolder}} {{#atLeastOneInActiveFolder}}
{{{typeName}}} *-- {{{modifier}}} {{{componentName}}} {{#Label}}: {{Label}}{{/Label}} {{{typeName}}} *-[#black{{#Computed}},#{{{computedColor}}}{{/Computed}}]- {{{modifier}}} {{{componentName}}} {{#Label}}: {{Label}}{{/Label}}
{{/atLeastOneInActiveFolder}} {{/atLeastOneInActiveFolder}}
{{#atLeastOneInActiveFolder}} {{#atLeastOneInActiveFolder}}
{{{leftName}}} {{{leftModifier}}} {{#isBidirectional}}<{{/isBidirectional}}-[norank]-> {{{rightModifier}}} {{{rightName}}} {{#Label}}: {{Label}}{{/Label}} {{{leftName}}} {{{LeftLabel}}} {{#isBidirectional}}<{{/isBidirectional}}-[norank]-> {{{RightLabel}}} {{{rightName}}} {{#Label}}: {{Label}}{{/Label}}
{{/atLeastOneInActiveFolder}} {{/atLeastOneInActiveFolder}}
#Fri Sep 30 14:31:26 CEST 2022 #Tue Oct 04 16:43:05 CEST 2022
version=0.2.6 version=0.2.7
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment