|
|
Re: XText cross-reference to rule containing a cross-reference [message #1383995 is a reply to message #1379258] |
Tue, 27 May 2014 18:11 |
dan jatnieks Messages: 8 Registered: July 2009 |
Junior Member |
|
|
Thanks for that tip Christian.
I have since noticed that hovering on the red 'X' in the left side rather than the red underlined "c", give me this message:
Quote:
Multiple markers at this line
- Couldn't resolve reference to ObjectEntity 'c'.
- mismatched input '.' expecting ';'
I'm a little concerned the 'mismatched input' message may indicate a problem in the grammar?
I've added the following to my MyDslQualifiedNameProvider
QualifiedName qualifiedName(ObjectEntity obj) {
List<String> names = new ArrayList<String>();
final EClass eClass = obj.eClass();
final EStructuralFeature result = eClass.getEStructuralFeature("first");
List<INode> nodes = NodeModelUtils.findNodesForFeature(obj, result);
for (INode n : nodes) {
System.out.println(n.getText());
// TODO: add ContainerEntity name to qualified name ??
}
names.add(obj.getName());
QualifiedName qn = QualifiedName.create(names);
System.out.println("QN= " + qn);
return qn;
}
But 'findNodesForFeature' just returns an empty list for the line 'ObjectOp c.o'. Could it be because of the 'mismatched input' message?
When called for ObjectEntity 'o2' from the line 'Object c.o2;', then 'findNodesForFeature' does return a node and node.getText() is 'c' from the ContainerEntity as expected.
So I'm still having a problem with 'ObjectOp c.o;' and getting the ContainerEntity.
[Updated on: Tue, 27 May 2014 18:23] Report message to a moderator
|
|
|
Re: XText cross-reference to rule containing a cross-reference [message #1383998 is a reply to message #1383995] |
Tue, 27 May 2014 18:34 |
|
Hi,
i dont understand your impl. here is basically what i intended you to do
ObjectOp:
'ObjectOp' name=[ObjectEntity|FQN] ';'
;
FQN: ID ("." ID)*;
a second problem is that xx=[YY] is short for xx=[YY|ID] which means reference an YY and parse an ID. an ID does not allow a .
=>
ObjectOp:
'ObjectOp' name=[ObjectEntity|FQN] ';'
;
FQN: ID ("." ID)*;
then i do not understand your example model: c.o the both are not related to each other.
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: XText cross-reference to rule containing a cross-reference [message #1384015 is a reply to message #1384014] |
Tue, 27 May 2014 20:10 |
|
hmmm i was missing that one
public class MyDslQualifiedNameProvider extends
DefaultDeclarativeQualifiedNameProvider {
QualifiedName qualifiedName(ObjectEntity obj) {
List<INode> nodes = NodeModelUtils.findNodesForFeature(obj, MyDslPackage.Literals.OBJECT_ENTITY__FIRST);
if (nodes.size()>0) {
return QualifiedName.create(nodes.get(0).getText().trim(), obj.getName());
}
return null;
}
}
then the container should become the parent of the child and the childs name should be parentname.childname
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.03841 seconds