Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Custom class reference in inferrer
Custom class reference in inferrer [message #1758625] Thu, 30 March 2017 17:04 Go to next message
Rodrigo Ruiz is currently offline Rodrigo RuizFriend
Messages: 28
Registered: March 2017
Junior Member
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 17:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14067
Registered: July 2009
Senior Member
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


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom class reference in inferrer [message #1758627 is a reply to message #1758626] Thu, 30 March 2017 17:15 Go to previous message
Rodrigo Ruiz is currently offline Rodrigo RuizFriend
Messages: 28
Registered: March 2017
Junior Member
beautiful, thank you very much!.
Previous Topic:Parsing XBase in the inferrer
Next Topic:Question on ContentAssistProcessorTestBuilder#append
Goto Forum:
  


Current Time: Mon Sep 27 11:27:17 GMT 2021

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

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

Back to the top