Referencing nameless Cross-references [message #1752356] |
Sun, 22 January 2017 18:15  |
Eclipse User |
|
|
|
generate mydsl "myfirm/mydsl"
Constants :
'KONSTANTE' ( (name=ID ',' foo=INT)
| ( const=[typ::Konstante] )) // nameless reference
;
Otherrule:
name=ID ref=[Constants] // can only reference the locally declared constants
;
generate typ "myfirm/typ"
Konstante:
'KONSTANTE' name = ID ':' foo=INT
;
Hi, I am having trouble getting the references to work. I want to reference the rule 'constants' but I can only get the references to match for the locally declared 'constants'. But I want to get the references to the nameless 'constants' as well.
I figuered out that I have implement my own QualifiedNameProvider but the name of the Konstante is not loaded (null) when I try to access it.
class MyDSLQualifiedNameProvider extends IQualifiedNameProvider.AbstractImpl {
@Inject private IQualifiedNameConverter qualifiedNameConverter;
override getFullyQualifiedName(EObject obj) {
var name = SimpleAttributeResolver.NAME_RESOLVER.apply(obj);
if (name == null || name.length() == 0) {
if (obj.class == ConstantsImpl) {
var constants = obj as Constants;
// constants.const.name is always null
if (constants.const.name == null) {
return null;
}
return qualifiedNameConverter.toQualifiedName(constants.const.name)
} else {
return null;
}
}
return qualifiedNameConverter.toQualifiedName(name);
}
}
How can I get access to the name of the externally referenced object?
Or is there a other solution to the problem or an example where someone else has solved this issue?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03926 seconds