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

Generating xml non-relast variant.

parent 2a7b6699
No related branches found
No related tags found
1 merge request!1All4one relast
......@@ -62,6 +62,31 @@ function build() {
build_incremental $@
}
function prepare_namelookup() {
# deactivate preprocess
sed -i 's|^jastadd.dependsOn preprocess|//jastadd.dependsOn preprocess|g' solve/build.gradle
# remove generated AST and helper files, activate namelookup AST and helper jadd files
( cd solve/src/main/jastadd &&
rm SocialNetworkGen.ast SocialNetworkGen.jadd &&
mv Refs.jadd.unused Refs.jadd &&
mv SocialNetworkNamelookup.ast.unused SocialNetworkNamelookup.ast )
}
function revert_namelookup() {
# activate preprocess
sed -i 's|//jastadd.dependsOn preprocess|jastadd.dependsOn preprocess|g' solve/build.gradle
# deactivate normal AST and helper jadd files
( cd solve/src/main/jastadd &&
mv Refs.jadd Refs.jadd.unused &&
mv SocialNetworkNamelookup.ast SocialNetworkNamelookup.ast.unused )
}
prepare_namelookup
# Build jastadd-ttc18-xml (namelookup)
sed -i 's/LiveContestDriverEMF/LiveContestDriverXml/' solve/build.gradle
build "jastadd-ttc18-xml"
revert_namelookup
# Build jastadd-ttc18-xml
sed -i 's/LiveContestDriverEMF/LiveContestDriverXml/' solve/build.gradle
build "jastadd-ttc18-relast-xml"
......
......@@ -67,7 +67,7 @@ task jastadd(type: JavaExec) {
"--package=de.tudresden.inf.st.ttc18live.jastadd.model",
"--o=src/gen/java",
"--tracing",
] + fileTree("./src/main/jastadd/").matching {exclude "*.relast"}
] + fileTree("./src/main/jastadd/").matching {exclude "*.relast"}.matching {exclude "*.unused"}
doFirst {
print("Calling jastadd2.jar " + fileTree("./src/main/jastadd/") + '\n')
......
aspect NameLookup {
syn java.util.List<User> User.getFriends() {
java.util.List<User> result = new java.util.ArrayList<>();
for (UserRef userRef : getFriendRefList()) {
result.add(userRef.getUser());
}
return result;
}
syn java.util.List<User> Comment.getLikedByList() = socialNetwork().getLikedByMap().get(this);
syn Map<Comment, java.util.List<User>> SocialNetwork.getLikedByMap() {
Map<Comment, java.util.List<User>> result = new HashMap();
for (Comment comment : comments()) {
result.put(comment, new java.util.ArrayList<>());
}
for (User user : getUserList()) {
for (CommentRef commentRef : user.getLikes()) {
result.get(commentRef.getComment()).add(user);
}
}
return result;
}
public void User.addSubmission(Submission s) {
this.addSubmissionRef(new SubmissionRef(s));
}
public void User.addFriend(User s) {
this.addFriendRef(new UserRef(s));
s.addFriendRef(new UserRef(this));
}
public void User.addLike(Comment s) {
this.addLikeRef(new CommentRef(s));
}
}
abstract ModelElement ::= <Id:Long> ;
SocialNetwork : ModelElement ::= User* Post* ;
User:ModelElement ::= <Name:String> ;
abstract Submission : ModelElement ::= <Timestamp:Long> <Content:String> Comment* ;
Comment : Submission ::= ;
Post : Submission ::= ;
rel User.Friend* -> User ;
rel User.Submission* -> Submission ;
rel User.Like* <-> Comment.LikedBy* ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment