Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext versions, sortBy and XBlockExpression(The five step tutorial)
icon11.gif  Xtext versions, sortBy and XBlockExpression [message #841480] Wed, 11 April 2012 11:17 Go to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 149
Registered: March 2010
Senior Member
Hello,

A boring question about the five-step-tutorial.

I am using Eclipse Indigo where I've installed Xtext 2.1.1.v201111141332 from the update site for releases.

Upon finishing the tutorial, when I launch the runtime Eclipse to test it I see that my editor does not seem to recognize the XBlockExpression propertly. Specifically, the following declaration in the editor does not support the expression:

        op getFullName() : String {
            return firstName + " " + name;
        }


The above generates the error "Couldn't resolve reference to JvmIdentifiableElement '+'." in the problems view. If I simply do a "return firstName" instead of using the string concatenation expression, the error goes away. The body in the tutorial is defined as follows:

Operation:
    'op' name=ValidID 
        '('(params+=FullJvmFormalParameter 
            (',' params+=FullJvmFormalParameter)*)?')'
        ':' type=JvmTypeReference
        body=XBlockExpression;


So why does XBlockExpression not accept this? I had some problems with the tutorial due to using the wrong version of Xtext, but I think v2.1.1 which I am now using is what that tutorial targets.

[Updated on: Wed, 11 April 2012 11:21]

Report message to a moderator

Re: Xtext versions, sortBy and XBlockExpression [message #841491 is a reply to message #841480] Wed, 11 April 2012 11:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Make sure you add xbase.lib to the deps of the model files project

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext versions, sortBy and XBlockExpression [message #841513 is a reply to message #841491] Wed, 11 April 2012 12:13 Go to previous messageGo to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 149
Registered: March 2010
Senior Member
Hi,

By default, my tutorial project depends on "org.eclipse.xtext.xbase". The plug-in dependencies view tells me that "org.eclipse.xtext.xbase" depends on "org.eclipse.xtext.xbase.lib". So I believe that this is transitively brought into play. In any case, I copy-pasted the dependency into the MANIFEST.MF so my required bundles now look like this (last line added by me):

Require-Bundle: org.eclipse.xtext;bundle-version="2.1.1";visibility:=reexport,
 org.eclipse.xtext.xbase;bundle-version="2.1.1";resolution:=optional;visibility:=reexport,
 org.apache.log4j;bundle-version="1.2.15";visibility:=reexport,
 org.apache.commons.logging;bundle-version="1.0.4";resolution:=optional;visibility:=reexport,
 org.eclipse.xtext.generator;resolution:=optional,
 org.eclipse.emf.codegen.ecore;resolution:=optional,
 org.eclipse.emf.mwe.utils;resolution:=optional,
 org.eclipse.emf.mwe2.launch;resolution:=optional,
 org.eclipse.xtext.util,
 org.eclipse.emf.ecore,
 org.eclipse.emf.common,
 org.antlr.runtime,
 org.eclipse.xtext.common.types,
 org.eclipse.xtext.xtend2.lib,
 org.eclipse.xtext.xbase.lib;bundle-version="2.1.1"


I restarted the runtime Eclipse workbench and forced a rebuild by editing the dmodel file and also doing a Project->Clean. Still the situation persists (see image).
  • Attachment: xtext-err.png
    (Size: 64.82KB, Downloaded 171 times)
Re: Xtext versions, sortBy and XBlockExpression [message #841526 is a reply to message #841513] Wed, 11 April 2012 12:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi I am talking about the project containing the model file

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext versions, sortBy and XBlockExpression [message #841533 is a reply to message #841526] Wed, 11 April 2012 12:39 Go to previous messageGo to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 149
Registered: March 2010
Senior Member
I created a plug-in project and added the xbase.lib project as you suggested. This works.

Since I intend to use the model in non-PDE projects (i.e. simple Java projects), I addedthe xbase.lib jar (along with its single dependency) to my simple java project and this also seems to work:

org.eclipse.xtext.xbase.lib_2.1.1.v201111141332.jar
com.google.collect_1.0.0.v201105210816.jar

I suppose this approach is valid for non-PDE projects?
Re: Xtext versions, sortBy and XBlockExpression [message #841541 is a reply to message #841533] Wed, 11 April 2012 12:46 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
There is a libary var you could add too. I guess it is called Extend
Libary


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Is there a way to disable Crossreference errors from UI completely?
Next Topic:XText in Standalone Application
Goto Forum:
  


Current Time: Thu Apr 25 12:45:38 GMT 2024

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

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

Back to the top