Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problems writing Scope provider for enumeration literals(Problems writing Scope provider for enumeration literals)
Problems writing Scope provider for enumeration literals [message #801585] Sat, 18 February 2012 16:40
Ingo Boegemann is currently offline Ingo BoegemannFriend
Messages: 7
Registered: February 2012
Junior Member
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
Previous Topic:Check eContainer for equality
Next Topic:change font from mydsl
Goto Forum:
  


Current Time: Tue Mar 31 00:07:36 GMT 2020

Powered by FUDForum. Page generated in 0.02127 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top