Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » cann't reference the instance in jar file or classpath model
cann't reference the instance in jar file or classpath model [message #1690101] Wed, 25 March 2015 09:20 Go to next message
Bob Tao is currently offline Bob TaoFriend
Messages: 23
Registered: March 2015
Junior Member
Hi all,
I have a problem regarding to Global Scoping.
I define a xtext model as follow:
ModuleDeclaration:
	'Module' name= QualifiedName id=INT
;
PackageDeclaration:
  'package' name = [ModuleDeclaration | QualifiedName]   
;

I want refer the instance of module defined in a jar file. but which doesn't work.
for details.
Project 1 define one model file.
model1.dal:
Module Account 121

then, I export the file to a module1.jar file, which just includes this one file

Project 2 define another model file.
model2.dal:
Module Product 122


Project2 define a new model file.
add model1.jar and add require project2
package.dal:
package Xxx

the content assist only list "Product" model, doesn't list 'Account'
that is to say, XText cross reference from jar does not work as said in XText document.
Quote:
To enable support for this kind of global scoping in Xtext, a DefaultGlobalScopeProvider has to be bound to the IGlobalScopeProvider interface. By default Xtext leverages the class path mechanism since it is well designed and already understood by most of our users. The available tooling provided by JDT and PDE to configure the class path adds even more value. However, it is just a default: you can reuse the infrastructure without using Java and be independent from the JDT.

what should I do?
Should I customize the scope like this?
def scope_ModuleDeclaration(PackageDeclaration context, EReference ref)
{
   //parser all jar and build scope
}

the XText version is 2.7.3 I used.

Thanks!
Re: cann't reference the instance in jar file or classpath model [message #1690148 is a reply to message #1690101] Wed, 25 March 2015 13:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
This should work out oft the box. Can you please share your complete grammar and your example project

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: cann't reference the instance in jar file or classpath model [message #1690242 is a reply to message #1690148] Thu, 26 March 2015 00:58 Go to previous messageGo to next message
Bob Tao is currently offline Bob TaoFriend
Messages: 23
Registered: March 2015
Junior Member
Hi Christian,
Thank your reply!
my grammar file content is as following. it maybe is so long. so I just copy the part, and others are in the attached file.
(I modify the url because I got an error when I reply this post)
<code>
grammar org.eclipse.tools.dynattr.Dal with org.eclipse.xtext.common.Terminals

generate dal "this is a url"

Domainmodel:
(package=PackageDeclaration)?
(imports+=ImportDeclaration)*
(elements += AbstractElement)*
(modules +=ModuleDeclaration)*
;
ModuleDeclaration:
'Module' name= QualifiedName id=INT
;
PackageDeclaration:
'package' name = [ModuleDeclaration | QualifiedName]
;

ImportDeclaration:
'import' importedNamespace = QualifiedName | importedNamespace= QualifiedNameWithWildcard
;

AbstractElement:
FieldGroup | FieldSet | Field
;

QualifiedName:
ID ('.' ID)*
;
QualifiedNameWithWildcard:
QualifiedName ('.*')?
;
</code>
  • Attachment: Dal.xtext
    (Size: 4.48KB, Downloaded 125 times)
Re: cann't reference the instance in jar file or classpath model [message #1690249 is a reply to message #1690242] Thu, 26 March 2015 06:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

please post your model projects (as exported zip) that dont work. in the example i created it works fine.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
icon7.gif  Re: cann't reference the instance in jar file or classpath model [message #1690266 is a reply to message #1690249] Thu, 26 March 2015 08:53 Go to previous message
Bob Tao is currently offline Bob TaoFriend
Messages: 23
Registered: March 2015
Junior Member

Thank your help!

As you said, It works.
I guest the reason is I just refresh the external jar in the project view(on this way, though the jar is updated, the type index is not updated)

if the module1.jar is modified, it should been removed from libraries and then been added it again, which will trigger index function.


Previous Topic:How to run xtext Junit tests outside eclipse
Next Topic:Code generator for Smalljava example
Goto Forum:
  


Current Time: Tue Apr 16 12:10:47 GMT 2024

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

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

Back to the top