Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » referencing java methods
referencing java methods [message #891900] Tue, 26 June 2012 13:22 Go to next message
peter  is currently offline peter Friend
Messages: 5
Registered: December 2011
Junior Member
Hy,
Is it possible to refer to java methods in a model?
For instance my model may look like this:
A = javaMethod(a);
//where java method (static or member) is defined in a class contained in a jar file in the same project.

I've tried to create an IScope from scratch, but it seems that I need an EMF representation for the .jar resources. Am I right?
Re: referencing java methods [message #894821 is a reply to message #891900] Tue, 10 July 2012 16:17 Go to previous messageGo to next message
peter  is currently offline peter Friend
Messages: 5
Registered: December 2011
Junior Member
Can someone help me with this?
I've tried to use my own IResourceServiceProvider for the .jar via an extension point like in this post:
xtext-2-0-and-uml
but nothing happens, there is no implemented method that is called at runtime.
It seems that I have serious problems With scoping API.
Another alternative that I experimented was Xtend, but this is also very far for my understanding limits, so I rather prefer to implement my own scopes.
Re: referencing java methods [message #894838 is a reply to message #894821] Tue, 10 July 2012 17:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
Registered: July 2009
Senior Member
Hi,

the basic problem is that your requirement is
"a class" and not "a certain class"
this makes it hard to reuse the out of the box java support

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: referencing java methods [message #894845 is a reply to message #891900] Tue, 10 July 2012 18:17 Go to previous messageGo to next message
peter  is currently offline peter Friend
Messages: 5
Registered: December 2011
Junior Member
Hello,
I don't Know what you mean by out of the box, "a class" ..."a certain class".
I'll try to explain better my problem, which by the way seemed to be trivial by means of xtext scopes...but...
My model.mydsl resource is contained in a project that has a particular nature: no classpath, no jdt nature, just Xtext nature and my own nature.
The project is also containing a list of Jar files as resources implementing some numerical methods.
I need that all those methods annotated in my own style be exported outside and visible in my model.mydsl. I've already implemented my own style provider for method names. The problem is that I'm not able to adapt these method names to an IEObjectDescription...for an IScope build from scratch.
My previous experience:
The IResourceServiceProvider solution has the same effect....
Building EObjects on the fly leads to dangling references...
JvmTypes is too hard to understand...
...I don't know what else to do...please help.
Re: referencing java methods [message #894848 is a reply to message #894845] Tue, 10 July 2012 18:32 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
Registered: July 2009
Senior Member
Hi,

the basic problem is: give me a list of classes or classnames that should be searched.
if you have that you have won. if not it might be very tricky ( i have no idea so far)

so are you able to give me a list of classnames and method names?
is it discussable to turn the project to a java project and add the classes to the classpath of that project?
what do you do if there are two classes with the same method name?

thus we could make it working with jvmtypes.

if you build something on your own you have to solve the "dangling refs problem"
e.g. by building something similar to TypeResource

you should also consider to solve the problem by using a string and using a utility for check/contentassist/codegeneration to
find the real clas/method

~Christian



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Package declaration
Next Topic:problems with the OnTheFlyJavaCompiler
Goto Forum:
  


Current Time: Fri Feb 21 10:33:30 GMT 2020

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

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

Back to the top