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

Merge branch 'dev' into 'main'

3.0.1

See merge request !13
parents 5e0a3728 2b5428a6
Branches main
No related tags found
1 merge request!133.0.1
Pipeline #15024 passed
Showing
with 923 additions and 899 deletions
...@@ -44,8 +44,8 @@ publish_dev: ...@@ -44,8 +44,8 @@ publish_dev:
script: script:
- "./gradlew setDevVersionForCI" - "./gradlew setDevVersionForCI"
- "./gradlew publish" - "./gradlew publish"
except: only:
- main - dev
publish_main: publish_main:
image: openjdk:11 image: openjdk:11
...@@ -60,7 +60,6 @@ publish_main: ...@@ -60,7 +60,6 @@ publish_main:
ragdoc_build: ragdoc_build:
image: image:
name: "git-st.inf.tu-dresden.de:4567/jastadd/ragdoc-builder" name: "git-st.inf.tu-dresden.de:4567/jastadd/ragdoc-builder"
entrypoint: [""]
stage: ragdoc stage: ragdoc
needs: needs:
- build - build
...@@ -68,6 +67,9 @@ ragdoc_build: ...@@ -68,6 +67,9 @@ ragdoc_build:
- JAVA_FILES=$(find dumpAst.base/src/ -name '*.java') - JAVA_FILES=$(find dumpAst.base/src/ -name '*.java')
- echo $JAVA_FILES | wc -l - echo $JAVA_FILES | wc -l
- /ragdoc-builder/start-builder.sh -excludeGenerated -d data/ $JAVA_FILES - /ragdoc-builder/start-builder.sh -excludeGenerated -d data/ $JAVA_FILES
only:
- dev
- main
artifacts: artifacts:
paths: paths:
- "data/" - "data/"
...@@ -75,7 +77,6 @@ ragdoc_build: ...@@ -75,7 +77,6 @@ ragdoc_build:
ragdoc_view: ragdoc_view:
image: image:
name: "git-st.inf.tu-dresden.de:4567/jastadd/ragdoc-view:relations" name: "git-st.inf.tu-dresden.de:4567/jastadd/ragdoc-view:relations"
entrypoint: [""]
stage: ragdoc stage: ragdoc
needs: needs:
- ragdoc_build - ragdoc_build
...@@ -84,7 +85,7 @@ ragdoc_view: ...@@ -84,7 +85,7 @@ ragdoc_view:
- mkdir -p pages/docs/ragdoc - mkdir -p pages/docs/ragdoc
- OUTPUT_DIR=$(pwd -P)/pages/docs/ragdoc - OUTPUT_DIR=$(pwd -P)/pages/docs/ragdoc
- cd /ragdoc-view/src/ && rm -rf data && ln -s $DATA_DIR - cd /ragdoc-view/src/ && rm -rf data && ln -s $DATA_DIR
- /ragdoc-view/build-view.sh --output-path=$OUTPUT_DIR - BASE_HREF=/dumpAst/ragdoc/ /ragdoc-view/build-view.sh --output-path=$OUTPUT_DIR
only: only:
- dev - dev
- main - main
...@@ -92,7 +93,7 @@ ragdoc_view: ...@@ -92,7 +93,7 @@ ragdoc_view:
paths: paths:
- "pages/docs/ragdoc" - "pages/docs/ragdoc"
pages: build_pages:
image: python:3.10.0-bullseye image: python:3.10.0-bullseye
stage: publish stage: publish
needs: needs:
...@@ -105,5 +106,14 @@ pages: ...@@ -105,5 +106,14 @@ pages:
artifacts: artifacts:
paths: paths:
- public/ - public/
only:
- main pages:
stage: publish
needs:
- build_pages
script: [ "true" ]
artifacts:
paths:
- public
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
LICENSE 0 → 100644
BSD 3-Clause License
Copyright (c) 2022, TU Dresden, Software Technology Group
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...@@ -147,7 +147,7 @@ task newVersion() { ...@@ -147,7 +147,7 @@ task newVersion() {
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)
} }
} }
...@@ -179,6 +179,15 @@ publishing { ...@@ -179,6 +179,15 @@ publishing {
} }
} }
// --- Misc ---
task ensureNoTrainlingNewlineForRelationStyleMustache() {
doFirst {
def text = project.file("src/main/resources/RelationStyle.mustache").text
project.file("src/main/resources/RelationStyle.mustache").write(text.strip())
}
}
// --- Task order --- // --- Task order ---
compileJava.dependsOn ensureNoTrainlingNewlineForRelationStyleMustache
generateAst.dependsOn relast generateAst.dependsOn relast
publish.dependsOn jar publish.dependsOn jar
...@@ -48,29 +48,28 @@ aspect ClassAnalysis { ...@@ -48,29 +48,28 @@ aspect ClassAnalysis {
String tokenName = invokeName(annotation); String tokenName = invokeName(annotation);
if (tokenName.startsWith("_impl_")) { if (tokenName.startsWith("_impl_")) {
String relationName = titleCase(tokenName.substring(6)); String relationName = titleCase(tokenName.substring(6));
try { if (present(getMethod(clazz, "get" + relationName), relationMethod -> {
java.lang.reflect.Method relationMethod = clazz.getMethod("get" + relationName);
// normal get + token-name -> singleRelation // normal get + token-name -> singleRelation
SingleRelationMethod singleRelationMethod = new SingleRelationMethod(); SingleRelationMethod singleRelationMethod = getMethod(clazz, "has" + relationName).isPresent() ?
new OptRelationMethod() : new SingleRelationMethod();
singleRelationMethod.setMethod(relationMethod); singleRelationMethod.setMethod(relationMethod);
singleRelationMethod.setName(relationName); singleRelationMethod.setName(relationName);
result.addOtherMethod(singleRelationMethod); result.addOtherMethod(singleRelationMethod);
})) {
continue; continue;
} catch (NoSuchMethodException e) {
// ignore, but we know this is probably not a single relation
} }
// we know here this is probably not a single or opt relation
// try list-relation next // try list-relation next
try { if (present(getMethod(clazz, "get" + relationName + "List"), relationMethod -> {
java.lang.reflect.Method relationMethod = clazz.getMethod("get" + relationName + "List");
// normal get + token-name + "List" -> listRelation // normal get + token-name + "List" -> listRelation
ListRelationMethod listRelationMethod = new ListRelationMethod(); ListRelationMethod listRelationMethod = new ListRelationMethod();
listRelationMethod.setMethod(relationMethod); listRelationMethod.setMethod(relationMethod);
listRelationMethod.setName(relationName); listRelationMethod.setName(relationName);
result.addOtherMethod(listRelationMethod); result.addOtherMethod(listRelationMethod);
})) {
continue; continue;
} catch (NoSuchMethodException e) {
// ignore, but we know this is probably not a relation at all
} }
// we know here this is probably not a relation at all
} }
IntrinsicTokenMethod tokenMethod = new IntrinsicTokenMethod(); IntrinsicTokenMethod tokenMethod = new IntrinsicTokenMethod();
tokenMethod.setMethod(method); tokenMethod.setMethod(method);
...@@ -201,6 +200,20 @@ aspect ClassAnalysis { ...@@ -201,6 +200,20 @@ aspect ClassAnalysis {
} }
} }
private static java.util.Optional<java.lang.reflect.Method> DumpAst.getMethod(Class<?> clazz, String methodName) {
try {
java.lang.reflect.Method method = clazz.getMethod(methodName);
return java.util.Optional.of(method);
} catch (NoSuchMethodException e) {
return java.util.Optional.empty();
}
}
private static <T> boolean DumpAst.present(java.util.Optional<T> optional, java.util.function.Consumer<T> callback) {
optional.ifPresent(callback);
return optional.isPresent();
}
// --- astNodeAnnotationPrefix --- // --- astNodeAnnotationPrefix ---
syn String DumpAst.astNodeAnnotationPrefix() = getPackageName() + ".ASTNodeAnnotation"; syn String DumpAst.astNodeAnnotationPrefix() = getPackageName() + ".ASTNodeAnnotation";
inh String DumpNode.astNodeAnnotationPrefix(); inh String DumpNode.astNodeAnnotationPrefix();
......
...@@ -5,26 +5,26 @@ DumpNode ::= DumpChildNode* DumpToken* DumpRelation* ...@@ -5,26 +5,26 @@ DumpNode ::= DumpChildNode* DumpToken* DumpRelation*
<Name> <Label> <BackgroundColor> <TextColor> <Object:Object> <Invisible:boolean> <Computed:boolean> <ManualStereotypes> <Name> <Label> <BackgroundColor> <TextColor> <Object:Object> <Invisible:boolean> <Computed:boolean> <ManualStereotypes>
/InvisiblePath/ ; /InvisiblePath/ ;
InnerDumpNode ; InnerDumpNode ::= <OriginalIndex:int> <Label> <LineColor> <TextColor> ; //TODO remove colors (and label?)
rel InnerDumpNode.DumpNode <-> DumpNode.ContainerOfInner ; rel InnerDumpNode.DumpNode <-> DumpNode.ContainerOfInner? ;
InnerRelationDumpNode; InnerRelationDumpNode ::= <OriginalIndex:int> <Label> <LineColor> <TextColor> ; //TODO remove colors (and label?)
rel InnerRelationDumpNode.DumpNode -> DumpNode ; // .ContainerOfInner* rel InnerRelationDumpNode.DumpNode <-> DumpNode.ContainerOfRelationInner* ;
abstract DumpChildNode ::= <Name> <Computed:boolean> ; abstract DumpChildNode ::= <Label> <Computed:boolean> <LineColor> <TextColor> ;
DumpNormalChildNode : DumpChildNode ; DumpNormalChildNode : DumpChildNode ::= ;
rel DumpNormalChildNode.DumpNode <-> DumpNode.ContainerOfNormalChild ; rel DumpNormalChildNode.DumpNode <-> DumpNode.ContainerOfNormalChild? ;
DumpListChildNode : DumpChildNode ::= InnerDumpNode* ; DumpListChildNode : DumpChildNode ::= InnerDumpNode* <Name> ;
abstract DumpToken ::= <Name> <Computed:boolean> ; abstract DumpToken ::= <Label> <Computed:boolean> ;
DumpReferenceToken : DumpToken ; DumpReferenceToken : DumpToken ::= <LineColor> <TextColor> ;
rel DumpReferenceToken.Value -> DumpNode ; rel DumpReferenceToken.DumpNode -> DumpNode ;
DumpReferenceListToken : DumpToken ::= InnerRelationDumpNode* ; DumpReferenceListToken : DumpToken ::= InnerRelationDumpNode* <Name> <LineColor> <TextColor> ;
DumpValueToken : DumpToken ::= <Value:Object> ; DumpValueToken : DumpToken ::= <Value:Object> ;
abstract DumpRelation ::= <Name> <Bidirectional:boolean> ; abstract DumpRelation ::= <Label> <Bidirectional:boolean> <LineColor> <TextColor> ;
DumpNormalRelation : DumpRelation ; DumpNormalRelation : DumpRelation ::= ;
rel DumpNormalRelation.DumpNode -> DumpNode ; rel DumpNormalRelation.DumpNode -> DumpNode ;
DumpListRelation : DumpRelation ::= InnerRelationDumpNode* ; DumpListRelation : DumpRelation ::= InnerRelationDumpNode* <Name> ;
// type of NTA // type of NTA
InvisiblePath ::= InnerRelationDumpNode* ; InvisiblePath ::= InnerRelationDumpNode* ;
...@@ -45,6 +45,7 @@ NormalListChildMethod : ListChildMethod ; ...@@ -45,6 +45,7 @@ NormalListChildMethod : ListChildMethod ;
NTAListChildMethod : ListChildMethod ; NTAListChildMethod : ListChildMethod ;
SingleRelationMethod : AnalysedMethod ; SingleRelationMethod : AnalysedMethod ;
OptRelationMethod : SingleRelationMethod ;
ListRelationMethod : AnalysedMethod ; ListRelationMethod : AnalysedMethod ;
// TODO can the refine bug also happen for refined attributes? // TODO can the refine bug also happen for refined attributes?
...@@ -53,9 +54,6 @@ IntrinsicTokenMethod : TokenMethod ::= <Refined:boolean> ; ...@@ -53,9 +54,6 @@ IntrinsicTokenMethod : TokenMethod ::= <Refined:boolean> ;
AttributeMethod : TokenMethod ; AttributeMethod : TokenMethod ;
BuildConfig ::= StyleInformation BuildConfig ::= StyleInformation
GlobalPatternCollection:PatternCollection
ExcludeTypePattern:TypePatternCollectionMapping*
IncludeTypePattern:TypePatternCollectionMapping*
<IncludeRelationMethod:IncludeRelationMethod> <IncludeRelationMethod:IncludeRelationMethod>
<IncludeChildMethod:IncludeChildMethod> <IncludeChildMethod:IncludeChildMethod>
<IncludeAttributeMethod:IncludeAttributeMethod> <IncludeAttributeMethod:IncludeAttributeMethod>
...@@ -64,13 +62,16 @@ BuildConfig ::= StyleInformation ...@@ -64,13 +62,16 @@ BuildConfig ::= StyleInformation
<IncludeEmptyString:boolean> <IncludeEmptyString:boolean>
<ExcludeNullNodes:boolean> <ExcludeNullNodes:boolean>
<Debug:boolean>; <Debug:boolean>;
TypePatternCollectionMapping ::= <TypeRegex> PatternCollection ; StyleInformation ::= <ComputedColor>;
PatternCollection ::= <TokenPattern> <ChildPattern> <RelationPattern> <AttributePattern> <NonterminalAttributePattern> ;
StyleInformation ::= <NameMethod:StyleMethod> <BackgroundColorMethod:StyleMethod> <TextColorMethod:StyleMethod> <StereotypeMethod:StyleMethod> <ComputedColor>;
PrintConfig ::= Header* PrintConfig ::= Header*
<Scale:double> <Scale:double>
<Version> <Version>
<RelationWithRank:boolean> <RelationWithRank:boolean>
<OrderChildren:boolean> ; <OrderChildren:boolean>
<NodeStyleDefinition:NodeStyleDefinition>
<RelationStyleDefinition:RelationStyleDefinition>;
Header ::= <Value> ; Header ::= <Value> ;
NodeStyle ::= <Label> <BackgroundColor> <TextColor> <StereoTypes> ;
RelationStyle ::= <Label> <LineColor> <TextColor> ;
aspect Frontend { aspect Frontend {
// --- match{In,Ex}cludePatternCollection ---
syn PatternCollection BuildConfig.matchIncludePatternCollection(String typeName) {
for (TypePatternCollectionMapping mapping : getIncludeTypePatternList()) {
if (matches(mapping.typePattern(), typeName)) {
return mapping.getPatternCollection();
}
}
return null;
}
syn PatternCollection BuildConfig.matchExcludePatternCollection(String typeName) {
for (TypePatternCollectionMapping mapping : getExcludeTypePatternList()) {
if (matches(mapping.typePattern(), typeName)) {
return mapping.getPatternCollection();
}
}
return null;
}
static StyleInformation StyleInformation.createDefault() { static StyleInformation StyleInformation.createDefault() {
StyleInformation result = new StyleInformation(); StyleInformation result = new StyleInformation();
result.setNameMethod(n -> n == null ? "null" : n.getClass().getSimpleName() + "@" + Integer.toHexString(n.hashCode()));
result.setBackgroundColorMethod(n -> "");
result.setTextColorMethod(n -> "");
result.setStereotypeMethod(n -> "");
result.setComputedColor("blue"); result.setComputedColor("blue");
return result; return result;
} }
@FunctionalInterface @FunctionalInterface
public interface StyleMethod<ASTNODE> { public interface NodeStyleDefinition<ASTNODE> {
String get(ASTNODE node); void style(ASTNODE node, NodeStyle style);
}
@FunctionalInterface
public interface RelationStyleDefinition<ASTNODE> {
void style(ASTNODE source, ASTNODE target, boolean isComputed, boolean isContainment, RelationStyle style);
}
public void NodeStyle.useSimpleLabel() {
setLabel(node.getObject() == null ? "null" : node.getObject().getClass().getSimpleName());
}
public void NodeStyle.useSimpleLabelWithHashCode() {
setLabel(node.getObject() == null ? "null" :
node.getObject().getClass().getSimpleName() + "@" + Integer.toHexString(node.getObject().hashCode()));
} }
@FunctionalInterface @FunctionalInterface
......
...@@ -36,6 +36,12 @@ aspect Navigation { ...@@ -36,6 +36,12 @@ aspect Navigation {
syn boolean AnalysedMethod.isSingleRelationMethod() = false; syn boolean AnalysedMethod.isSingleRelationMethod() = false;
eq SingleRelationMethod.isSingleRelationMethod() = true; eq SingleRelationMethod.isSingleRelationMethod() = true;
/** Tests if SingleRelationMethod is a OptRelationMethod.
* @return 'true' if this is a OptRelationMethod, otherwise 'false'
*/
syn boolean SingleRelationMethod.isOptRelationMethod() = false;
eq OptRelationMethod.isOptRelationMethod() = true;
/** Tests if AnalysedMethod is a ListRelationMethod. /** Tests if AnalysedMethod is a ListRelationMethod.
* @return 'true' if this is a ListRelationMethod, otherwise 'false' * @return 'true' if this is a ListRelationMethod, otherwise 'false'
*/ */
...@@ -102,6 +108,12 @@ aspect Navigation { ...@@ -102,6 +108,12 @@ aspect Navigation {
syn boolean DumpToken.isDumpReferenceToken() = false; syn boolean DumpToken.isDumpReferenceToken() = false;
eq DumpReferenceToken.isDumpReferenceToken() = true; eq DumpReferenceToken.isDumpReferenceToken() = true;
/** Tests if DumpToken is a DumpReferenceListToken.
* @return 'true' if this is a DumpReferenceListToken, otherwise 'false'
*/
syn boolean DumpToken.isDumpReferenceListToken() = false;
eq DumpReferenceListToken.isDumpReferenceListToken() = true;
/** Tests if DumpToken is a DumpValueToken. /** Tests if DumpToken is a DumpValueToken.
* @return 'true' if this is a DumpValueToken, otherwise 'false' * @return 'true' if this is a DumpValueToken, otherwise 'false'
*/ */
...@@ -227,6 +239,13 @@ aspect Navigation { ...@@ -227,6 +239,13 @@ aspect Navigation {
eq DumpToken.asDumpReferenceToken() = null; eq DumpToken.asDumpReferenceToken() = null;
eq DumpReferenceToken.asDumpReferenceToken() = this; eq DumpReferenceToken.asDumpReferenceToken() = this;
/** casts a DumpToken into a DumpReferenceListToken if possible.
* @return 'this' cast to a DumpReferenceListToken or 'null'
*/
syn DumpReferenceListToken DumpToken.asDumpReferenceListToken();
eq DumpToken.asDumpReferenceListToken() = null;
eq DumpReferenceListToken.asDumpReferenceListToken() = this;
/** casts a DumpToken into a DumpValueToken if possible. /** casts a DumpToken into a DumpValueToken if possible.
* @return 'this' cast to a DumpValueToken or 'null' * @return 'this' cast to a DumpValueToken or 'null'
*/ */
......
...@@ -10,6 +10,11 @@ aspect Navigation { ...@@ -10,6 +10,11 @@ aspect Navigation {
// --- buildConfig --- // --- buildConfig ---
inh BuildConfig DumpNode.buildConfig(); inh BuildConfig DumpNode.buildConfig();
inh BuildConfig PrintConfig.buildConfig(); inh BuildConfig PrintConfig.buildConfig();
inh BuildConfig InnerDumpNode.buildConfig();
inh BuildConfig InnerRelationDumpNode.buildConfig();
inh BuildConfig DumpChildNode.buildConfig();
inh BuildConfig DumpRelation.buildConfig();
inh BuildConfig DumpToken.buildConfig();
eq DumpAst.getChild().buildConfig() = getBuildConfig(); eq DumpAst.getChild().buildConfig() = getBuildConfig();
// --- printConfig --- // --- printConfig ---
...@@ -25,11 +30,23 @@ aspect Navigation { ...@@ -25,11 +30,23 @@ aspect Navigation {
inh DumpNode InnerRelationDumpNode.containingDumpNode(); inh DumpNode InnerRelationDumpNode.containingDumpNode();
inh DumpNode DumpChildNode.containingDumpNode(); inh DumpNode DumpChildNode.containingDumpNode();
inh DumpNode DumpRelation.containingDumpNode(); inh DumpNode DumpRelation.containingDumpNode();
inh DumpNode DumpReferenceToken.containingDumpNode();
inh DumpNode DumpReferenceListToken.containingDumpNode();
eq DumpNode.getDumpChildNode().containingDumpNode() = this; eq DumpNode.getDumpChildNode().containingDumpNode() = this;
eq DumpNode.getDumpRelation().containingDumpNode() = this; eq DumpNode.getDumpRelation().containingDumpNode() = this;
eq DumpNode.getDumpToken().containingDumpNode() = this; eq DumpNode.getDumpToken().containingDumpNode() = this;
eq DumpNode.getInvisiblePath().containingDumpNode() = this; eq DumpNode.getInvisiblePath().containingDumpNode() = this;
// --- containingDumpListChildNode ---
inh DumpListChildNode InnerDumpNode.containingDumpListChildNode();
eq DumpListChildNode.getInnerDumpNode().containingDumpListChildNode() = this;
// --- containingDumpListRelation ---
inh DumpListRelation InnerRelationDumpNode.containingDumpListRelation();
eq DumpListRelation.getInnerRelationDumpNode().containingDumpListRelation() = this;
eq DumpReferenceListToken.getInnerRelationDumpNode().containingDumpListRelation() = null;
eq InvisiblePath.getInnerRelationDumpNode().containingDumpListRelation() = null;
// --- container --- // --- container ---
syn DumpNode DumpNode.container() { syn DumpNode DumpNode.container() {
if (getContainerOfNormalChild() != null) { if (getContainerOfNormalChild() != null) {
...@@ -85,10 +102,10 @@ aspect Navigation { ...@@ -85,10 +102,10 @@ aspect Navigation {
return result; return result;
} }
// --- innerNotNull --- // --- innerNotNullOrEmpty ---
syn boolean DumpNormalRelation.innerNotNull() = !printConfig().getRelationWithRank() && getDumpNode() != null && getDumpNode().getObject() != null; syn boolean DumpNormalRelation.innerNotNullOrEmpty() = !printConfig().getRelationWithRank() && getDumpNode() != null && getDumpNode().getObject() != null && getDumpNode().getObject() != DumpAst.EMPTY;
syn boolean DumpReferenceToken.innerNotNull() = !printConfig().getRelationWithRank() && getValue() != null && getValue().getObject() != null; syn boolean DumpReferenceToken.innerNotNullOrEmpty() = !printConfig().getRelationWithRank() && getDumpNode() != null && getDumpNode().getObject() != null && getDumpNode().getObject() != DumpAst.EMPTY;
syn boolean InnerRelationDumpNode.innerNotNull() = !printConfig().getRelationWithRank() && getDumpNode() != null && getDumpNode().getObject() != null; syn boolean InnerRelationDumpNode.innerNotNullOrEmpty() = !printConfig().getRelationWithRank() && getDumpNode() != null && getDumpNode().getObject() != null && getDumpNode().getObject() != DumpAst.EMPTY;
// === Method naviagtion === // === Method naviagtion ===
coll java.util.List<SingleChildMethod> ClassAnalysisResult.singleChildMethods() [new java.util.ArrayList<>()] root ClassAnalysisResult; coll java.util.List<SingleChildMethod> ClassAnalysisResult.singleChildMethods() [new java.util.ArrayList<>()] root ClassAnalysisResult;
......
aspect Printing { aspect Printing {
// --- outerNodeName ---
inh String InnerDumpNode.outerNodeName();
inh String InnerRelationDumpNode.outerNodeName();
inh String DumpChildNode.outerNodeName();
inh String DumpRelation.outerNodeName();
inh String DumpToken.outerNodeName();
inh String DumpReferenceToken.outerNodeName();
eq DumpNode.getChild().outerNodeName() = name();
// --- innerNodeName ---
syn String InnerDumpNode.innerNodeName() = getDumpNode() != null ? getDumpNode().name() : null;
syn String InnerRelationDumpNode.innerNodeName() = getDumpNode() != null ? getDumpNode().name() : null;
syn String DumpNormalChildNode.innerNodeName() = getDumpNode() != null ? getDumpNode().name() : null;
syn String DumpNormalRelation.innerNodeName() = getDumpNode() != null ? getDumpNode().name() : null;
syn String DumpReferenceToken.innerNodeName() = getValue().name();
// --- name --- // --- name ---
syn String DumpNode.name() = getName(); // might change in the future syn String DumpNode.name() = getName(); // might change in the future
// --- label ---
syn String DumpChildNode.label() = getName() + (getComputed() ? "()" : "");
syn String DumpRelation.label() = getName();
syn String DumpToken.label() = getName() + (getComputed() ? "()" : "");
syn String DumpNode.label() = getLabel();
inh String InnerDumpNode.label();
inh String InnerRelationDumpNode.label();
eq DumpListChildNode.getInnerDumpNode(int index).label() = label() + "[" + index + "]";
eq DumpListRelation.getInnerRelationDumpNode(int index).label() = label() + "[" + index + "]";
eq DumpReferenceListToken.getInnerRelationDumpNode(int index).label() = label() + "[" + index + "]";
eq InvisiblePath.getInnerRelationDumpNode(int index).label() = null;
// --- bothVisible ---
boolean ASTNode.bothVisible(DumpNode one, DumpNode two) {
return one != null && two != null && !one.getInvisible() && !two.getInvisible();
}
syn boolean InnerDumpNode.bothVisible() = bothVisible(containingDumpNode(), getDumpNode());
syn boolean InnerRelationDumpNode.bothVisible() = bothVisible(containingDumpNode(), getDumpNode());
syn boolean DumpNormalChildNode.bothVisible() = bothVisible(containingDumpNode(), getDumpNode());
syn boolean DumpNormalRelation.bothVisible() = bothVisible(containingDumpNode(), getDumpNode());
} }
aspect Debugging { aspect Debugging {
......
...@@ -8,6 +8,11 @@ aspect TemplateContext { ...@@ -8,6 +8,11 @@ aspect TemplateContext {
return getObject() == null; return getObject() == null;
} }
// --- isEmpty ---
syn boolean DumpNode.isEmpty() {
return getObject() == DumpAst.EMPTY;
}
// --- isAstNode --- // --- isAstNode ---
syn boolean DumpNode.isAstNode() { syn boolean DumpNode.isAstNode() {
if (getObject() == null) { if (getObject() == null) {
...@@ -22,11 +27,63 @@ aspect TemplateContext { ...@@ -22,11 +27,63 @@ aspect TemplateContext {
return false; return false;
} }
// --- outerNodeName ---
inh String InnerDumpNode.outerNodeName();
inh String InnerRelationDumpNode.outerNodeName();
inh String DumpChildNode.outerNodeName();
inh String DumpRelation.outerNodeName();
inh String DumpToken.outerNodeName();
inh String DumpReferenceToken.outerNodeName();
eq DumpNode.getChild().outerNodeName() = name();
// --- innerNodeName ---
syn String InnerDumpNode.innerNodeName() = getDumpNode() != null ? getDumpNode().name() : null;
syn String InnerRelationDumpNode.innerNodeName() = getDumpNode() != null ? getDumpNode().name() : null;
syn String DumpNormalChildNode.innerNodeName() = getDumpNode() != null ? getDumpNode().name() : null;
syn String DumpNormalRelation.innerNodeName() = getDumpNode() != null ? getDumpNode().name() : null;
syn String DumpReferenceToken.innerNodeName() = getDumpNode().name();
// --- label ---
syn String DumpChildNode.label() = safeLabel(getLabel() + (getComputed() ? "()" : ""));
syn String DumpRelation.label() = safeLabel(getLabel());
syn String DumpToken.label() = safeLabel(getLabel() + (getComputed() ? "()" : ""));
syn String DumpNode.label() = safeLabel(getLabel());
inh String InnerDumpNode.label();
inh String InnerRelationDumpNode.label();
eq DumpListChildNode.getInnerDumpNode(int index).label() {
InnerDumpNode inner = getInnerDumpNode(index);
return safeLabel(
(inner.getDumpNode().isEmpty() ? "" : "[" + chooseIndex(inner.getOriginalIndex(), index) + "]"));
}
eq DumpListRelation.getInnerRelationDumpNode(int index).label() {
InnerRelationDumpNode inner = getInnerRelationDumpNode(index);
return safeLabel(inner.getLabel() +
(inner.getDumpNode().isEmpty() ? "" : "[" + chooseIndex(inner.getOriginalIndex(), index) + "]"));
}
eq DumpReferenceListToken.getInnerRelationDumpNode(int index).label() = "[" + index + "]";
eq InvisiblePath.getInnerRelationDumpNode(int index).label() = null;
protected int ASTNode.chooseIndex(int originalIndex, int inheritedIndex) {
return originalIndex != 0 ? originalIndex : inheritedIndex;
}
static String ASTNode.safeLabel(String s) {
return s.isEmpty() ? " " : s;
}
// --- bothVisible ---
boolean ASTNode.bothVisible(DumpNode one, DumpNode two) {
return one != null && two != null && !one.getInvisible() && !two.getInvisible();
}
syn boolean InnerDumpNode.bothVisible() = bothVisible(containingDumpNode(), getDumpNode());
syn boolean InnerRelationDumpNode.bothVisible() = bothVisible(containingDumpNode(), getDumpNode());
syn boolean DumpNormalChildNode.bothVisible() = bothVisible(containingDumpNode(), getDumpNode());
syn boolean DumpNormalRelation.bothVisible() = bothVisible(containingDumpNode(), getDumpNode());
// --- NTA: InvisiblePath --- // --- NTA: InvisiblePath ---
syn InvisiblePath DumpNode.getInvisiblePath() { syn InvisiblePath DumpNode.getInvisiblePath() {
InvisiblePath result = new InvisiblePath(); InvisiblePath result = new InvisiblePath();
for (DumpNode successor : reachableThroughInvisible()) { for (DumpNode successor : reachableThroughInvisible()) {
result.addInnerRelationDumpNode(new InnerRelationDumpNode(successor)); result.addInnerRelationDumpNode(new InnerRelationDumpNode().setDumpNode(successor));
} }
return result; return result;
} }
...@@ -49,9 +106,9 @@ aspect TemplateContext { ...@@ -49,9 +106,9 @@ aspect TemplateContext {
// --- labelAndTextColor --- // --- labelAndTextColor ---
syn String DumpNode.labelAndTextColor() { syn String DumpNode.labelAndTextColor() {
if (getTextColor().isEmpty()) { if (getTextColor().isEmpty()) {
return getLabel(); return label();
} else { } else {
return "<color:" + getTextColor() + ">" + getLabel() + "</color>"; return "<color:" + getTextColor() + ">" + label() + "</color>";
} }
} }
......
...@@ -32,9 +32,9 @@ aspect ToYaml { ...@@ -32,9 +32,9 @@ aspect ToYaml {
addYamledList(result, "Headers", getHeaderList(), fromRelation); addYamledList(result, "Headers", getHeaderList(), fromRelation);
// tokens // tokens
result.put("scale", getScale()); result.put("OrderChildren", getOrderChildren());
result.put("version", getVersion()); result.put("Scale", getScale());
result.put("orderChildren", getOrderChildren()); result.put("Version", getVersion());
// attributes // attributes
result.put("debug", debug()); result.put("debug", debug());
...@@ -44,7 +44,7 @@ aspect ToYaml { ...@@ -44,7 +44,7 @@ aspect ToYaml {
syn MappingElement Header.toYaml(boolean fromRelation) { syn MappingElement Header.toYaml(boolean fromRelation) {
MappingElement result = new MappingElement(); MappingElement result = new MappingElement();
// tokens // tokens
result.put("value", getValue()); result.put("Value", getValue());
return result; return result;
} }
...@@ -59,19 +59,19 @@ aspect ToYaml { ...@@ -59,19 +59,19 @@ aspect ToYaml {
} }
// tokens // tokens
result.put("name", getName()); result.put("Name", getName());
if (!fromRelation) { if (!fromRelation) {
result.put("computed", getComputed()); result.put("BackgroundColor", getBackgroundColor());
result.put("label", getLabel()); result.put("Invisible", getInvisible());
result.put("backgroundColor", getBackgroundColor()); result.put("TextColor", getTextColor());
result.put("textColor", getTextColor());
result.put("invisible", getInvisible());
} }
// attributes // attributes
if (!fromRelation) { if (!fromRelation) {
result.put("isNull", isNull()); result.put("isNull", isNull());
result.put("isEmpty", isEmpty());
result.put("isAstNode", isAstNode()); result.put("isAstNode", isAstNode());
result.put("label", label());
result.put("labelAndTextColor", labelAndTextColor()); result.put("labelAndTextColor", labelAndTextColor());
result.put("stereotypeList", stereotypeList()); result.put("stereotypeList", stereotypeList());
addYamledList(result, "myChildren", myChildren(), true); addYamledList(result, "myChildren", myChildren(), true);
...@@ -88,12 +88,15 @@ aspect ToYaml { ...@@ -88,12 +88,15 @@ aspect ToYaml {
syn MappingElement DumpChildNode.toYaml(boolean fromRelation) { syn MappingElement DumpChildNode.toYaml(boolean fromRelation) {
MappingElement result = new MappingElement(); MappingElement result = new MappingElement();
// tokens // tokens
result.put("name", getName()); result.put("LineColor", getLineColor());
result.put("computed", getComputed()); result.put("TextColor", getTextColor());
// attributes // attributes
result.put("label", label());
result.put("isList", isList()); result.put("isList", isList());
result.put("label", label());
result.put("needRelationStyling", needRelationStyling());
result.put("outerNodeName", outerNodeName()); result.put("outerNodeName", outerNodeName());
return result; return result;
...@@ -101,6 +104,7 @@ aspect ToYaml { ...@@ -101,6 +104,7 @@ aspect ToYaml {
syn MappingElement DumpNormalChildNode.toYaml(boolean fromRelation) { syn MappingElement DumpNormalChildNode.toYaml(boolean fromRelation) {
MappingElement result = super.toYaml(fromRelation); MappingElement result = super.toYaml(fromRelation);
// attributes // attributes
result.put("bothVisible", bothVisible()); result.put("bothVisible", bothVisible());
result.put("innerNodeName", innerNodeName()); result.put("innerNodeName", innerNodeName());
...@@ -109,6 +113,10 @@ aspect ToYaml { ...@@ -109,6 +113,10 @@ aspect ToYaml {
syn MappingElement DumpListChildNode.toYaml(boolean fromRelation) { syn MappingElement DumpListChildNode.toYaml(boolean fromRelation) {
MappingElement result = super.toYaml(fromRelation); MappingElement result = super.toYaml(fromRelation);
// tokens
result.put("Name", getName());
// children // children
addYamledList(result, "InnerDumpNodes", getInnerDumpNodeList(), fromRelation); addYamledList(result, "InnerDumpNodes", getInnerDumpNodeList(), fromRelation);
return result; return result;
...@@ -116,28 +124,33 @@ aspect ToYaml { ...@@ -116,28 +124,33 @@ aspect ToYaml {
syn MappingElement DumpToken.toYaml(boolean fromRelation) { syn MappingElement DumpToken.toYaml(boolean fromRelation) {
MappingElement result = new MappingElement(); MappingElement result = new MappingElement();
// tokens
result.put("name", getName());
result.put("computed", getComputed());
// attributes // attributes
result.put("isDumpValueToken", isDumpValueToken());
result.put("isList", isList()); result.put("isList", isList());
result.put("label", label()); result.put("label", label());
result.put("isDumpValueToken", isDumpValueToken());
return result; return result;
} }
syn MappingElement DumpValueToken.toYaml(boolean fromRelation) { syn MappingElement DumpValueToken.toYaml(boolean fromRelation) {
MappingElement result = super.toYaml(fromRelation); MappingElement result = super.toYaml(fromRelation);
// tokens // tokens
result.put("value", getValue().toString()); result.put("Value", getValue().toString());
return result; return result;
} }
syn MappingElement DumpReferenceToken.toYaml(boolean fromRelation) { syn MappingElement DumpReferenceToken.toYaml(boolean fromRelation) {
MappingElement result = super.toYaml(fromRelation); MappingElement result = super.toYaml(fromRelation);
// tokens
result.put("LineColor", getLineColor());
result.put("TextColor", getTextColor());
// attributes // attributes
result.put("innerNodeName", innerNodeName()); result.put("innerNodeName", innerNodeName());
result.put("innerNotNull", innerNotNull()); result.put("innerNotNullOrEmpty", innerNotNullOrEmpty());
result.put("needRelationStyling", needRelationStyling());
result.put("outerNodeName", outerNodeName()); result.put("outerNodeName", outerNodeName());
return result; return result;
} }
...@@ -145,37 +158,52 @@ aspect ToYaml { ...@@ -145,37 +158,52 @@ aspect ToYaml {
syn MappingElement DumpReferenceListToken.toYaml(boolean fromRelation) { syn MappingElement DumpReferenceListToken.toYaml(boolean fromRelation) {
MappingElement result = super.toYaml(fromRelation); MappingElement result = super.toYaml(fromRelation);
// tokens
result.put("Name", getName());
result.put("LineColor", getLineColor());
result.put("TextColor", getTextColor());
// children // children
addYamledList(result, "InnerRelationDumpNode", getInnerRelationDumpNodeList(), fromRelation); addYamledList(result, "InnerRelationDumpNode", getInnerRelationDumpNodeList(), fromRelation);
// attributes // attributes
result.put("needRelationStyling", needRelationStyling());
result.put("outerNodeName", outerNodeName()); result.put("outerNodeName", outerNodeName());
return result; return result;
} }
syn MappingElement DumpRelation.toYaml(boolean fromRelation) { syn MappingElement DumpRelation.toYaml(boolean fromRelation) {
MappingElement result = new MappingElement(); MappingElement result = new MappingElement();
// tokens // tokens
result.put("name", getName()); result.put("Bidirectional", getBidirectional());
result.put("bidirectional", getBidirectional()); result.put("LineColor", getLineColor());
result.put("TextColor", getTextColor());
// attributes // attributes
result.put("isList", isList()); result.put("isList", isList());
result.put("label", label()); result.put("label", label());
result.put("needRelationStyling", needRelationStyling());
result.put("outerNodeName", outerNodeName()); result.put("outerNodeName", outerNodeName());
return result; return result;
} }
syn MappingElement DumpNormalRelation.toYaml(boolean fromRelation) { syn MappingElement DumpNormalRelation.toYaml(boolean fromRelation) {
MappingElement result = super.toYaml(fromRelation); MappingElement result = super.toYaml(fromRelation);
// attributes // attributes
result.put("bothVisible", bothVisible()); result.put("bothVisible", bothVisible());
result.put("innerNodeName", innerNodeName()); result.put("innerNodeName", innerNodeName());
result.put("innerNotNull", innerNotNull()); result.put("innerNotNullOrEmpty", innerNotNullOrEmpty());
return result; return result;
} }
syn MappingElement DumpListRelation.toYaml(boolean fromRelation) { syn MappingElement DumpListRelation.toYaml(boolean fromRelation) {
MappingElement result = super.toYaml(fromRelation); MappingElement result = super.toYaml(fromRelation);
// tokens
result.put("Name", getName());
// children // children
addYamledList(result, "InnerRelationDumpNode", getInnerRelationDumpNodeList(), fromRelation); addYamledList(result, "InnerRelationDumpNode", getInnerRelationDumpNodeList(), fromRelation);
return result; return result;
...@@ -183,27 +211,40 @@ aspect ToYaml { ...@@ -183,27 +211,40 @@ aspect ToYaml {
syn MappingElement InnerDumpNode.toYaml(boolean fromRelation) { syn MappingElement InnerDumpNode.toYaml(boolean fromRelation) {
MappingElement result = new MappingElement(); MappingElement result = new MappingElement();
// tokens
result.put("LineColor", getLineColor());
result.put("TextColor", getTextColor());
// attributes // attributes
result.put("bothVisible", bothVisible()); result.put("bothVisible", bothVisible());
result.put("innerNodeName", innerNodeName()); result.put("innerNodeName", innerNodeName());
result.put("outerNodeName", outerNodeName());
result.put("label", label()); result.put("label", label());
result.put("needRelationStyling", needRelationStyling());
result.put("outerNodeName", outerNodeName());
return result; return result;
} }
syn MappingElement InnerRelationDumpNode.toYaml(boolean fromRelation) { syn MappingElement InnerRelationDumpNode.toYaml(boolean fromRelation) {
MappingElement result = new MappingElement(); MappingElement result = new MappingElement();
// tokens
result.put("LineColor", getLineColor());
result.put("TextColor", getTextColor());
// attributes // attributes
result.put("bothVisible", bothVisible()); result.put("bothVisible", bothVisible());
result.put("innerNodeName", innerNodeName()); result.put("innerNodeName", innerNodeName());
result.put("innerNotNull", innerNotNull()); result.put("innerNotNullOrEmpty", innerNotNullOrEmpty());
result.put("outerNodeName", outerNodeName());
result.put("label", label()); result.put("label", label());
result.put("needRelationStyling", needRelationStyling());
result.put("outerNodeName", outerNodeName());
return result; return result;
} }
syn MappingElement InvisiblePath.toYaml(boolean fromRelation) { syn MappingElement InvisiblePath.toYaml(boolean fromRelation) {
MappingElement result = super.toYaml(fromRelation); MappingElement result = super.toYaml(fromRelation);
// children // children
addYamledList(result, "InnerRelationDumpNode", getInnerRelationDumpNodeList(), fromRelation); addYamledList(result, "InnerRelationDumpNode", getInnerRelationDumpNodeList(), fromRelation);
return result; return result;
...@@ -237,7 +278,7 @@ aspect ToYaml { ...@@ -237,7 +278,7 @@ aspect ToYaml {
if (value == null || value.equals("null")) { if (value == null || value.equals("null")) {
return StringElement.of("null"); return StringElement.of("null");
} }
if (value.isEmpty()) { if (value.isBlank()) {
return StringElement.of(value); return StringElement.of(value);
} }
return containsAny(value, ",#[{\"\n") ? return containsAny(value, ",#[{\"\n") ?
......
This diff is collapsed.
// more stuff from Transform that is not correctly handled by the IntelliJ plugin
aspect Transform {
interface RelationStyleDefinable {
default RelationStyle createDefaultStyle() {
return new RelationStyle()
.setLabel(initialLabel())
.setLineColor(isComputed() ? buildConfig().getStyleInformation().getComputedColor() : "")
.setTextColor(isComputed() ? buildConfig().getStyleInformation().getComputedColor() : "");
}
default RelationStyle getStyle(RelationStyleDefinition relationStyleDefinition) {
RelationStyle style = createDefaultStyle();
relationStyleDefinition.style(containingDumpNode().getObject(),
getDumpNode() != null ? getDumpNode().getObject() : null,
isComputed(), isContainment(), style);
return style;
}
}
interface RelationStylable<SELF> {
default boolean needRelationStyling() {
return !getLineColor().isEmpty() || !getTextColor().isEmpty();
}
default void applyStyle(RelationStyle style) {
setLabel(style.getLabel());
setTextColor(style.getTextColor());
setLineColor(style.getLineColor());
}
}
private <T extends RelationStyleDefinable & RelationStylable<?>> RelationStyle DumpAst.applyStyle(T styleDefinable) {
RelationStyle result = styleDefinable.getStyle(getPrintConfig().getRelationStyleDefinition());
styleDefinable.applyStyle(result);
return result;
}
}
aspect Util { aspect Util {
// --- find{In,Ex}cludePatternCollection ---
syn PatternCollection BuildConfig.findIncludePatternCollection(String typeRegex) {
for (TypePatternCollectionMapping mapping : getIncludeTypePatternList()) {
if (mapping.getTypeRegex().equals(typeRegex)) {
return mapping.getPatternCollection();
}
}
return null;
}
syn PatternCollection BuildConfig.findExcludePatternCollection(String typeRegex) {
for (TypePatternCollectionMapping mapping : getExcludeTypePatternList()) {
if (mapping.getTypeRegex().equals(typeRegex)) {
return mapping.getPatternCollection();
}
}
return null;
}
private String DumpAst.titleCase(String s) { private String DumpAst.titleCase(String s) {
if (s.isEmpty()) { if (s.isEmpty()) {
return s; return s;
......
{{#TextColor}}#text:{{{TextColor}}}{{/TextColor}}{{#LineColor}}{{#TextColor}};{{/TextColor}}{{^TextColor}}#{{/TextColor}}line:{{{LineColor}}}{{/LineColor}}
\ No newline at end of file
...@@ -11,57 +11,64 @@ skinparam object<<NTA>> { ...@@ -11,57 +11,64 @@ skinparam object<<NTA>> {
hide <<NTA>> stereotype hide <<NTA>> stereotype
{{#PrintConfig}} {{#PrintConfig}}
scale {{{scale}}} scale {{{Scale}}}
{{#Headers}} {{#Headers}}
{{{value}}} {{{Value}}}
{{/Headers}} {{/Headers}}
{{/PrintConfig}} {{/PrintConfig}}
{{#DumpNodes}} {{#DumpNodes}}
{{^invisible}} {{^Invisible}}
{{#isNull}} {{#isNull}}
object "null" as {{{name}}}<<null>> object "null" as {{{Name}}}<<null>>
{{/isNull}} {{/isNull}}
{{#isEmpty}}
object "[]" as {{{Name}}}<<null>>
{{/isEmpty}}
{{#isAstNode}} {{#isAstNode}}
object "{{{labelAndTextColor}}}" as {{{name}}} {{{stereotypeList}}} {{#backgroundColor}}#{{{backgroundColor}}}{{/backgroundColor}} { object "{{{labelAndTextColor}}}" as {{{Name}}} {{{stereotypeList}}} {{#BackgroundColor}}#{{{BackgroundColor}}}{{/BackgroundColor}} {
{{#DumpTokens}} {{#DumpTokens}}
{{#isDumpValueToken}} {{#isDumpValueToken}}
{{{label}}} = {{{value}}} {{{label}}} = {{{Value}}}
{{/isDumpValueToken}} {{/isDumpValueToken}}
{{/DumpTokens}} {{/DumpTokens}}
} }
{{/isAstNode}} {{/isAstNode}}
{{/invisible}} {{/Invisible}}
{{/DumpNodes}} {{/DumpNodes}}
{{#DumpNodes}} {{#DumpNodes}}
{{#DumpTokens}} {{#DumpTokens}}
{{^invisible}} {{^Invisible}}
{{#isList}} {{#isList}}
circle " " as {{{Name}}}
{{{outerNodeName}}} .-[norank]-> {{{Name}}} {{#needRelationStyling}}{{>RelationStyle}}{{/needRelationStyling}} : "{{{label}}}"
{{#InnerRelationDumpNode}} {{#InnerRelationDumpNode}}
{{#bothVisible}} {{#bothVisible}}
{{{outerNodeName}}} .[#black{{#computed}},#{{{computedColor}}}{{/computed}}{{#innerNotNull}},norank{{/innerNotNull}}].> {{{innerNodeName}}} : {{{label}}} {{{Name}}} .{{#innerNotNullOrEmpty}}[norank]{{/innerNotNullOrEmpty}}.> {{{innerNodeName}}} {{#needRelationStyling}}{{>RelationStyle}}{{/needRelationStyling}} : "{{{label}}}"
{{/bothVisible}} {{/bothVisible}}
{{/InnerRelationDumpNode}} {{/InnerRelationDumpNode}}
{{/isList}} {{/isList}}
{{^isList}} {{^isList}}
{{^isDumpValueToken}} {{^isDumpValueToken}}
{{{outerNodeName}}} .[#black{{#computed}},#{{{computedColor}}}{{/computed}}{{#innerNotNull}},norank{{/innerNotNull}}].> {{{innerNodeName}}} : {{{label}}} {{{outerNodeName}}} .{{#innerNotNullOrEmpty}}[norank]{{/innerNotNullOrEmpty}}.> {{{innerNodeName}}} {{#needRelationStyling}}{{>RelationStyle}}{{/needRelationStyling}} : "{{{label}}}"
{{/isDumpValueToken}} {{/isDumpValueToken}}
{{/isList}} {{/isList}}
{{/invisible}} {{/Invisible}}
{{/DumpTokens}} {{/DumpTokens}}
{{#DumpChildNodes}} {{#DumpChildNodes}}
{{#isList}} {{#isList}}
circle " " as {{{Name}}}
{{{outerNodeName}}} *-- {{{Name}}} {{#needRelationStyling}}{{>RelationStyle}}{{/needRelationStyling}} : "{{{label}}}"
{{#InnerDumpNodes}} {{#InnerDumpNodes}}
{{#bothVisible}} {{#bothVisible}}
{{{outerNodeName}}} *-{{#computed}}[#{{{computedColor}}}]{{/computed}}- {{{innerNodeName}}} : {{{label}}} {{{Name}}} -- {{{innerNodeName}}} {{#needRelationStyling}}{{>RelationStyle}}{{/needRelationStyling}} : "{{{label}}}"
{{/bothVisible}} {{/bothVisible}}
{{/InnerDumpNodes}} {{/InnerDumpNodes}}
{{/isList}} {{/isList}}
{{^isList}} {{^isList}}
{{#bothVisible}} {{#bothVisible}}
{{{outerNodeName}}} *-{{#computed}}[#{{{computedColor}}}]{{/computed}}- {{{innerNodeName}}} : {{{label}}} {{{outerNodeName}}} *-- {{{innerNodeName}}} {{#needRelationStyling}}{{>RelationStyle}}{{/needRelationStyling}} : "{{{label}}}"
{{/bothVisible}} {{/bothVisible}}
{{/isList}} {{/isList}}
{{/DumpChildNodes}} {{/DumpChildNodes}}
...@@ -69,36 +76,36 @@ object "{{{labelAndTextColor}}}" as {{{name}}} {{{stereotypeList}}} {{#backgroun ...@@ -69,36 +76,36 @@ object "{{{labelAndTextColor}}}" as {{{name}}} {{{stereotypeList}}} {{#backgroun
{{#isList}} {{#isList}}
{{#InnerRelationDumpNode}} {{#InnerRelationDumpNode}}
{{#bothVisible}} {{#bothVisible}}
{{{outerNodeName}}} {{#bidirectional}}<{{/bidirectional}}-{{#innerNotNull}}[norank]{{/innerNotNull}}-> {{{innerNodeName}}} : {{{label}}} {{{outerNodeName}}} {{#Bidirectional}}<{{/Bidirectional}}-{{#innerNotNullOrEmpty}}[norank]{{/innerNotNullOrEmpty}}-> {{{innerNodeName}}} {{#needRelationStyling}}{{>RelationStyle}}{{/needRelationStyling}} : "{{{label}}}"
{{/bothVisible}} {{/bothVisible}}
{{/InnerRelationDumpNode}} {{/InnerRelationDumpNode}}
{{/isList}} {{/isList}}
{{^isList}} {{^isList}}
{{#bothVisible}} {{#bothVisible}}
{{{outerNodeName}}} {{#bidirectional}}<{{/bidirectional}}-{{#innerNotNull}}[norank]{{/innerNotNull}}-> {{{innerNodeName}}} : {{{label}}} {{{outerNodeName}}} {{#Bidirectional}}<{{/Bidirectional}}-{{#innerNotNullOrEmpty}}[norank]{{/innerNotNullOrEmpty}}-> {{{innerNodeName}}} {{#needRelationStyling}}{{>RelationStyle}}{{/needRelationStyling}} : "{{{label}}}"
{{/bothVisible}} {{/bothVisible}}
{{/isList}} {{/isList}}
{{/DumpRelations}} {{/DumpRelations}}
{{^invisible}} {{^Invisible}}
{{#InvisiblePath}} {{#InvisiblePath}}
{{#InnerRelationDumpNode}} {{#InnerRelationDumpNode}}
{{{outerNodeName}}} o.. {{{innerNodeName}}} {{{outerNodeName}}} o.. {{{innerNodeName}}}
{{/InnerRelationDumpNode}} {{/InnerRelationDumpNode}}
{{/InvisiblePath}} {{/InvisiblePath}}
{{/invisible}} {{/Invisible}}
{{#PrintConfig}}{{#orderChildren}} {{#PrintConfig}}{{#OrderChildren}}
{{#myChildren}} {{#myChildren}}
{{#hasSuccessor}} {{#hasSuccessor}}
{{{name}}} -[hidden]right-> {{#successor}}{{{name}}}{{/successor}} {{{Name}}} -[hidden]right-> {{#successor}}{{{Name}}}{{/successor}}
{{/hasSuccessor}} {{/hasSuccessor}}
{{/myChildren}} {{/myChildren}}
{{/orderChildren}}{{/PrintConfig}} {{/OrderChildren}}{{/PrintConfig}}
{{/DumpNodes}} {{/DumpNodes}}
{{#PrintConfig}} {{#PrintConfig}}
{{#debug}} {{#debug}}
legend right legend right
%date() %date()
dumpAst: {{{version}}} dumpAst: {{{Version}}}
plantuml: %version() plantuml: %version()
endlegend endlegend
{{/debug}} {{/debug}}
......
#Thu Sep 08 16:46:11 CEST 2022 #Tue Nov 22 10:54:37 CET 2022
version=2.0.0 version=3.0.1
...@@ -24,3 +24,9 @@ T3 : AbstractT ; ...@@ -24,3 +24,9 @@ T3 : AbstractT ;
rel AbstractT.oneA -> A ; rel AbstractT.oneA -> A ;
rel AbstractT.maybeA? -> A ; rel AbstractT.maybeA? -> A ;
rel AbstractT.manyA* -> A ; rel AbstractT.manyA* -> A ;
OtherRoot : Nameable ::= E* F*;
E : Nameable ;
F : Nameable ;
rel E.myF* <-> F.myE* ;
...@@ -9,6 +9,7 @@ import org.jastadd.featureTest.ast.*; ...@@ -9,6 +9,7 @@ import org.jastadd.featureTest.ast.*;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Arrays;
/** /**
* Main class of feature test. * Main class of feature test.
...@@ -18,44 +19,78 @@ import java.nio.file.Paths; ...@@ -18,44 +19,78 @@ import java.nio.file.Paths;
public class FeatureTestMain { public class FeatureTestMain {
public static void main(String[] args) throws IOException, TransformationException { public static void main(String[] args) throws IOException, TransformationException {
new FeatureTestMain().run(args);
}
private void run(String[] args) throws TransformationException, IOException {
String mode = args.length == 0 ? "default" : args[0];
System.out.println(Arrays.toString(args) + " -> " + mode);
final DumpBuilder builder;
switch (mode) {
case "default":
case "withRoot":
builder = withRoot();
break;
case "withOtherRoot":
builder = withOtherRoot();
break;
default:
throw new UnsupportedOperationException("Unknown mode: " + mode);
}
Path pathToYaml = Paths.get("featureTest.yml");
Path pathToPng = Paths.get("featureTest.png");
Path pathToSvg = Paths.get("featureTest.svg");
builder.dumpAsYaml(pathToYaml, true);
builder.dumpAsPNG(pathToPng);
builder.dumpAsSVG(pathToSvg);
builder.dumpAsSource(Paths.get("featureTest.puml"));
}
private DumpBuilder withRoot() {
Root root = new Root(); Root root = new Root();
root.setName("Root1"); root.setName("Root1");
A a = new A().setName("A2"); A a = new A().setName("A2");
a.setB(new B().setName("B2.1")); a.setB(new B().setName("B2.1"));
a.setD(new D());
// a.setMyC(new C().setName("C2.1")); // a.setMyC(new C().setName("C2.1"));
// B b1 = new B().setName("B3").setOtherValue("some long text"); B b1 = new B().setName("B3").setOtherValue("some long text");
// C c = new C().setName("C4"); // C c = new C().setName("C4");
// c.setA(new A().setName("A4.1").setB(new B().setName("B4.1.1"))); // c.setA(new A().setName("A4.1").setB(new B().setName("B4.1.1")));
// c.setRawReference(a); // c.setRawReference(a);
// b1.setOneA(a); // b1.setOneA(a);
// B b2 = new B().setName("B5").setOtherValue("#ff00ff"); B b2 = new B().setName("B5").setOtherValue("#ff00ff");
// C myC = new C().setName("C6"); // C myC = new C().setName("C6");
// c.setA(new A().setName("A6.1").setB(new B().setName("B6.1.1"))); // c.setA(new A().setName("A6.1").setB(new B().setName("B6.1.1")));
// a.setMyC(myC); // a.setMyC(myC);
root.setA(a); root.setA(a);
// root.addB(b1); root.addB(b1);
// root.addB(b2); root.addB(b2);
// root.setC(c); // root.setC(c);
Path pathToYaml = Paths.get("featureTest.yml"); return Dumper
Path pathToPng = Paths.get("featureTest.png");
Path pathToSvg = Paths.get("featureTest.svg");
DumpBuilder builder = Dumper
// .read(null) // .read(null)
.read(root) .read(root)
// .enableRelationWithRank() // .enableRelationWithRank()
// .customPreamble("hide empty members") // .customPreamble("hide empty members")
.enableDebug() .enableDebug()
.customPreamble("title My fancy title") .customPreamble("title My fancy title")
.includeChildWhen((parentNode, childNode, contextName) -> { .includeChild((parentNode, childNode, contextName) -> {
if (parentNode instanceof A && ((A) parentNode).getName().equals("A2")) { // if (parentNode instanceof A && ((A) parentNode).getName().equals("A2")) {
return false; // return false;
// }
if (parentNode instanceof Root && childNode instanceof B) {
return !"B3".equals(((B) childNode).getName());
} }
return !contextName.equals("MyC"); // return !contextName.equals("MyC");
return true;
}) })
.includeRelationsWhen((sourceNode, targetNode, roleName) -> .includeRelation((sourceNode, targetNode, roleName) ->
!(sourceNode instanceof B) || !((B) sourceNode).getName().equals("B6.1.1")) !(sourceNode instanceof B) || !((B) sourceNode).getName().equals("B6.1.1"))
.includeAttributeWhen((node, attributeName, isNTA, supplier) -> { .includeAttribute((node, attributeName, isNTA, supplier) -> {
switch (attributeName) { switch (attributeName) {
case "referenceAttr": case "referenceAttr":
case "collectBs": case "collectBs":
...@@ -69,11 +104,66 @@ public class FeatureTestMain { ...@@ -69,11 +104,66 @@ public class FeatureTestMain {
} }
}) })
.skinParam(SkinParamBooleanSetting.Shadowing, false) .skinParam(SkinParamBooleanSetting.Shadowing, false)
.setNameMethod(node -> node.getClass().getSimpleName() + ASTNode.counter++); .relationStyle((source, target, isComputed, isContainment, style) -> {
System.out.println(style.getLabel() + ", computed: " + isComputed + ", containment: " + isContainment + ", textC: " + style.getTextColor() + ", lineC: " + style.getLineColor());
if (isContainment && target != null && style.getLabel().equals(target.getClass().getSimpleName())) {
style.setLabel("");
}
switch (style.getLabel()) {
case "ManyA":
style.setLabel("ManyA of " + ((Nameable) source).getName());
break;
case "OneA":
case "MaybeC?":
style.setTextColor("red");
style.setLineColor("green");
break;
case "B":
style.setLineColor("orange");
style.setTextColor("orange");
break;
case "collectBs":
style.setLineColor("purple");
style.setTextColor("purple");
break;
}
})
.<ASTNode<?>>nodeStyle((node, style) -> {
if (node.isA()) {
style.setBackgroundColor("yellow");
}
if (node instanceof B && ((B) node).getOtherValue().startsWith("#")) {
style.setBackgroundColor(((B) node).getOtherValue().substring(1));
}
style.setLabel(node.getClass().getSimpleName() + ASTNode.counter++);
});
}
builder.dumpAsYaml(pathToYaml, true); private DumpBuilder withOtherRoot() {
builder.dumpAsPNG(pathToPng); OtherRoot root = new OtherRoot();
builder.dumpAsSVG(pathToSvg); E e1 = new E().setName("E1");
builder.dumpAsSource(Paths.get("featureTest.puml")); E e2 = new E().setName("E2");
E e3 = new E().setName("E3");
E e4 = new E().setName("E4");
F f1 = new F().setName("F1");
F f2 = new F().setName("F2");
F f3 = new F().setName("F3");
F f4 = new F().setName("F4");
for (E e : new E[]{e1, e2, e3, e4}) {
root.addE(e);
}
for (F f : new F[]{f1, f2, f3, f4}) {
root.addF(f);
}
e1.addMyF(f1);
e1.addMyF(f2);
e2.addMyF(f2);
e3.addMyF(f2);
return Dumper.read(root)
.includeToken((node, tokenName, value) -> false)
.nodeStyle((node, style) -> {
style.setLabel(((Nameable) node).getName());
});
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment