Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Infer return type of XBlockExpression which refers Parameters
Infer return type of XBlockExpression which refers Parameters [message #814113] Tue, 06 March 2012 03:30
Jeeeyul Lee is currently offline Jeeeyul LeeFriend
Messages: 117
Registered: July 2009
Location: Seoul
Senior Member

My Operation Definitions takes parameters, a XBlockExpression(as body), and explicit return type optionally.

I want to let my user dosn't have to declare return type explicitly like xtend.

below codes do infer return type of my operation:
// have explicit return type
if(op.type != null){
	return op.type
}

// using Type Provider
var result = op.body.getType(true)
if(result == null || result.simpleName == "void"){
	result = evalBlock.getCommonReturnType(true)

	if(result == null){
		result = TypesFactory::eINSTANCE.createJvmAnyTypeReference
	}
}
return result.cloneWithProxies


the problem is when "return expression" refers parameters,
ITypeProvider can't evaluate actual return type
because of there is no type declaration of parameters in XBlockExpression.

So I tried like this:
var evalBlock = EcoreUtil2::cloneWithProxies(op.body) as XBlockExpression;
for(eachParm : op.params){
	var vd = XbaseFactory::eINSTANCE.createXVariableDeclaration
	vd.setType(eachParm.typeForIdentifiable.cloneWithProxies)
	vd.setName(eachParm.simpleName)
}


But TypeProvider have throw an exception which says this block does not belongs to an resource.

So, How can I infer return type?

[Updated on: Tue, 06 March 2012 03:33]

Report message to a moderator

Previous Topic:How can I let my xbase based language takes basic extension like Xtend does?
Next Topic:JvmModelGenerator seems to does not generate enumeration type.
Goto Forum:
  


Current Time: Thu Apr 25 12:36:44 GMT 2024

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

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

Back to the top