Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Access a referenced JvmGenericType in the JvmModelInferrer
Access a referenced JvmGenericType in the JvmModelInferrer [message #1231289] Tue, 14 January 2014 09:22 Go to next message
Cioran Naroic is currently offline Cioran NaroicFriend
Messages: 18
Registered: December 2013
Junior Member
Hello everyone,

Here is my test grammar:
grammar some.grammar.example with org.eclipse.xtext.xbase.Xbase

generate example "http:/www.some.com/grammar/example/"

import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes

ModelRoot:
	(elements += ElementDecl)*
;

ElementDecl:
	'element' name = ValidID '{'
		referenced += ReferencedDecl*
	'}'
;

ReferencedDecl:
	'referenced' type = [jvmTypes::JvmGenericType | QualifiedName]
;


With an example:
element X {
	referenced my.package.ClassX
}


I would like to "browse" the declared operations, fields etc. of the referenced JvmGenericType in my implementation of JvmModelInferrer (I need to generate specific classes depending on the content of the referenced type).

I have no problem doing that in a "initializeLater" section, but all the fields of the referenced type are empty or null when I try to browse them outside an "initializeLater", and printing the type itself gives me:
"elem.type=JvmGenericType:  (eProxyURI: platform:/resource/some.grammar.example/src/some.grammar.example/test.example#xtextLink_::0.1.0.3.1::0::/2)


The problem is I can't do my browsing inside an "initializeLater" because I need to pass new classes to the acceptor depending on it, and I can't do that in this phase.

Do you have any idea of how I could browse the JvmGenericType in an infer(...) method? That is, resolving the proxy, changing something in my grammar or something like that?

Thank you,
Re: Access a referenced JvmGenericType in the JvmModelInferrer [message #1231671 is a reply to message #1231289] Wed, 15 January 2014 07:19 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
You cannot resolve any crossreferences when 'preIndexingPhase=true'.
This is because you run into a chicken and egg problem when you try to
look up types in order to contribute new types because you will change
the scope (the types available) and that would cause non-deterministic
behavior.

I thinl you'll have to reconsider your design.

Sven


Am 14/01/14 10:22, schrieb Cioran Naroic:
> Hello everyone,
>
> Here is my test grammar:
>
> grammar some.grammar.example with org.eclipse.xtext.xbase.Xbase
>
> generate example "http:/www.some.com/grammar/example/"
>
> import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes
>
> ModelRoot:
> (elements += ElementDecl)*
> ;
>
> ElementDecl:
> 'element' name = ValidID '{'
> referenced += ReferencedDecl*
> '}'
> ;
>
> ReferencedDecl:
> 'referenced' type = [jvmTypes::JvmGenericType | QualifiedName]
> ;
>
>
> With an example:
>
> element X {
> referenced my.package.ClassX
> }
>
>
> I would like to "browse" the declared operations, fields etc. of the
> referenced JvmGenericType in my implementation of JvmModelInferrer (I
> need to generate specific classes depending on the content of the
> referenced type).
>
> I have no problem doing that in a "initializeLater" section, but all the
> fields of the referenced type are empty or null when I try to browse
> them outside an "initializeLater", and printing the type itself gives me:
>
> "elem.type=JvmGenericType: (eProxyURI:
> platform:/resource/some.grammar.example/src/some.grammar.example/test.example#xtextLink_::0.1.0.3.1::0::/2)
>
>
>
> The problem is I can't do my browsing inside an "initializeLater"
> because I need to pass new classes to the acceptor depending on it, and
> I can't do that in this phase.
>
> Do you have any idea of how I could browse the JvmGenericType in an
> infer(...) method? That is, resolving the proxy, changing something in
> my grammar or something like that?
>
> Thank you,
>


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Previous Topic:Determine differences between two representations of an EObject
Next Topic:Browse a type passed to AbstractModelInferrer
Goto Forum:
  


Current Time: Fri Nov 27 18:56:49 GMT 2020

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

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

Back to the top