|
Re: [Xcore] [message #1738240 is a reply to message #1738190] |
Mon, 18 July 2016 06:46   |
Eclipse User |
|
|
|
Where is Vector2f defined/implemented?
Looking at the logic in
org.eclipse.emf.ecore.util.EcoreValidator.validateEStructuralFeature_ValidDefaultValueLiteral(EStructuralFeature,
DiagnosticChain, Map<Object, Object>) there's code like this:
// If there is a conversion delegate then the lack of a
default value really does indicate that there is a problem converting
the literal to a value.
//
EDataType.Internal.ConversionDelegate conversionDelegate =
((EDataType.Internal)eDataType).getConversionDelegate();
if (conversionDelegate != null)
{
And Xcore does set the conversion delegate, which needs to be able to
run your code. That happens in
org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EDataType, String)
EDataType.Internal.ConversionDelegate conversionDelegate =
((EDataType.Internal)eDataType).getConversionDelegate();
if (conversionDelegate != null)
{
return conversionDelegate.createFromString(stringValue);
}
Perhaps this isn't working because the class can't be loaded. So I
wonder is the class in that project, or is it from some library in
another project, or what?
On 18.07.2016 01:11, ealrann xor wrote:
> Hello,
> I'm trying to set the default value of a wrapped class (I want to
> avoid the default null value). A little example :
>
>
> class PositionObject
> {
> PointF position = "1;2" // new Vector2f(1, 2)
> }
>
> type PointF wraps Vector2f create
> {
> if(it != null)
> {
> val String[] split = it.split(";")
> if(split.length == 2)
> {
> new Vector2f(Float.valueOf(split.get(0)),
> Float.valueOf(split.get(1)))
> }
> }
> new Vector2f
> }
> convert
> {
> it.x + ";" + it.y
> }
>
>
>
> Unfortunately, Xcore doesn't allow the PointF position = "1;2" (the
> error message : "The default value literal '1;2' must be a valid
> literal of the attribute's type").
>
> But : if I remove the create and convert part, the error message
> disappears (but the generated code no longer knows how to parse my
> string :( ).
> Did I missed something ?
>
> If I can't do that, how can I just set a default value like PointF
> position = new Vector2f() ?
|
|
|
|
|
|
|
|
Re: [Xcore] [message #1738298 is a reply to message #1738293] |
Mon, 18 July 2016 14:53   |
Eclipse User |
|
|
|
Yes, I noticed that too. Feel free to open a Bugzilla for that. There's
already a bugzilla about cyclic rebuilds. In this case, it seems as if
two builds are really needed because until the class wrapped by the data
type is built, it can't be loaded and resolved by the Xcore model. It
sounds like a tricky problem for sure...
On 18.07.2016 19:26, ealrann xor wrote:
> Better with Neon, but I still have the error :
>
> At first look, your sample project is working on Neon, but the error
> still appears when you clean the project. At this time, the only way
> to remove the error is to edit the .xcore and save it.
>
> I tried with a clean install of Neon EMF (windows x64), with xcore
> from update site.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04471 seconds