Commit 683281f4 authored by Anders Nilsson's avatar Anders Nilsson

Synching

parent 85eb9240
......@@ -33,18 +33,64 @@ aspect Misc {
public String Thing.id() {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i).isIdentifier()) {
Identifier ident = ((ClassUse) getElement(i)).decl();
return ident.getElement(0).id();
Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl();
return ((StringElement) ident.getElement(0)).getLITERAL();
}
}
return null;
}
public String ValueElement.id() {
return getElement(0).getLITERAL();
}
syn boolean Element.isIdentifier() = false;
eq Identifier.isIdentifier() = true;
eq ClassUse.isIdentifier() = decl().isIdentifier();
}
aspect Decl {
syn lazy Thing ClassUse.decl() {
String id = getAttribute(0).getValue().getSTRING_LITERAL();
return rootNode().findDecl(id);
}
Start ASTNode.rootNode() {
ASTNode parent = getParent();
while (!(parent instanceof Start)) {
parent = parent.getParent();
}
return (Start) parent;
}
syn Thing Start.findDecl(String id) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i).findDecl(id) != null) {
return (Thing) getElement(i);
}
}
return null;
}
syn Thing Element.findDecl(String id) = null;
eq ComplexElement.findDecl(String id) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i).findDecl(id) != null) {
return (Thing) getElement(i);
}
}
return null;
}
eq Thing.findDecl(String id) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i).isEqualId(id)) {
return this;
}
}
return null;
}
syn boolean Attribute.isEqualId(String id) = false;
eq RdfId.isEqualId(String id) {
if (getValue().getSTRING_LITERAL().equals(id)) {
return true;
}
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment