Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Creating an xbase Project(getting runtime errors)
Creating an xbase Project [message #946525] Tue, 16 October 2012 09:07 Go to next message
Martin Baker is currently offline Martin BakerFriend
Messages: 31
Registered: July 2009
Member
I have created an xbase project, mwe2 runs without any errors and creates the project. However when I run the project in a new instance of Eclipse I get the following error types:

* Couldn't resolve reference to JvmIdentifiableElement
* Couldn't resolve reference to JvmDeclaredType
* There is no context to infer the closure's argument types from.
* This expression is not allowed in this context, since it doesn't cause any side effects.

I am stuck because I don't know how to debug this sort of problem. I would appreciate any ideas about what I might try.

I am fairly certain that the grammar and JvmModelInferrer files are correct because I have adapted them from the 'script' example. So I guess there is some other file that needs to be setup or there is some other configuration setup that I need to do.

I have documented my approach on this page:
www.euclideanspace.com/software/development/eclipse/xtext/xbase/creating/

Also, on this page, I have put screen shots of each stage and a full list of the errors:
www.euclideanspace.com/software/development/eclipse/xtext/xbase/build/

I would appreciate any help with this.

Also is there any other background reading that I can do on xbase (apart from the documentation here: http://www.eclipse.org/Xtext/)?
It might help if I understood its workings a bit better, for instance, if a var is declared in the DSL how is it linked to further instances when it is used later in the DSL?

Martin
Re: Creating an xbase Project [message #946678 is a reply to message #946525] Tue, 16 October 2012 11:48 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1770
Registered: July 2009
Location: Firenze, Italy
Senior Member
when you run the new eclipse instance, have you created an Plug-in
Project? If so, please make sure to add xbase.lib bundle as a dependency.

hope this helps
cheers
Lorenzo

On 10/16/2012 11:07 AM, Martin Mising name wrote:
> I have created an xbase project, mwe2 runs without any errors and
> creates the project. However when I run the project in a new instance of
> Eclipse I get the following error types:
>
> * Couldn't resolve reference to JvmIdentifiableElement
> * Couldn't resolve reference to JvmDeclaredType
> * There is no context to infer the closure's argument types from.
> * This expression is not allowed in this context, since it doesn't cause
> any side effects.
>
> I am stuck because I don't know how to debug this sort of problem. I
> would appreciate any ideas about what I might try.
>
> I am fairly certain that the grammar and JvmModelInferrer files are
> correct because I have adapted them from the 'script' example. So I
> guess there is some other file that needs to be setup or there is some
> other configuration setup that I need to do.
>
> I have documented my approach on this page:
> www.euclideanspace.com/software/development/eclipse/xtext/xbase/creating/
>
> Also, on this page, I have put screen shots of each stage and a full
> list of the errors:
> www.euclideanspace.com/software/development/eclipse/xtext/xbase/build/
>
> I would appreciate any help with this.
>
> Also is there any other background reading that I can do on xbase (apart
> from the documentation here: http://www.eclipse.org/Xtext/)?
> It might help if I understood its workings a bit better, for instance,
> if a var is declared in the DSL how is it linked to further instances
> when it is used later in the DSL?
>
> Martin


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: Creating an xbase Project [message #946848 is a reply to message #946678] Tue, 16 October 2012 15:05 Go to previous messageGo to next message
Martin Baker is currently offline Martin BakerFriend
Messages: 31
Registered: July 2009
Member
> when you run the new eclipse instance, have you created an Plug-in
> Project? If so, please make sure to add xbase.lib bundle as a dependency.
>
> hope this helps
> cheers
> Lorenzo

Lorenzo,

Yes, thank you, I did what you suggested and I now only have one error:

Unhandled exception type java.io.IOException testfile.euclid2

I have now updated this page:
www.euclideanspace.com/software/development/eclipse/xtext/xbase/build/
to show how I am now calling the runtime instance of Eclipse.

I think it would be good if this information could be put into the Xtext documentation (or alternatively in Lorenzos tutorials) as it may not be obvious to beginners (at least it was not to me). You are most welcome to use, or adapt anything from the above webpage.

Also, as I mentioned before, I would welcome some sort of documentation/tutorial to explain how all the top level components of xbase fit together.

Thanks again,

Martin
Re: Creating an xbase Project [message #961520 is a reply to message #946848] Sun, 28 October 2012 10:44 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1770
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 10/16/2012 05:05 PM, Martin Baker wrote:
>> when you run the new eclipse instance, have you created an Plug-in
>> Project? If so, please make sure to add xbase.lib bundle as a dependency.
>>
>> hope this helps
>> cheers
>> Lorenzo
>

Hi there

some comments...

I took a quick look at your webpage; when I was talking about dep on
xbase.lib I was referring NOT to your Xtext project, but to the new
example project you create in the new Eclipse instance.

Concerning this part

"I tried to add org.eclipse.xtext.xbase.lib to Reqired Plugins and
imported packages in dependancies tab of MANIFEST.MF but
org.eclipse.xtext.xbase.lib was not availible in list. So instead I
right clicked on 'Plug-in Dependancies' Build path -> Configure Build
Path and added it there."

org.eclipse.xtext.xbase.lib was not available in the list because (I'm
pretty sure) your xtext project already depends on
org.eclipse.xtext.xbase which in turns already depends on
org.eclipse.xtext.xbase.lib (thus the dep you're trying to add should be
redundant).

> Lorenzo,
>
> Yes, thank you, I did what you suggested and I now only have one error:
>
> Unhandled exception type java.io.IOException testfile.euclid2
>

I did not completely understand what you are implementing, but you're
starting from the Script example, right?

in the testfile
(http://www.euclideanspace.com/software/development/eclipse/xtext/xbase/build/build16_400.png)
you access this method

public static List<String> readLines(File file, Charset charset)
throws IOException

from com.google.common.io right?

you see that this method throws an IOException and the Xbase validator
raises an error because your block does not handle exceptions at all...

try to wrap, in the example, that Files::readLines(...) into an Xbase
try catch block and the error should go away...

if you don't want to have to deal with exceptions in your DSL you have
to redefine the XbaseJavaValidator method which performs these checks

I've done something similar in one of my DSLs, e.g.,
http://sourceforge.net/p/xsemantics/code/ci/68395a1c0bed6fa2f3cdf7a0220a49d4f27c98ae/tree/plugins/it.xsemantics.dsl/src/it/xsemantics/dsl/validation/XsemanticsJavaValidator.java

@Override
protected boolean supportsCheckedExceptions() {
// we generate Java code which already handles exceptions
return false;
}

but, BE CAREFUL, you will then have to tweak code generation (i.e.,
XbaseCompiler) so that, for instance, the whole generated Java block is
wrapped inside a try catch block... otherwise, the generated Java code
will not compile...

hope this helps
Lorenzo

> I have now updated this page:
> www.euclideanspace.com/software/development/eclipse/xtext/xbase/build/
> to show how I am now calling the runtime instance of Eclipse.
>
> I think it would be good if this information could be put into the Xtext
> documentation (or alternatively in Lorenzos tutorials) as it may not be
> obvious to beginners (at least it was not to me). You are most welcome
> to use, or adapt anything from the above webpage.
>
> Also, as I mentioned before, I would welcome some sort of
> documentation/tutorial to explain how all the top level components of
> xbase fit together.
>
> Thanks again,
>
> Martin


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: Creating an xbase Project [message #962827 is a reply to message #961520] Mon, 29 October 2012 11:04 Go to previous message
Martin Baker is currently offline Martin BakerFriend
Messages: 31
Registered: July 2009
Member
Lorenzo,

Thanks, very much, for your reply.

> I did not completely understand what you are implementing, but
> you're starting from the Script example, right?

Yes, I was looking for very simple working xbase code which I could use as a stating point and then add my specific DSL features.

However I think I have found a better approach and I am having much more success with this. I am now basing my code on the xtend code. I did the following to give simple code which has basic object-oriented functionality and can be easily extended to add the special language features required for a given DSL.

I took the xtend grammar file and removed the 'rich string' stuff (The code is on the page below). I then constructed a simple JvmModelInferrer.xtend' file to generate the code from the grammar (code also on page below).

This is all I did, all the rest is just as generated by the 'new xtext' wizard. Obviously this does not have the same functionality as the xtend code, but its not intended to, it is intended as a very simple working code which can then be extended in various ways to add project specific DSL features as required.

See this page for the code and step by step instructions:
www.euclideanspace.com/software/development/eclipse/xtext/xbase/build/

What I would like is for the xtext developers to add a 'new xbase' wizard which would build such a project without having to add any code. It would also be good if they could provide better reference information to explain how to write the JvmModelInferrer.xtend file from scratch

Thanks again,

Martin
Previous Topic:Changing a cross-reference during generation
Next Topic:Customize proposals of a grammar
Goto Forum:
  


Current Time: Wed Sep 30 09:56:09 GMT 2020

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

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

Back to the top