Skip to main content



      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 05:20 Go to next message
Eclipse UserFriend
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 09:32 Go to previous messageGo to next message
Eclipse UserFriend
This should work out oft the box. Can you please share your complete grammar and your example project
Re: cann't reference the instance in jar file or classpath model [message #1690242 is a reply to message #1690148] Wed, 25 March 2015 20:58 Go to previous messageGo to next message
Eclipse UserFriend
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 145 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 02:19 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

please post your model projects (as exported zip) that dont work. in the example i created it works fine.
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 04:53 Go to previous message
Eclipse UserFriend

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: Sat Jul 12 17:00:55 EDT 2025

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

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

Back to the top