Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Integration with Xbase - Domain model example
Integration with Xbase - Domain model example [message #1784961] Fri, 06 April 2018 10:37 Go to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
Hi,

I'm trying to play with the DomainModel example shipped with Xtext 2.12 and investigating how the inferrer works. However, the sample model given https://www.eclipse.org/Xtext/documentation/104_jvmdomainmodel.html does not work. Here are the error messages I'm getting:

Quote:
Couldn't resolve reference to JvmIdentifiableElement '+'. test.dmodel
Couldn't resolve reference to JvmIdentifiableElement 'sortBy'.


Just to be complete, here is the sample (copied from Xtext documentation)

import java.util.List
entity Person {
    name: String
    firstName: String
    friends: List<Person>
    address : Address
    op getFullName() : String {
        return firstName + " " + name;
    }
    
    op getFriendsSortedByFullName() : List<Person> {
        return friends.sortBy[ f | f.fullName ]
    }
}

entity Address {
    street: String
    zip: String
    city: String
}


and the grammar (also cross-checked with the template project and the Xtext web dec)

grammar org.eclipse.xtext.example.domainmodel.Domainmodel with
                                      org.eclipse.xtext.xbase.Xbase
 
generate domainmodel "http://www.xtext.org/example/Domainmodel"
 
Domainmodel:
    importSection=XImportSection?
    elements+=AbstractElement*;
 
AbstractElement:
    PackageDeclaration | Entity;
 
PackageDeclaration:
    'package' name=QualifiedName '{'
        elements+=AbstractElement*
    '}';
 
Entity:
    'entity' name=ValidID ('extends' superType=JvmTypeReference)? '{'
        features+=Feature*
    '}';
 
Feature:
    Property | Operation;
 
Property:
    name=ValidID ':' type=JvmTypeReference;
 
Operation:
    'op' name=ValidID 
        '('(params+=FullJvmFormalParameter 
        (',' params+=FullJvmFormalParameter)*)?')'
        ':' type=JvmTypeReference 
    body=XBlockExpression;


Any idea?
Thanks,
Cheers,
Fabian
Re: Integration with Xbase - Domain model example [message #1784971 is a reply to message #1784961] Fri, 06 April 2018 11:35 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 611
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Add Xbase Lib to the classpath of your project
Re: Integration with Xbase - Domain model example [message #1785023 is a reply to message #1784971] Sat, 07 April 2018 23:33 Go to previous messageGo to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
That perfectly makes sense... Newbie mistake. Thanks!

[Updated on: Sat, 07 April 2018 23:34]

Report message to a moderator

Re: Integration with Xbase - Domain model example [message #1785210 is a reply to message #1785023] Wed, 11 April 2018 00:16 Go to previous messageGo to next message
Mohammad MAZ is currently offline Mohammad MAZFriend
Messages: 1
Registered: April 2018
Junior Member
Hi,

I have the same problem. Having double checked the inclusion of Xbase lib in classpath, I still have the mentioned problem. In fact, I cannot use any binary operator, neither any built-in function call such as println(). Would you please elaborate more on this problem and the probable causes for that?

@Fabian: I am wondering if you could fix your problem. If yes, could you explain what exactly you did.

Best,
Mohammad
Re: Integration with Xbase - Domain model example [message #1785269 is a reply to message #1785210] Wed, 11 April 2018 19:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12229
Registered: July 2009
Senior Member
Can you post a screenshot of your runtime eclipse showing the dependency added

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Integration with Xbase - Domain model example [message #1785276 is a reply to message #1785210] Wed, 11 April 2018 21:41 Go to previous messageGo to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
I did it the "old-fashioned" way (simple Java project, no maven/gradle) by downloading the jar from Maven and adding the jar in my classpath (Configure Build Path > Librairies > Add Jars/external jars).

index.php/fa/32586/0/
Re: Integration with Xbase - Domain model example [message #1785282 is a reply to message #1785276] Thu, 12 April 2018 04:38 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 611
Registered: July 2009
Location: Dortmund, Germany
Senior Member

org.eclipse.xbase.lib has additional dependencies (e.g. Guava) that are missing here. Use Add Library on this page, Xtext ships a library container for convenience.
Re: Integration with Xbase - Domain model example [message #1785283 is a reply to message #1785282] Thu, 12 April 2018 05:05 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12229
Registered: July 2009
Senior Member
can you post a screenshot of the complete eclipse with project explorer and file open?
and did you check you inferrer twice?


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 12 April 2018 05:06]

Report message to a moderator

Previous Topic:Issue with a keyword interfering in another rule
Next Topic:Embed Editor
Goto Forum:
  


Current Time: Wed Sep 19 18:33:45 GMT 2018

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

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

Back to the top