Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » cross-reference linking and xbase
cross-reference linking and xbase [message #1734949] Tue, 14 June 2016 05:26 Go to next message
Johannes Beichter is currently offline Johannes BeichterFriend
Messages: 5
Registered: November 2011
Junior Member
Hi,

I'm having trouble getting cross-references between two containment
subtrees of my dsl to work with xbase, I get "cannot be resolved" for
the reference "L2a.L3a" in the following example. The scope doesn't seem
to be the problem since "L2a.L3a" is proposed by auto completion.

level1 L1 {
level2a L2a {
level3a L3a
}
level2b L2b {
level3b ref L2a.L3a
}
}

Here's the grammar (with common.Terminals the linking works OOTB):

//grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals // -> works
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase
// -> ref cannot be resolved

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
Level1;

Level1:
'level1' name=ID '{'
childrenA+=Level2A*
childrenB+=Level2B*
'}';

Level2A:
'level2a' name=ID '{'
children+=Level3A*
'}';

Level3A:
'level3a' name=ID;

Level2B:
'level2b' name=ID '{'
children+=Level3B*
'}';

Level3B:
'level3b' 'ref' level3a=[Level3A|QualifiedName];

QualifiedName:
(ID '.')* ID;

Thank you for any help on this problem!
Re: cross-reference linking and xbase [message #1734952 is a reply to message #1734949] Tue, 14 June 2016 05:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13186
Registered: July 2009
Senior Member
first of all your grammar gives this warning

warning(200): ../org.xtext.example.mydsl1/src-gen/org/xtext/example/mydsl1/parser/antlr/internal/InternalMyDsl.g:424:3: Decision can match input such as "RULE_ID '.' RULE_ID" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input

xbase solves this by

QualifiedName:
ValidID (=>'.' ValidID)*;

and you should do that as well

then there is another problem when using xbase:

xbase does not allow relative imports.

if you have name a.b.c

and do a import a.*

then b.c is not allowed.

this is caused by

org.eclipse.xtext.xbase.scoping.XImportSectionNamespaceScopeProvider.doCreateImportNormalizer(QualifiedName, boolean, boolean)

see javadoc of AbstractNestedTypeAwareImportNormalizer

so the question is: do you actually need xbase?
do you import java types and non java types as well?

and if so how shall relative imports behave?
do you want realative implicit imports at all?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: cross-reference linking and xbase [message #1734953 is a reply to message #1734952] Tue, 14 June 2016 06:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13186
Registered: July 2009
Senior Member
you may comment on https://bugs.eclipse.org/bugs/show_bug.cgi?id=495047

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: cross-reference linking and xbase [message #1735029 is a reply to message #1734952] Tue, 14 June 2016 19:10 Go to previous message
Johannes Beichter is currently offline Johannes BeichterFriend
Messages: 5
Registered: November 2011
Junior Member
Thank you very much for all the advice. Content assist made me think
that links were intended to work the way it completes the references,
but as I understand it that's only a bug with content assist.

> so the question is: do you actually need xbase?
> do you import java types and non java types as well?

The answer to the second question is NO, there are no links to Java.

And I would really prefer to get rid of xbase if I don't need it.

So I'll post the problem that made me include xbase into my grammar in
the first place separately. Then maybe someone can help me out with a
more elegant, xbase-free solution for my original problem. Then the
cross-linking should work OOTB. If not I'll follow this path again.

Thanks again.
Previous Topic:Bundle Exception - Error when launching Eclipse Application
Next Topic:getting the file path and accessing project files
Goto Forum:
  


Current Time: Wed Nov 13 09:44:34 GMT 2019

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

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

Back to the top