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

all wanted cases work for type endpoint definitions using treeResolveAll in ragconnect

parent c715e851
No related branches found
No related tags found
No related merge requests found
...@@ -18,17 +18,9 @@ mainClassName = 'de.tudresden.inf.st.mrc.MinimalMain' ...@@ -18,17 +18,9 @@ mainClassName = 'de.tudresden.inf.st.mrc.MinimalMain'
repositories { repositories {
jcenter() jcenter()
// maven {
// name "gitlab-maven"
// url "https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven"
// }
maven { maven {
name "gitlab-maven-ragconnect" name "gitlab-maven"
url "https://git-st.inf.tu-dresden.de/api/v4/projects/708/packages/maven" url "https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven"
}
maven {
name "gitlab-maven-relast2uml"
url "https://git-st.inf.tu-dresden.de/api/v4/projects/679/packages/maven"
} }
} }
...@@ -56,6 +48,7 @@ dependencies { ...@@ -56,6 +48,7 @@ dependencies {
implementation group: 'de.tudresden.inf.st', name: 'dumpAstWithPlantuml', version: '0.3.5' implementation group: 'de.tudresden.inf.st', name: 'dumpAstWithPlantuml', version: '0.3.5'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.12.1' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.12.1'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.1' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.1'
implementation group: 'de.tudresden.inf.st', name: 'dumpAst', version: '0.3.5'
grammar2umlClasspath group: 'de.tudresden.inf.st', name: 'grammar2uml', version: '0.1.1' grammar2umlClasspath group: 'de.tudresden.inf.st', name: 'grammar2uml', version: '0.1.1'
// ragconnectClasspath group: 'de.tudresden.inf.st', name: 'ragconnect', version: '0.2.4' // ragconnectClasspath group: 'de.tudresden.inf.st', name: 'ragconnect', version: '0.2.4'
......
...@@ -17,14 +17,14 @@ aspect Computation { ...@@ -17,14 +17,14 @@ aspect Computation {
result.addFoxtrot(new Foxtrot().setID(i)); result.addFoxtrot(new Foxtrot().setID(i));
result.addGolf(new Golf().setID(i)); result.addGolf(new Golf().setID(i));
} }
// rel Alfa.MyBravo -> Bravo ; // // rel Alfa.MyBravo -> Bravo ;
result.setMyBravo(getBravo(getInput())); // result.setMyBravo(getBravo(getInput()));
// rel Alfa.MultiBravo* -> Bravo ; // // rel Alfa.MultiBravo* -> Bravo ;
result.addMultiBravo(getBravo(getInput())); // result.addMultiBravo(getBravo(getInput()));
result.addMultiBravo(getBravo((getInput() + 1))); // result.addMultiBravo(getBravo((getInput() + 1)));
// rel Alfa.MidiDelta <-> Delta.MidiAlfa? ; // // rel Alfa.MidiDelta <-> Delta.MidiAlfa? ;
result.setMidiDelta(getDelta(getInput())); // result.setMidiDelta(getDelta(getInput()));
// rel Alfa.MyEcho -> Echo ; // rel Alfa.MyEcho -> Echo ;
result.setMyEcho(result.getEcho(getInput())); result.setMyEcho(result.getEcho(getInput()));
...@@ -38,13 +38,24 @@ aspect Computation { ...@@ -38,13 +38,24 @@ aspect Computation {
// rel Alfa.MidiGolf <-> Golf.MidiAlfa? ; // rel Alfa.MidiGolf <-> Golf.MidiAlfa? ;
result.setMidiGolf(result.getGolf(getInput())); result.setMidiGolf(result.getGolf(getInput()));
// rel Alfa.MyHotel -> Hotel ; // // rel Alfa.MyHotel -> Hotel ;
result.setMyHotel(getSenderSubTree().getHotel(getInput())); // result.setMyHotel(getSenderSubTree().getHotel(getInput()));
// rel Alfa.MultiHotel* -> Hotel ; // // rel Alfa.MultiHotel* -> Hotel ;
result.addMultiHotel(getSenderSubTree().getHotel(getInput())); // result.addMultiHotel(getSenderSubTree().getHotel(getInput()));
result.addMultiHotel(getSenderSubTree().getHotel((getInput() + 1))); // result.addMultiHotel(getSenderSubTree().getHotel((getInput() + 1)));
// rel Alfa.Myself -> Alfa ;
result.setMyself(result);
// rel Echo.MyFoxtrot -> Foxtrot ;
result.getEcho(getInput()).setMyFoxtrot(result.getFoxtrot(getInput()));
// // rel Foxtrot.MyHotel -> Hotel ;
// result.getFoxtrot(getInput()).setMyHotel(getSenderSubTree().getHotel(getInput()));
return result; return result;
} }
syn boolean ASTNode.isNameable() = false;
eq Nameable.isNameable() = true;
} }
aspect NameResolution { aspect NameResolution {
......
...@@ -22,15 +22,19 @@ Foxtrot : Nameable ; ...@@ -22,15 +22,19 @@ Foxtrot : Nameable ;
Golf : Nameable ; Golf : Nameable ;
Hotel : Nameable ; Hotel : Nameable ;
rel Alfa.MyBravo -> Bravo ; rel Alfa.MyBravo? -> Bravo ;
rel Alfa.MultiBravo* -> Bravo ; rel Alfa.MultiBravo* -> Bravo ;
// # relation into NTA not possible // # relation into NTA not possible
//rel Charlie.MyAlfa -> Alfa ; //rel Charlie.MyAlfa -> Alfa ;
// # bidi relation from/into NTA probably not a good idea // # bidi relation from/into NTA probably not a good idea
rel Alfa.MidiDelta <-> Delta.MidiAlfa? ; rel Alfa.MidiDelta? <-> Delta.MidiAlfa? ;
rel Alfa.MyEcho -> Echo ; rel Alfa.MyEcho -> Echo ;
rel Alfa.MultiEcho* -> Echo ; rel Alfa.MultiEcho* -> Echo ;
rel Foxtrot.MyAlfa? -> Alfa ; rel Foxtrot.MyAlfa? -> Alfa ;
rel Alfa.MidiGolf <-> Golf.MidiAlfa? ; rel Alfa.MidiGolf <-> Golf.MidiAlfa? ;
rel Alfa.MyHotel -> Hotel ; rel Alfa.MyHotel? -> Hotel ;
rel Alfa.MultiHotel* -> Hotel ; rel Alfa.MultiHotel* -> Hotel ;
rel Alfa.Myself -> Alfa ;
rel Echo.MyFoxtrot? -> Foxtrot ;
rel Foxtrot.MyHotel? -> Hotel ;
...@@ -9,7 +9,9 @@ import java.io.ByteArrayOutputStream; ...@@ -9,7 +9,9 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;
...@@ -238,23 +240,26 @@ public class MinimalMain { ...@@ -238,23 +240,26 @@ public class MinimalMain {
root2ForReceiver.addReceiverRoot(receiverRoot); root2ForReceiver.addReceiverRoot(receiverRoot);
receiverRoot.connectAlfa(mqttUriString); receiverRoot.connectAlfa(mqttUriString);
Dumper.read(senderRoot).includeNonterminalAttributes("Alfa").dumpAsPNG(Paths.get("00-initial-sender.png"));
Dumper.read(receiverRoot).dumpAsPNG(Paths.get("00-initial-receiver.png"));
senderRoot.setInput(1); senderRoot.setInput(1);
describedWait(1, "after setting input to 1"); describedWait(1, "after setting input to 1");
printSender(senderRoot); printAlfa(true, senderRoot, receiverRoot);
printReceiver(receiverRoot); printAlfa(false, senderRoot, receiverRoot);
Dumper.read(senderRoot).includeNonterminalAttributes("Alfa").dumpAsPNG(Paths.get("01-after-1-sender.png"));
Dumper.read(receiverRoot).dumpAsPNG(Paths.get("01-after-1-receiver.png"));
printAlfa(true, senderRoot, receiverRoot);
printAlfa(false, senderRoot, receiverRoot);
senderRoot.setInput(2); senderRoot.setInput(2);
describedWait(1, "after setting input to 2"); describedWait(1, "after setting input to 2");
printSender(senderRoot); printAlfa(true, senderRoot, receiverRoot);
printReceiver(receiverRoot); printAlfa(false, senderRoot, receiverRoot);
} Dumper.read(senderRoot).includeNonterminalAttributes("Alfa").dumpAsPNG(Paths.get("02-after-2-sender.png"));
Dumper.read(receiverRoot).dumpAsPNG(Paths.get("02-after-2-receiver.png"));
private static void printSender(SenderRoot senderRoot) { printAlfa(true, senderRoot, receiverRoot);
printAlfa("sender", senderRoot.getAlfa(), senderRoot::getDeltaList); printAlfa(false, senderRoot, receiverRoot);
}
private static void printReceiver(ReceiverRoot receiverRoot) {
printAlfa("receiver", receiverRoot.getAlfa(), receiverRoot::getDeltaList);
} }
private static SenderRoot createSenderRoot() { private static SenderRoot createSenderRoot() {
...@@ -285,58 +290,107 @@ public class MinimalMain { ...@@ -285,58 +290,107 @@ public class MinimalMain {
interface AddBravo { void accept(Bravo b); } interface AddBravo { void accept(Bravo b); }
interface AddCharlie { void accept(Charlie b); } interface AddCharlie { void accept(Charlie b); }
interface AddDelta { void accept(Delta b); } interface AddDelta { void accept(Delta b); }
interface GetDeltaList { Iterable<Delta> get(); }
interface AddHotel { void accept(Hotel b); } interface AddHotel { void accept(Hotel b); }
private static void printAlfa(String name, Alfa alfa, GetDeltaList getDeltaList) { private static void printAlfa(boolean isSender, SenderRoot senderRoot, ReceiverRoot receiverRoot) {
StringBuilder sbDelta = new StringBuilder(); final String name;
for (Delta delta : getDeltaList.get()) { final String tick;
sbDelta.append(delta.getID()) final Alfa alfa;
.append("->") final Iterable<Delta> deltaList;
.append(delta.hasMidiAlfa() ? delta.getMidiAlfa().getID() : "/") final Iterable<Hotel> hotelList;
.append(", "); if (isSender) {
} name = "sender";
String deltaList = sbDelta.toString(); tick = " >-";
StringBuilder sbFoxtrot = new StringBuilder(); alfa = senderRoot.getAlfa();
for (Foxtrot foxtrot : alfa.getFoxtrotList()) { deltaList = senderRoot.getDeltaList();
sbFoxtrot.append(foxtrot.getID()) hotelList = senderRoot.getSenderSubTree().getHotelList();
.append("->") } else {
.append(foxtrot.hasMyAlfa() ? foxtrot.getMyAlfa().getID() : "/") name = "receiver";
.append(", "); tick = " <-";
alfa = receiverRoot.getAlfa();
deltaList = receiverRoot.getDeltaList();
hotelList = receiverRoot.getReceiverSubTree().getHotelList();
} }
String foxtrotList = sbFoxtrot.toString(); // also dump AST
StringBuilder sb = new StringBuilder();
printNode(alfa.getParent(), "", sb);
logger.info("\n{}", sb.toString());
logger.info("Checking Alfa\n" + logger.info("Checking Alfa\n" +
"{}: {} in {}\n" + "{}: {} in {}\n" +
" |- MyBravo: {}\n" + tick + " Myself: {}\n" +
" |- MultiBravoList: {}\n" + // tick + " MyBravo: {}\n" +
" |- MidiDelta: {} (MidiDelta.getMidiAlfa(): {})\n" + // tick + " MultiBravoList: {}\n" +
" |- DeltaList: {}\n" + // tick + " MidiDelta: {} (MidiDelta.getMidiAlfa(): {})\n" +
" |- MyEcho: {}\n" + // tick + " DeltaList: {}\n" +
" |- MultiEchoList: {}\n" + tick + " MyEcho: {}\n" +
" |- FoxtrotList (id -> alfa.id): {}\n" + tick + " EchoList.MyFoxtrot: {}\n" +
" |- MidiGolf: {} (MidiGolf.getMidiAlfa(): {})\n" + tick + " MultiEchoList: {}\n" +
" |- MyHotel: {}\n" + tick + " FoxtrotList.MyAlfa: {}\n" +
" |- MultiHotelList: {}" + tick + " FoxtrotList.MyHotel: {}\n" +
tick + " MidiGolf: {} (MidiGolf.getMidiAlfa(): {})\n" +
tick + " GolfList (id -> alfa.id): {}\n" +
// tick + " MyHotel: {}\n" +
// tick + " MultiHotelList: {}\n" +
// tick + " HotelList: {}" +
"{}", // just to make swapping of params easier (all have a comma at the end) "{}", // just to make swapping of params easier (all have a comma at the end)
name, alfa, alfa.getParent(), name, alfa, alfa.getParent(),
alfa.getMyBravo().getID(), nameAndHash(alfa.getMyself()),
printNameableList(alfa.getMultiBravoList()), // nameAndHash(alfa.getMyBravo()),
alfa.getMidiDelta().getID(), alfa.getMidiDelta().getMidiAlfa(), // printNameableList(alfa.getMultiBravoList()),
deltaList, // nameAndHash(alfa.getMidiDelta()), alfa.getMidiDelta().getMidiAlfa(),
alfa.getMyEcho().getID(), // printOptionalList(deltaList, Delta::hasMidiAlfa, Delta::getMidiAlfa),
nameAndHash(alfa.getMyEcho()),
printOptionalList(alfa.getEchoList(), Echo::hasMyFoxtrot, Echo::getMyFoxtrot),
printNameableList(alfa.getMultiEchoList()), printNameableList(alfa.getMultiEchoList()),
foxtrotList, printOptionalList(alfa.getFoxtrotList(), Foxtrot::hasMyAlfa, Foxtrot::getMyAlfa),
alfa.getMidiGolf().getID(), alfa.getMidiGolf().getMidiAlfa(), printOptionalList(alfa.getFoxtrotList(), Foxtrot::hasMyHotel, Foxtrot::getMyHotel),
alfa.getMyHotel().getID(), nameAndHash(alfa.getMidiGolf()), nameAndHash(alfa.getMidiGolf().getMidiAlfa()),
printNameableList(alfa.getMultiHotelList()), printOptionalList(alfa.getGolfList(), Golf::hasMidiAlfa, Golf::getMidiAlfa),
// nameAndHash(alfa.getMyHotel()),
// printNameableList(alfa.getMultiHotelList()),
// printNameableList(toList(hotelList)),
"" ""
); );
} }
private static List<? extends Nameable> toList(Iterable<Hotel> hotelList) {
List<Hotel> result = new ArrayList<>();
hotelList.forEach(result::add);
return result;
}
private static String printNameableList(List<? extends Nameable> nameableList) { private static String printNameableList(List<? extends Nameable> nameableList) {
return nameableList.stream().map(nameable -> Integer.toString(nameable.getID())).collect(Collectors.joining(",", "[", "]")); return nameableList.stream().map(MinimalMain::nameAndHash).collect(Collectors.joining(",", "[", "]"));
}
private static <T extends Nameable> String printOptionalList(Iterable<T> tIterable, Function<T, Boolean> hasChild, Function<T, Nameable> getChild) {
StringBuilder sb = new StringBuilder();
for (T t : tIterable) {
sb.append(nameAndHash(t))
.append(" -> ")
.append(hasChild.apply(t) ? nameAndHash(getChild.apply(t)) : "/")
.append(", ");
}
return sb.toString();
}
private static String nameAndHash(Nameable nameable) {
return nameable.getID() + " (@" + Integer.toHexString(nameable.hashCode()) + ")";
} }
private static void printNode(ASTNode<?> node, String indent, StringBuilder sb) {
if (node.isNameable()) {
sb.append(indent)
.append("- ")
.append(node.getClass().getSimpleName())
.append(nameAndHash((Nameable) node))
.append("\n");
}
for (ASTNode<?> child : node.astChildren()) {
printNode(child, node instanceof JastAddList ? indent : indent + " |", sb);
}
}
// private static void enableTracing(ASTNode<?> node) { // private static void enableTracing(ASTNode<?> node) {
// if (node.trace().getReceiver() != null && node.trace().getReceiver() instanceof MinimalReceiver) { // if (node.trace().getReceiver() != null && node.trace().getReceiver() instanceof MinimalReceiver) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment