How to make references to composite elements? Do I need to extend DefaultDeclarativeQualifiedNameProvider?
Example xtext model:
Model:
elements+=Table*;
Table:
'table' name=ID '{'
columns+=Column*
primaryKey=PrimaryKey
foreignKey+=ForeignKey*
'}';
Column:
'column' name=ID;
ForeignKey:
'foreignKey' name=ID '{'
columns+=[Column]*
references=[PrimaryKey]
'}';
PrimaryKey:
'primaryKey' name=ID '{'
columns+=[Column]*
'}';
I want to model:
table HideOut {
column Name
column Location
primaryKey hideoutKey {
Name
}
}
table Gangster {
column Name
primaryKey gangsterKey {
Name
}
foreignKey hideOuts {
HideOut.hideoutKey
}
}
But the reference in foreignKey hideOuts to HideOut.hideoutKey is not picked up.
The editor message is: Couldn't resolve reference to PrimaryKey 'HideOut'
I tried writing a DefaultDeclarativeQualifiedNameProvider, but it did not seem to help. I followed http christiandietrich.wordpress.com/2011/07/16/iqualifiednameproviders-in-xtext-2-0/
Could someone help me in the right direction? My goal is to have two seperate model files with references between them. Making reference works for root elements like 'Table' in my model, but I do not want to use root elements only.
Thank you, Martijn