Hi
In my DSL I use successfully a ScopeProvider to allow code completion for JvmOperations
xtext:
CaseAction:
'CaseAction' name=ValidID '{'
'implementor' ':' implementorClass=JvmTypeReference '::' method=[jvmTypes::JvmOperation]
'resultEnum' ':' resultEnum=[jvmTypes::JvmEnumerationType]
'}';
ScopeProvider:
JvmGenericType type = (JvmGenericType) caseAction
.getImplementorClass().getType();
List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>();
for (JvmOperation operation : type.getDeclaredOperations()) {
descriptions.add(EObjectDescription.create(
QualifiedName.create(operation.getSimpleName()),
operation));
}
return new SimpleScope(descriptions);
Doing the same for a JvmEnumerationLiteral however works only for the proposal but throws an error in the IDE once the proposal is accepted (Couldn't resolve reference to JvmEnumerationLiteral 'VALID'.)
xtext:
StateAction:
action=[CaseAction] ':' '{'
(valueStateMappings+=EnumValueStateMapping)*
'}';
EnumValueStateMapping :
resultValue=[jvmTypes::JvmEnumerationLiteral] '->' nextState=[CaseState]
;
ScopeProvider:
if (action != null) {
CaseAction caseAction = action.getAction();
if (caseAction != null) {
JvmOperation method = caseAction.getMethod();
if (method != null) {
JvmType returnType = method.getReturnType().getType();
if (returnType instanceof JvmEnumerationType) {
JvmEnumerationType enumerationType = (JvmEnumerationType) returnType;
for (JvmEnumerationLiteral literal : enumerationType
.getLiterals()) {
descriptions.add(EObjectDescription.create(
QualifiedName.create(literal
.getSimpleName()), literal));
}
}
}
}
}
return new SimpleScope(descriptions);
Any ideas what I am doing wrong, how I can overcome this problem?
Thanks in advance
Ingo