Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Custom class reference in inferrer
Custom class reference in inferrer [message #1758625] Thu, 30 March 2017 13:04 Go to next message
Eclipse UserFriend
Hi again Smile
When building my inferrer i need to put a custom class as return type for my method like this:
members += com.toMethod(com.name, typeRef(CommandResponse))[ ...


That CommandResponse is a class meant to be in the target environment and my own as well, so it will be in the classpath.
I created a namespace scope provider by:
ImportedNamespaceScopeProvider extends ImportedNamespaceAwareLocalScopeProvider

and then when scoping i put all the packages i will be needing on the generated class, like this:
	@Override
	protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(EObject context, boolean ignoreCase) {
		List<ImportNormalizer> importedNamespaceResolvers = super.internalGetImportedNamespaceResolvers(context, ignoreCase);
		String ownNamespace = EcoreUtil2.getContainerOfType(context, Model.class).getName()+ ".*";
		importedNamespaceResolvers.add(createImportedNamespaceResolver(ownNamespace, ignoreCase));
		importedNamespaceResolvers.add(createImportedNamespaceResolver("core.services.*", true));
		importedNamespaceResolvers.add(createImportedNamespaceResolver("java.lang.*", true));
		importedNamespaceResolvers.add(createImportedNamespaceResolver("request.*", true));
		return importedNamespaceResolvers;
	}

which should cover CommandResponse (is in request.CommandResponse) .
But when i run the code, the editor freezes, i can't type or do anything useful with it.
so, i'm convinced there must be another way of doing this.
Can you suggest me a better way, one that works?
Thanks again, your help is much appreciated.
Re: Custom class reference in inferrer [message #1758626 is a reply to message #1758625] Thu, 30 March 2017 13:10 Go to previous messageGo to next message
Eclipse UserFriend
hi,

i dont understand why you do it this way. if you know the class name you can simply call

"full.qualified.ClassName".typeRef (instead of <ClassLiteral>.typeRef)
in your case e.g. "request.CommandResponse".typeRef
Re: Custom class reference in inferrer [message #1758627 is a reply to message #1758626] Thu, 30 March 2017 13:15 Go to previous message
Eclipse UserFriend
beautiful, thank you very much!.
Previous Topic:Parsing XBase in the inferrer
Next Topic:Question on ContentAssistProcessorTestBuilder#append
Goto Forum:
  


Current Time: Thu May 15 07:07:16 EDT 2025

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

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

Back to the top