Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338522

Summary: ElementInitializer.xpt and Sequence{IntegerValue}
Product: [Modeling] GMF-Tooling Reporter: Ralph Gerbig <ralphgerbig>
Component: CoreAssignee: Ralph Gerbig <ralphgerbig>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: mistria
Version: unspecifiedFlags: mistria: review+
Target Milestone: 2.4   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch borlander: iplog+, borlander: review+

Description Ralph Gerbig CLA 2011-03-01 06:03:44 EST
Build Identifier: 20100917-0705

Hi,

i have the a OCL Expression (Sequence{0,0}) to initialize a EInt[2..*] EMF List. For this not compilable code is generated. The following lines of ElementInitializer are responsible for this:

----------------------------------------------------------------------------
«IF getTypeGenClassifier(feature).expressionResultNeedsCast()-»
		for (java.util.Iterator it = ((java.util.Collection) «expressionVarName»).iterator(); it.hasNext(); ) {
			Object next = «diagramElement.getDiagram().editorGen.expressionProviders.getAbstractExpressionQualifiedClassName()».performCast(it.next(), «EXPAND MetaModel::MetaClass FOR getTypeGenClassifier(feature)»);
			«EXPAND MetaModel::getFeatureValue(instanceVar, instanceClass, true) FOR feature».add(next);
		}
«ELSE-»
-------------------------------------------------------------------------------

- getTypeGenClassifier(feature).expressionResultNeedsCast() recognizes that my Integers need a type cast as they are numeric values.
- Object next = «diagramElement.getDiagram() ... does produce an Object, but for the code to work I need an Integer.
- I need to change «EXPAND MetaModel::getFeatureValue(instanceVar, instanceClass, true) FOR feature».add(next); to «EXPAND MetaModel::getFeatureValue(instanceVar, instanceClass, true) FOR feature».add((Integer)next); by hand to work.

Reproducible: Always
Comment 1 Mickael Istria CLA 2011-03-01 06:55:42 EST
Do you think you could provide a patch for this bug?
Comment 2 Ralph Gerbig CLA 2011-03-03 11:38:15 EST
(In reply to comment #1)
> Do you think you could provide a patch for this bug?

I do have this line running perfectly:

«EXPAND MetaModel::getFeatureValue(instanceVar, instanceClass, true) FOR feature».add((«EXPAND MetaModel::QualifiedClassName /*XXX sorta hack, better would be MM::setFeatureValue that supports lists*/FOR getTypeGenClassifier(feature)») next);

I copyied the type cast from some lines beneath. It works with string, boolean and integer lists for me.
Comment 3 Ralph Gerbig CLA 2011-07-01 02:48:00 EDT
Still in 2.4.0.
Comment 4 Mickael Istria CLA 2011-07-01 04:02:04 EDT
Can you please provide your suggested modification as a patch (checkout the org.eclipse,gmf.codegen, apply your modification, and then use Team>Create Patch) ?
Comment 5 Ralph Gerbig CLA 2011-07-05 02:52:34 EDT
Created attachment 199087 [details]
Patch
Comment 6 Mickael Istria CLA 2011-07-05 06:27:14 EDT
Patch seems clean enough. I've run tests with the patch and they are still green.

I committed your patch, and it will be available in 2.4.0. You can get an interim unofficial experimental build here: https://hudson.eclipse.org/hudson/job/tycho-gmp.gmf.tooling/

Thanks a lot Ralph.
Comment 7 Michael Golubev CLA 2011-07-13 19:45:47 EDT
version -> 2.4
Comment 8 Michael Golubev CLA 2011-07-14 07:51:37 EDT
Rollback, Set target to 2.4 instead of accidenatlly set Version
Comment 9 Michael Golubev CLA 2011-07-14 07:55:00 EDT
Comment on attachment 199087 [details]
Patch

to be included into IP log