|
|
Re: Complete keyword with lookahead [message #828125 is a reply to message #828103] |
Sat, 24 March 2012 08:30 |
Alex G Messages: 96 Registered: January 2012 |
Member |
|
|
A template is a nice idea, thank you for the hint. But I don't think its the correct feature for me in this context. I want to look at the token "[i]" as a whole name and not providing a template of the form "'[' ... ']'".
Sure I can write a grammar like
IndexedType: ind=[Index | PrefixedID] "]"
PrefixedID: "[" ID;
and change the corresponding qualified name in order to use default XText features. But that's a sort of hack in the grammar.
So far I have overwritten completeKeyword which itself doesn't call lookUpCrossReferences but imitates this by manually calling the scope provider for objects of type Index. After that I call ICompletionAcceptor with changed ICompletionProposals.
But somehow I think that this way is a sort of hacky as well, since I have to overwrite the completeKeyword method. Eventually there might be for this kind of proposals ("concatenation" of proposals with lookahead) some corresponding API methods, but I haven't found any of these, since when calling the proposal provider before a keyword, I think, the only complete method which is called is completeKeyword.
[Updated on: Sat, 24 March 2012 08:31] Report message to a moderator
|
|
|
Re: Complete keyword with lookahead [message #828472 is a reply to message #828096] |
Sat, 24 March 2012 21:40 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Alex,
you can obtain the assignment from the YourDslGrammarAccess.
Instead of completeKeyword I'd try to specialize the complete_IndexType
implementation.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 24.03.12 03:23, schrieb Alex G:
> Hi!
>
> If one of the next grammar elements of a content assist context is a
> special keyword how can I propose at this context what follows after the
> keyword (without hacking the grammar with a special datatype)? For
> example, if the grammar snippet looks like
>
> IndexedType: "[" ind=[Index] "]"
>
> where "[" is keyword, I want to show up at the context offset before "["
> not only the keyword "[", but also the whole completion rule, like "[i]"
> as a proposal. The problem is, that the complete* and complete_* rules
> are not called at at context of a keyword, which has no feature assigned
> to it.
> The easiest way would be to override completeKeyword and call
> completeIndexedType_Ind which itself needs a non-null Assignment object,
> and I don't know where to get it from. Is there a better method to
> concatenate following proposals?
>
> Best regards,
> Alex.
|
|
|
Powered by
FUDForum. Page generated in 0.56574 seconds