Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364810 - Xtend validation and JvmArrayType implementation issue
Summary: Xtend validation and JvmArrayType implementation issue
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.1.1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-25 05:37 EST by Serano Colameo CLA
Modified: 2017-09-19 18:03 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serano Colameo CLA 2011-11-25 05:37:37 EST
Build Identifier: Xtext/Xtend 2.1.1.v201111141332

in xtext 2.1.1. this xtend snipped does not work anymore:

	def String getName(JvmArrayType jvmArrayType) {
		return jvmArrayType.identifier
	}

The validation says: Couldn't resolve reference to JvmIdentifiableElement 'identifier' although the "identifier" member appears in the code completion dialog.

There are two implementation for JvmArrayType:
- JvmArrayTypeImpl
- JvmArrayTypeImplCustom

When we debug the code JvmArrayTypeImplCustom is instantiated and there is a method getIdentifier.

However, it's really confusing now how to use this stuff....

/serano

Reproducible: Always

Steps to Reproduce:
1. create DomainModell example
2. put this snippet in the DomainmodelJvmModelInferrer.xtend

	def String getName(JvmArrayType jvmArrayType) {
		return jvmArrayType.identifier
	}

3.
Comment 1 Sven Efftinge CLA 2011-11-25 05:47:48 EST
I cannot reproduce this with the latest head.
I created an empty class containing the method you mentioned. Works for me.
Comment 2 Serano Colameo CLA 2011-11-25 05:51:43 EST
(In reply to comment #1)
> I cannot reproduce this with the latest head.
> I created an empty class containing the method you mentioned. Works for me.

ok, but we work with the official released version and not with the "latest from head".

did you try with the official release as well?

/serano
Comment 3 Serano Colameo CLA 2011-11-25 06:04:07 EST
(In reply to comment #2)
> (In reply to comment #1)
> > I cannot reproduce this with the latest head.
> > I created an empty class containing the method you mentioned. Works for me.
> 
> ok, but we work with the official released version and not with the "latest
> from head".
> 
> did you try with the official release as well?
> 
> /serano

btw, this works fine:

	def String getName(JvmArrayType jvmArrayType) {
		return (jvmArrayType as JvmArrayTypeImpl).identifier
	}

please use DomainmodelJvmModelInferrer.xtend to reproduce the same behavior.

/serano
Comment 4 Serano Colameo CLA 2011-11-25 06:25:27 EST
here another sample code to reproduce:

package org.eclipse.xtext.example.domainmodel.jvmmodel

import com.google.inject.Inject
import org.eclipse.xtext.common.types.JvmArrayType
import org.eclipse.xtext.common.types.JvmDeclaredType
import org.eclipse.xtext.example.domainmodel.domainmodel.Entity
import org.eclipse.xtext.naming.IQualifiedNameProvider
import org.eclipse.xtext.util.IAcceptor
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder
import org.eclipse.xtext.common.types.impl.JvmArrayTypeImpl

class Test {
	
	@Inject extension JvmTypesBuilder
	@Inject extension IQualifiedNameProvider

	def test(Entity e, IAcceptor<JvmDeclaredType> acceptor) {
		acceptor.accept(
			e.toClass( e.fullyQualifiedName ) [
				documentation = e.documentation
			]
		)
	}
	
	def String getName(JvmArrayType jvmArrayType) {
//	enable for validation error:
 		return jvmArrayType.identifier
//	enable this statement and it works:
//		return (jvmArrayType as JvmArrayTypeImpl).identifier
	}
}
Comment 5 Sebastian Zarnekow CLA 2011-11-25 06:29:42 EST
Serano, you are right, there was a bug in 2.1.1
However, it is already fixed for 2.2
Comment 6 Karsten Thoms CLA 2017-09-19 17:52:28 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 7 Karsten Thoms CLA 2017-09-19 18:03:10 EDT
Closing all bugs that were set to RESOLVED before Neon.0