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
No related branches found
No related tags found
No related merge requests found
Pipeline #14736 failed
......@@ -225,13 +225,18 @@ task printVersion() {
task setDevVersionForCI() {
doFirst {
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)
}
}
group = 'de.tudresden.inf.st'
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
maven(MavenPublication) {
......
Grammar2Uml ::= Program <FileName> Folder* <StyleDefinition:StyleDefinition> ;
Grammar2Uml ::= Program <FileName> Folder* StyleInformation <StyleDefinition:StyleDefinition> ;
Folder ::= <Name:String> <Active:boolean> ;
rel Folder.Type* <-> TypeDecl.SourceFolder?;
Style ::= <BackgroundColor> <InlineAsSuperType:boolean> ;
StyleInformation ::= <ComputedColor> ;
......@@ -2,11 +2,11 @@ MGrammar2Uml ::= Folder:MFolder* OtherType:MTypeDecl* Containment:MContainment*
MFolder ::= InnerTypeDecl:MTypeDecl* <Active:boolean> ;
MTypeDecl ::= InnerTokenComponent:MTokenComponent* <Name> Style;
MTokenComponent;
abstract MContainment ::= <Label:String> ;
abstract MContainment ::= <Label:String> <Computed:boolean> ;
MSingleContainment : MContainment;
MOptContainment : MContainment;
MListContainment : MContainment;
MRelation ::= <Label> <LeftModifier> <RightModifier> <Bidirectional:boolean>;
MRelation ::= <Label> <LeftLabel> <RightLabel> <Bidirectional:boolean>;
MInheritance;
rel MGrammar2Uml.Grammar2Uml -> Grammar2Uml;
......@@ -17,6 +17,5 @@ rel MContainment.Type -> MTypeDecl;
rel MContainment.Component -> MTypeDecl;
rel MRelation.Left -> MTypeDecl;
rel MRelation.Right -> MTypeDecl;
//rel MTypeDecl.SuperClass? -> MTypeDecl;
rel MInheritance.SuperClass -> MTypeDecl;
rel MInheritance.SubClass -> MTypeDecl;
aspect Configuration {
public static StyleInformation StyleInformation.createDefault() {
return new StyleInformation().setComputedColor("blue");
}
}
......@@ -47,6 +47,7 @@ aspect AttributesForMustache {
syn String MContainment.typeName() = "\"" + getType().getName() + "\"";
syn String MContainment.componentName() = "\"" + getComponent().getName() + "\"";
syn String MContainment.modifier();
syn String MContainment.computedColor() = grammar2uml().getStyleInformation().getComputedColor();
eq MSingleContainment.modifier() = "\"1\"";
eq MOptContainment.modifier() = "\"0 .. 1\"";
eq MListContainment.modifier() = "\"*\"";
......@@ -82,27 +83,32 @@ aspect AttributesForMustache {
syn MRelation Relation.toMRelation();
eq DirectedRelation.toMRelation() {
MRelation result = new MRelation();
result.setRightModifier(getSource().toMRelationModifier());
result.setRightLabel("\"" + getSource().toMRelationModifier() + getSource().maybeName() + "\"");
result.setBidirectional(false);
return result;
}
eq BidirectionalRelation.toMRelation() {
MRelation result = new MRelation();
result.setLeftModifier(getRight().toMRelationModifier());
result.setRightModifier(getLeft().toMRelationModifier());
result.setLeftLabel("\"" + getRight().toMRelationModifier() + getRight().maybeName() + "\"");
result.setRightLabel("\"" + getLeft().toMRelationModifier() + getLeft().maybeName() + "\"");
result.setBidirectional(true);
return result;
}
// --- toMRelationModifier ---
syn String Role.toMRelationModifier();
eq NormalRole.toMRelationModifier() = "\"1\"";
eq ListRole.toMRelationModifier() = "\"*\"";
eq OptRole.toMRelationModifier() = "\"0 .. 1\"";
eq NormalRole.toMRelationModifier() = "1";
eq ListRole.toMRelationModifier() = "*";
eq OptRole.toMRelationModifier() = "0 .. 1";
eq UnnamedRole.toMRelationModifier() {
throw new RuntimeException("UnnamedRole cannot be converted to MRelation");
}
// --- maybeName ---
syn String Role.maybeName() = "";
eq NavigableRole.maybeName() = " " + getName();
// --- createDefaultStyle ---
private Style TypeDecl.createDefaultStyle() {
return new Style().setBackgroundColor("white");
}
......@@ -136,6 +142,9 @@ aspect AttributesForMustache {
if (!component.getName().isEmpty() && !component.getName().equals(component.asTypeComponent().getTypeDecl().getName())) {
containment.setLabel(component.getName());
}
if (component.getNTA()) {
containment.setComputed(true);
}
result.addContainment(containment);
}
}
......
......@@ -26,11 +26,16 @@ public class Grammar2UmlProcessor {
private final List<String> inputGrammarFiles = new ArrayList<>();
private boolean verbose;
private boolean useDefaultFolders;
private final List<Folder> folders = new ArrayList<>();
private Grammar2Uml grammar2uml = null;
private final Grammar2Uml grammar2uml;
private final List<Consumer<Grammar2Uml>> callbacks = new ArrayList<>();
private StyleDefinition styleDefinition = (typeDecl, style) -> {};
public Grammar2UmlProcessor() {
grammar2uml = new Grammar2Uml();
grammar2uml.setStyleInformation(StyleInformation.createDefault());
}
public Grammar2UmlProcessor addGrammar(String... inputGrammarFiles) {
Collections.addAll(this.inputGrammarFiles, inputGrammarFiles);
return this;
......@@ -52,7 +57,7 @@ public class Grammar2UmlProcessor {
* @return this
*/
public Grammar2UmlProcessor addFolder(Folder... folders) {
Collections.addAll(this.folders, folders);
Arrays.stream(folders).forEach(this.grammar2uml::addFolder);
return this;
}
......@@ -88,6 +93,11 @@ public class Grammar2UmlProcessor {
return this;
}
public Grammar2UmlProcessor setComputedColor(String color) {
this.grammar2uml.getStyleInformation().setComputedColor(color);
return this;
}
/**
* Writes the representation to the given destination file.
*
......@@ -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 {
if (grammar2uml != null) {
if (grammar2uml.getProgram() != null) {
return; // already built
}
......@@ -215,7 +209,6 @@ public class Grammar2UmlProcessor {
}
Program program = new Program();
grammar2uml = new Grammar2Uml();
for (String inputGrammarFileName : inputGrammarFiles) {
printMessage("Parsing " + inputGrammarFileName);
GrammarFile inputGrammar;
......@@ -239,10 +232,6 @@ public class Grammar2UmlProcessor {
}
}
for (Folder folder : folders) {
grammar2uml.addFolder(folder);
}
grammar2uml.setStyleDefinition(styleDefinition);
grammar2uml.setProgram(program);
grammar2uml.treeResolveAll();
......
{{#atLeastOneInActiveFolder}}
{{{typeName}}} *-- {{{modifier}}} {{{componentName}}} {{#Label}}: {{Label}}{{/Label}}
{{{typeName}}} *-[#black{{#Computed}},#{{{computedColor}}}{{/Computed}}]- {{{modifier}}} {{{componentName}}} {{#Label}}: {{Label}}{{/Label}}
{{/atLeastOneInActiveFolder}}
{{#atLeastOneInActiveFolder}}
{{{leftName}}} {{{leftModifier}}} {{#isBidirectional}}<{{/isBidirectional}}-[norank]-> {{{rightModifier}}} {{{rightName}}} {{#Label}}: {{Label}}{{/Label}}
{{{leftName}}} {{{LeftLabel}}} {{#isBidirectional}}<{{/isBidirectional}}-[norank]-> {{{RightLabel}}} {{{rightName}}} {{#Label}}: {{Label}}{{/Label}}
{{/atLeastOneInActiveFolder}}
#Fri Sep 30 14:31:26 CEST 2022
version=0.2.6
#Tue Oct 04 16:43:05 CEST 2022
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