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

1.2.2

- always use refined token method, especially when method from parent also exists
- also restructure debug output
parent e87f6c0a
Branches
No related tags found
1 merge request!121.2.2
Pipeline #14564 passed
...@@ -75,6 +75,18 @@ aspect ClassAnalysis { ...@@ -75,6 +75,18 @@ aspect ClassAnalysis {
IntrinsicTokenMethod tokenMethod = new IntrinsicTokenMethod(); IntrinsicTokenMethod tokenMethod = new IntrinsicTokenMethod();
tokenMethod.setMethod(method); tokenMethod.setMethod(method);
tokenMethod.setName(tokenName); tokenMethod.setName(tokenName);
TokenMethod previousTokenMethodWithSameName = result.getTokenMethodWithName(tokenName);
if (method.getName().startsWith("refined__")) {
tokenMethod.setRefined(true);
// check for previous non-refined method with same name
if (previousTokenMethodWithSameName != null) {
// replace previous method instead of adding
result.setOtherMethod(tokenMethod, previousTokenMethodWithSameName.myIndex());
continue;
}
} else if (previousTokenMethodWithSameName != null && previousTokenMethodWithSameName.isIntrinsicTokenMethod() && previousTokenMethodWithSameName.asIntrinsicTokenMethod().getRefined()) {
continue;
}
result.addOtherMethod(tokenMethod); result.addOtherMethod(tokenMethod);
break; break;
case "Attribute": case "Attribute":
...@@ -140,6 +152,23 @@ aspect ClassAnalysis { ...@@ -140,6 +152,23 @@ aspect ClassAnalysis {
return result; return result;
} }
TokenMethod ClassAnalysisResult.getTokenMethodWithName(String tokenName) {
// this can not be an attribute, since ClassAnalysisResult changes, and we do not use incremental eval
for (AnalysedMethod otherMethod : getOtherMethodList()) {
if (otherMethod.isTokenMethod()) {
TokenMethod tokenMethod = otherMethod.asTokenMethod();
if (tokenMethod.getName().equals(tokenName)) {
return tokenMethod;
}
}
}
return null;
}
inh int AnalysedMethod.myIndex();
eq ClassAnalysisResult.getContainmentMethod(int index).myIndex() = index;
eq ClassAnalysisResult.getOtherMethod(int index).myIndex() = index;
syn java.util.List<String> DumpAst.targetOrder(Class<?> clazz) { syn java.util.List<String> DumpAst.targetOrder(Class<?> clazz) {
for (java.lang.reflect.Constructor<?> method : clazz.getConstructors()) { for (java.lang.reflect.Constructor<?> method : clazz.getConstructors()) {
for (java.lang.annotation.Annotation annotation : method.getAnnotations()) { for (java.lang.annotation.Annotation annotation : method.getAnnotations()) {
......
...@@ -47,8 +47,9 @@ NTAListChildMethod : ListChildMethod ; ...@@ -47,8 +47,9 @@ NTAListChildMethod : ListChildMethod ;
SingleRelationMethod : AnalysedMethod ; SingleRelationMethod : AnalysedMethod ;
ListRelationMethod : AnalysedMethod ; ListRelationMethod : AnalysedMethod ;
// TODO can the refine bug also happen for refined attributes?
abstract TokenMethod : AnalysedMethod ; abstract TokenMethod : AnalysedMethod ;
IntrinsicTokenMethod : TokenMethod ; IntrinsicTokenMethod : TokenMethod ::= <Refined:boolean> ;
AttributeMethod : TokenMethod ; AttributeMethod : TokenMethod ;
BuildConfig ::= StyleInformation BuildConfig ::= StyleInformation
......
...@@ -43,16 +43,16 @@ aspect Printing { ...@@ -43,16 +43,16 @@ aspect Printing {
aspect Debugging { aspect Debugging {
syn String ClassAnalysisResult.prettyPrint() { syn String ClassAnalysisResult.prettyPrint() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("ContainmentMethods:"); sb.append("- ContainmentMethods: ");
for (AnalysedMethod method : getContainmentMethodList()) { for (AnalysedMethod method : getContainmentMethodList()) {
sb.append(method.prettyPrint()).append(","); sb.append("\n - ").append(method.prettyPrint());
} }
if (getNumContainmentMethod() == 0) { if (getNumContainmentMethod() == 0) {
sb.append("none. "); sb.append("none. ");
} }
sb.append("other methods:"); sb.append("\n- Other methods: ");
for (AnalysedMethod method : getOtherMethodList()) { for (AnalysedMethod method : getOtherMethodList()) {
sb.append(method.prettyPrint()).append(","); sb.append("\n - ").append(method.prettyPrint());
} }
if (getNumOtherMethod() == 0) { if (getNumOtherMethod() == 0) {
sb.append("none."); sb.append("none.");
......
#Mon Jul 25 18:03:32 CEST 2022 #Tue Sep 06 14:11:59 CEST 2022
version=1.2.1 version=1.2.2
...@@ -34,6 +34,8 @@ dependencies { ...@@ -34,6 +34,8 @@ dependencies {
implementation project(":dumpAst") implementation project(":dumpAst")
jastadd2 group: 'org.jastadd', name: 'jastadd2', version: '2.3.5-dresden' jastadd2 group: 'org.jastadd', name: 'jastadd2', version: '2.3.5-dresden'
relast group: 'org.jastadd', name: 'relast', version: "${relast_version}" relast group: 'org.jastadd', name: 'relast', version: "${relast_version}"
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.3'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.13.3'
implementation group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11' implementation group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
} }
......
aspect GrammarGlobal { aspect GrammarGlobal {
refine @com.fasterxml.jackson.annotation.JsonGetter("id") public String Nameable.getName() {
return refined();
}
syn A C.getCalculated() { syn A C.getCalculated() {
A result = new A(); A result = new A();
result.setName("Calculated-" + getName()); result.setName("Calculated-" + getName());
...@@ -34,6 +38,8 @@ aspect GrammarGlobal { ...@@ -34,6 +38,8 @@ aspect GrammarGlobal {
syn int Root.simpleAttr() = 42; syn int Root.simpleAttr() = 42;
syn A Root.referenceAttr() = getA(); syn A Root.referenceAttr() = getA();
syn String Nameable.fancyName() = getName() + ", but fancy!";
syn boolean ASTNode.isA() = false; syn boolean ASTNode.isA() = false;
eq A.isA() = true; eq A.isA() = true;
...@@ -41,6 +47,17 @@ aspect GrammarGlobal { ...@@ -41,6 +47,17 @@ aspect GrammarGlobal {
B contributes this to Root.collectBs(); B contributes this to Root.collectBs();
C contributes nta getAlsoCalculatedList() to Root.collectBs(); C contributes nta getAlsoCalculatedList() to Root.collectBs();
C contributes nta getAlsoCalculatedListNewSyntax() to Root.collectBs(); C contributes nta getAlsoCalculatedListNewSyntax() to Root.collectBs();
inh Root A.root();
eq Root.getChild().root() = this;
syn nta B A.AAA() {
B result = new B();
result.setMaybeC(root().getC());
return result;
}
public static int ASTNode.counter;
} }
aspect GrammarTypeLevel { aspect GrammarTypeLevel {
...@@ -51,3 +68,7 @@ aspect GrammarTypeLevel { ...@@ -51,3 +68,7 @@ aspect GrammarTypeLevel {
return result; return result;
} }
} }
aspect Refining {
refine GrammarGlobal eq Nameable.fancyName() = refined() + " and more!";
}
// testcases with global inclusion/exclusion // testcases with global inclusion/exclusion
Nameable ::= <Name> ; abstract Nameable ::= <Name> ;
Root : Nameable ::= A B* [C]; Root : Nameable ::= A B* [C];
A : Nameable ::= B [MyC:C] [D]; A : Nameable ::= B [MyC:C] [D];
B : Nameable ::= <OtherValue> ; B : Nameable ::= <OtherValue> ;
......
...@@ -2,10 +2,7 @@ package de.tudresden.inf.st.jastadd.featureTest; ...@@ -2,10 +2,7 @@ package de.tudresden.inf.st.jastadd.featureTest;
import de.tudresden.inf.st.jastadd.dumpAst.ast.Dumper; import de.tudresden.inf.st.jastadd.dumpAst.ast.Dumper;
import de.tudresden.inf.st.jastadd.dumpAst.ast.SkinParamBooleanSetting; import de.tudresden.inf.st.jastadd.dumpAst.ast.SkinParamBooleanSetting;
import org.jastadd.featureTest.ast.A; import org.jastadd.featureTest.ast.*;
import org.jastadd.featureTest.ast.B;
import org.jastadd.featureTest.ast.C;
import org.jastadd.featureTest.ast.Root;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
...@@ -23,29 +20,29 @@ public class FeatureTestMain { ...@@ -23,29 +20,29 @@ public class FeatureTestMain {
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.setMyC(new C().setName("C2.1")); // a.setMyC(new C().setName("C2.1"));
B b1 = new B().setName("B3"); // 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"); // 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"); Path pathToYaml = Paths.get("featureTest.yml");
Path pathToPng = Paths.get("featureTest.png"); Path pathToPng = Paths.get("featureTest.png");
Path pathToSvg = Paths.get("featureTest.svg"); Path pathToSvg = Paths.get("featureTest.svg");
Path pathToPdf = Paths.get("featureTest.pdf");
Dumper Dumper
// .read(null) // .read(null)
.read(root) .read(root)
// .customPreamble("hide empty members") // .customPreamble("hide empty members")
.enableDebug()
.customPreamble("title My fancy title") .customPreamble("title My fancy title")
.includeChildWhen((parentNode, childNode, contextName) -> { .includeChildWhen((parentNode, childNode, contextName) -> {
if (parentNode instanceof A && ((A) parentNode).getName().equals("A2")) { if (parentNode instanceof A && ((A) parentNode).getName().equals("A2")) {
...@@ -61,17 +58,19 @@ public class FeatureTestMain { ...@@ -61,17 +58,19 @@ public class FeatureTestMain {
case "collectBs": case "collectBs":
case "Calculated": case "Calculated":
case "AlsoCalculatedListNewSyntax": case "AlsoCalculatedListNewSyntax":
case "AAA":
case "fancyName":
return true; return true;
default: default:
return false; return false;
} }
}) })
.skinParam(SkinParamBooleanSetting.Shadowing, false) .skinParam(SkinParamBooleanSetting.Shadowing, false)
.setNameMethod(node -> node.getClass().getSimpleName() + ASTNode.counter++)
// .enableRelationWithRank() // .enableRelationWithRank()
.dumpAsYaml(pathToYaml, true) .dumpAsYaml(pathToYaml, true)
.dumpAsPNG(pathToPng) .dumpAsPNG(pathToPng)
.dumpAsSVG(pathToSvg) .dumpAsSVG(pathToSvg)
.dumpAsPDF(pathToPdf)
.dumpAsSource(Paths.get("featureTest.puml")) .dumpAsSource(Paths.get("featureTest.puml"))
; ;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment