From 6de66d8ce97fb2dc35556eeb0d4fbb0454831ee6 Mon Sep 17 00:00:00 2001 From: rschoene <rene.schoene@tu-dresden.de> Date: Wed, 2 Mar 2022 18:22:41 +0100 Subject: [PATCH] working on better visualization - allow passing null to Dumper.read() --- dumpAst/src/main/jastadd/DumpAst.relast | 2 +- dumpAst/src/main/jastadd/GenerationBackend.jadd | 2 +- dumpAst/src/main/jastadd/GenerationFrontend.jadd | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dumpAst/src/main/jastadd/DumpAst.relast b/dumpAst/src/main/jastadd/DumpAst.relast index 7f41406..3d76a4b 100644 --- a/dumpAst/src/main/jastadd/DumpAst.relast +++ b/dumpAst/src/main/jastadd/DumpAst.relast @@ -1,5 +1,5 @@ DumpAst ::= DumpNode* <PackageName> BuildConfig PrintConfig ; -rel DumpAst.RootNode -> DumpNode ; +rel DumpAst.RootNode? -> DumpNode ; DumpNode ::= DumpChildNode* DumpToken* DumpRelation* <Name> <Label> <BackgroundColor> <TextColor> <Object:Object> <Invisible:boolean> <Computed:boolean> <ManualStereotypes> diff --git a/dumpAst/src/main/jastadd/GenerationBackend.jadd b/dumpAst/src/main/jastadd/GenerationBackend.jadd index 4536424..be9aaff 100644 --- a/dumpAst/src/main/jastadd/GenerationBackend.jadd +++ b/dumpAst/src/main/jastadd/GenerationBackend.jadd @@ -15,7 +15,7 @@ aspect GenerationBackend { } public TransformationOptions asRoot() { - return fromSource(Source.ROOT, false); + return fromSource(Source.ROOT, false).allowNullObjectsOnce(); } public TransformationOptions asNormal(boolean shouldBeInvisible) { diff --git a/dumpAst/src/main/jastadd/GenerationFrontend.jadd b/dumpAst/src/main/jastadd/GenerationFrontend.jadd index 2bc0d68..3e6fcf0 100644 --- a/dumpAst/src/main/jastadd/GenerationFrontend.jadd +++ b/dumpAst/src/main/jastadd/GenerationFrontend.jadd @@ -379,7 +379,17 @@ public class DumpBuilder { protected DumpAst build() { if (result == null) { result = new DumpAst(); - result.setPackageName(this.packageName == null ? this.target.getClass().getPackage().getName() : this.packageName); + final String packageNameToUse; + if (this.packageName != null) { + packageNameToUse = this.packageName; + } else { + if (this.target == null) { + packageNameToUse = null; + } else { + packageNameToUse = this.target.getClass().getPackage().getName(); + } + } + result.setPackageName(packageNameToUse); result.setBuildConfig(this.buildConfig); result.setPrintConfig(this.printConfig); try { -- GitLab