Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » injectExpressionBody problem
injectExpressionBody problem [message #203311] Mon, 25 August 2008 16:23 Go to next message
Dennis Doubleday is currently offline Dennis DoubledayFriend
Messages: 3
Registered: July 2009
Junior Member
I'm having trouble using the new Java injectExpressionBody attribute. If I
specify an expression like "source != target" in the gmfmap file, the
generated expression method comes out like this:

public static boolean canExistLinkConditional_3003(Tasklet
container,
Node source,
Node target) {
try {
source != target
return true;
} catch (Exception e) {
TaskletDiagramEditorPlugin.getInstance().logError(
"Link constraint evaluation error", e); //$NON-NLS-1$
return false;
}
}
}

I can change the expression to "return source != target;" (which isn't
really an expression, it is a statement, but I digress...) But this is
still a compilation problem because the generated "return true;" is
unreachable code.

The only way I can see to work around this is to make the expression
something like: "if (source != target) return true; if (source == target)
return false;" which is pretty kludgy, but it might trick the compiler
into thinking the "return true;" is reachable.

Why is the "return true;" generated?
Re: injectExpressionBody problem [message #203343 is a reply to message #203311] Tue, 26 August 2008 06:48 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Dennis,

Are you using latest version of GMf sources? Can you please check org.eclipse.gmf.codegen/xpt/editor/VisualIDRegistry.xpt
template contents? In my version this file contains following DEFINE:

«DEFINE _domainElementConstraintMethod(GenCommonBase diagramElement, ValueExpression
expression, GenClass context) FOR GenJavaExpressionProvider-»
«EXPAND xpt::Common::generatedMemberComment»
private static boolean «EXPAND _domainElementConstraintMethodName FOR diagramElement»(«EXPAND
MetaModel::QualifiedClassName FOR context» domainElement) {
«IF injectExpressionBody && expression.body != null && expression.body.length()
!= 0-»
«expression.body»
«ELSEIF throwException || (injectExpressionBody && (expression.body == null
|| expression.body.length() == 0))-»
// FIXME: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new java.lang.UnsupportedOperationException("No java implementation
provided in '«EXPAND _domainElementConstraintMethodName FOR diagramElement»'
operation");«EXPAND xpt::Common::nonNLS»
«ELSE-»
return false;
«ENDIF-»
}
«ENDDEFINE»

in any case, correct value of the "body" property should be "return source
!= target".

-----------------
Alex Shatalin
Re: injectExpressionBody problem [message #203478 is a reply to message #203343] Tue, 26 August 2008 22:27 Go to previous messageGo to next message
Dennis Doubleday is currently offline Dennis DoubledayFriend
Messages: 3
Registered: July 2009
Junior Member
Alex Shatalin wrote:
> Hello Dennis,
>
> Are you using latest version of GMf sources?

The version is org.eclipse.gmf.codegen_2.1.0.v20080610-1132

The template looks as you described. I am at a loss to explain where
"return true;" is coming from. I didn't specify it.
Re: injectExpressionBody problem [message #203485 is a reply to message #203478] Wed, 27 August 2008 06:41 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Dennis,

Well, same with me.. Can I ask you to try re-generating .gmfgen model from
..gmfmap one once again + code into the clear plugin? This looks like a problem
with reconcile/merger subsystem... At least, from the template view the code
should be generated properly..

-----------------
Alex Shatalin
Previous Topic:Visual ID and graceful migration?
Next Topic:visual IDs and the .trace plugin
Goto Forum:
  


Current Time: Thu Apr 25 14:32:45 GMT 2024

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

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

Back to the top