Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » strange behavior for navigation to elements
strange behavior for navigation to elements [message #1500079] Fri, 05 December 2014 17:16 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

in the editor of one of my DSLs based on Xbase (2.7.3) I see a strange
behavior concerning navigation:

- F3 always correctly jumps to the declaration (for Java type
references, feature references, etc.)
- Ctrl+click on a feature reference jumps to the return (Java) type (and
holding Ctrl pressed shows two options: "Open Return Type" and "Open
Implementation", so "Open Implementation" is not the default choice, and
I don't know where "Open Return Type" comes from)
- Ctrl+click on any Java type reference does not result in any effect
(not even on the XImportSection)

The JvmModelInferrer for this language infers several Java types and
several Java methods for the corresponding DSL elements, so I might have
done something wrong with model associations in the inferrer... any
hint on what to debug for the behavior of Ctrl+click?

The odd thing is that even with an XBlockExpression like this one

val my = "foo"
println(my)

Ctrl+clicking on "my" brings to the java.lang.String; and with that
respect, I haven't customized the syntax of Xbase expressions, nor the
XbaseCompiler.

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: strange behavior for navigation to elements [message #1503218 is a reply to message #1500079] Mon, 08 December 2014 09:02 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
This appears to be a bug. Please file a ticket with a simple grammar /
model inferrer attached.

Thanks,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: strange behavior for navigation to elements [message #1503346 is a reply to message #1503218] Mon, 08 December 2014 11:27 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/8/2014 10:02 AM, Sebastian Zarnekow wrote:
> This appears to be a bug. Please file a ticket with a simple grammar /
> model inferrer attached.
>
> Thanks,
> Sebastian

OK, I'll try to reproduce the problem with a simpler grammar and
inferrer; in the meantime, which Xbase's class could I debug?

thanks
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: strange behavior for navigation to elements [message #1503650 is a reply to message #1503346] Mon, 08 December 2014 17:04 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
I would start at the HyperlinkHelper or one of its subtypes.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: strange behavior for navigation to elements [message #1503669 is a reply to message #1503650] Mon, 08 December 2014 17:23 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/8/2014 6:04 PM, Sebastian Zarnekow wrote:
> I would start at the HyperlinkHelper or one of its subtypes.
>
> Best,
> Sebastian

Thanks! Before filing the bug, I'd really like to make sure I didn't
mess anything in my DSL ;)

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: strange behavior for navigation to elements [message #1504553 is a reply to message #1503650] Tue, 09 December 2014 10:56 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 08/12/2014 18:04, Sebastian Zarnekow wrote:
> I would start at the HyperlinkHelper or one of its subtypes.

Hi Sebastian

here are some findings first for the navigation to Java types that don't
work in my DSL:

- I cannot reproduce that with Domainmodel example because:

public class DomainmodelHyperlinkHelper extends TypeAwareHyperlinkHelper {

so it does NOT extend XbaseHyperlinkHelper (the default for Xbase
languages).

XbaseHyperlinkHelper overrides

/**
* If multiple links are requested, all ambiguous candidates are
provided for feature and constructor calls.
*/
@Override
public IHyperlink[] createHyperlinksByOffset(XtextResource resource,
int offset, boolean createMultipleHyperlinks) {
if (!createMultipleHyperlinks) {
return super.createHyperlinksByOffset(resource, offset,
createMultipleHyperlinks);
}
List<IHyperlink> links = Lists.newArrayList();
IHyperlinkAcceptor acceptor = new HyperlinkAcceptor(links);
INode crossRefNode =
getEObjectAtOffsetHelper().getCrossReferenceNode(resource, new
TextRegion(offset, 0));
if (crossRefNode == null) {
this.createHyperlinksByOffset(resource, offset, acceptor);
} else {
this.createHyperlinksForCrossRef(resource, crossRefNode, acceptor);
}
if (!links.isEmpty())
return Iterables.toArray(links, IHyperlink.class);
return null;
}

since createMultipleHyperlinks is true it does not call the super
implementation, and when it gets to createHyperlinksForCrossRef it does:

protected void createHyperlinksForCrossRef(XtextResource resource,
INode crossRefNode,
final IHyperlinkAcceptor acceptor) {
EObject containedElementAt =
getEObjectAtOffsetHelper().resolveContainedElementAt(resource,
crossRefNode.getOffset());
if (containedElementAt instanceof XAbstractFeatureCall) {...

so it creates hyperlinks only for XAbstractFeatureCall skipping
completely Java type references...

is this intentional or is it a bug?

cheers
Lorenzo


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: strange behavior for navigation to elements [message #1504573 is a reply to message #1504553] Tue, 09 December 2014 11:19 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 09/12/2014 11:56, Lorenzo Bettini wrote:
> On 08/12/2014 18:04, Sebastian Zarnekow wrote:
>> I would start at the HyperlinkHelper or one of its subtypes.
>
> Hi Sebastian
>
> here are some findings first for the navigation to Java types that don't
> work in my DSL:
>
> - I cannot reproduce that with Domainmodel example because:
>
> public class DomainmodelHyperlinkHelper extends TypeAwareHyperlinkHelper {
>
> so it does NOT extend XbaseHyperlinkHelper (the default for Xbase
> languages).
>
> XbaseHyperlinkHelper overrides
>
> /**
> * If multiple links are requested, all ambiguous candidates are
> provided for feature and constructor calls.
> */
> @Override
> public IHyperlink[] createHyperlinksByOffset(XtextResource resource,
> int offset, boolean createMultipleHyperlinks) {
> if (!createMultipleHyperlinks) {
> return super.createHyperlinksByOffset(resource, offset,
> createMultipleHyperlinks);
> }
> List<IHyperlink> links = Lists.newArrayList();
> IHyperlinkAcceptor acceptor = new HyperlinkAcceptor(links);
> INode crossRefNode =
> getEObjectAtOffsetHelper().getCrossReferenceNode(resource, new
> TextRegion(offset, 0));
> if (crossRefNode == null) {
> this.createHyperlinksByOffset(resource, offset, acceptor);
> } else {
> this.createHyperlinksForCrossRef(resource, crossRefNode, acceptor);
> }
> if (!links.isEmpty())
> return Iterables.toArray(links, IHyperlink.class);
> return null;
> }
>
> since createMultipleHyperlinks is true it does not call the super
> implementation, and when it gets to createHyperlinksForCrossRef it does:
>
> protected void createHyperlinksForCrossRef(XtextResource resource,
> INode crossRefNode,
> final IHyperlinkAcceptor acceptor) {
> EObject containedElementAt =
> getEObjectAtOffsetHelper().resolveContainedElementAt(resource,
> crossRefNode.getOffset());
> if (containedElementAt instanceof XAbstractFeatureCall) {...
>
> so it creates hyperlinks only for XAbstractFeatureCall skipping
> completely Java type references...
>
> is this intentional or is it a bug?
>
> cheers
> Lorenzo
>
>

So skipping XbaseHyperlinkHelper at all with this

@Override
public Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() {
return TypeAwareHyperlinkHelper.class;
}

solves also all my other problems of the original message...

Can this be considered a bug of XbaseHyperlinkHelper?

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: strange behavior for navigation to elements [message #1505955 is a reply to message #1504573] Wed, 10 December 2014 12:52 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
I didn't follow the code snippets closely but the observed behavior
could be a bug in the XbaseHyperlinkHelper, yes.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: strange behavior for navigation to elements [message #1506261 is a reply to message #1505955] Wed, 10 December 2014 18:14 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 10/12/2014 13:52, Sebastian Zarnekow wrote:
> I didn't follow the code snippets closely but the observed behavior
> could be a bug in the XbaseHyperlinkHelper, yes.

OK, I filed a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=454791


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Previous Topic:ResolvedOperations.getDeclaredOperations
Next Topic:Adding comments during serialization (without Node model)
Goto Forum:
  


Current Time: Fri Apr 26 13:29:58 GMT 2024

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

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

Back to the top