Home » Modeling » TMF (Xtext) » TemplateProposal leads to endless loop
TemplateProposal leads to endless loop [message #1780195] |
Thu, 18 January 2018 14:18 |
Tobias W. Messages: 10 Registered: May 2017 |
Junior Member |
|
|
Hi everybody,
today I stumbled across a really strange problem. Everytime I try to use CodeCompletion via ctrl+space in a certain place the AntlrProposalConflictHelper hangs in an endless loop in the equalTokenSequence(TokenSource first, TokenSource second) method.
My DSL grammar is this:
Method: 'method' name=ID fireAndForget?=FireAndForget? '(' methodArguments+=MethodArgument? (',' methodArguments+=MethodArgument)* ')';
FireAndForget: '[fireAndForget]';
MethodArgument: InArgument | OutArgument | InOutArgument;
InArgument: direction='in' type=PATH name=ID;
OutArgument: direction='out' type=PATH name=ID;
InOutArgument: direction='inout' type=PATH name=ID;
terminal fragment DIGIT: '0'..'9';
terminal fragment LOWERCASE_LETTER: 'a'..'z';
terminal fragment UPPERCASE_LETTER: 'A'..'Z';
terminal ID: (LOWERCASE_LETTER|UPPERCASE_LETTER|'_') (LOWERCASE_LETTER|UPPERCASE_LETTER|DIGIT|'_')*;
terminal PATH: ('/' ID)+;
But when I now type: "method MyMethod ()" with the cursor between the brackets and trying to use CodeCompletion via ctrl+space the application hangs.
This is what the data in the equalTokenSequence(TokenSource first, TokenSource second) looks like when it happens:
first data [$, {, i, n, }, , $, {, t, y, p, e, }, , $, {, n, a, m, e, }]
token [@-1,0:-1='',<9>,1:0]
text
second data [(, $, {, i, n, }, , $, {, t, y, p, e, }, , $, {, n, a, m, e, }]
token [@-1,1:0='',<9>,1:1]
text
The method reads in the next token in a while loop but the next token is always the same like written above.
Any idea what the problem could be? Is there something wrong with my grammar?
Greetings
Tobias
|
|
|
Re: TemplateProposal leads to endless loop [message #1780211 is a reply to message #1780195] |
Thu, 18 January 2018 15:51 |
|
Tobias,
I tried your sample that you gave and do not experience a problem with my Xtext 2.14 developer workspace. Which Xtext version do you use? I suppose you printed only the relevant part of your grammar, but not the complete. The grammar I took is:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
methods+=Method*;
Method: 'method' name=ID fireAndForget?=FireAndForget? '(' methodArguments+=MethodArgument? (',' methodArguments+=MethodArgument)* ')';
FireAndForget: '[fireAndForget]';
MethodArgument: InArgument | OutArgument | InOutArgument;
InArgument: direction='in' type=PATH name=ID;
OutArgument: direction='out' type=PATH name=ID;
InOutArgument: direction='inout' type=PATH name=ID;
terminal fragment DIGIT: '0'..'9';
terminal fragment LOWERCASE_LETTER: 'a'..'z';
terminal fragment UPPERCASE_LETTER: 'A'..'Z';
terminal ID: (LOWERCASE_LETTER|UPPERCASE_LETTER|'_') (LOWERCASE_LETTER|UPPERCASE_LETTER|DIGIT|'_')*;
terminal PATH: ('/' ID)+;
If you can give a reproducing example with Xtext 2.13 please file a bug.
~Karsten
|
|
|
Re: TemplateProposal leads to endless loop [message #1780215 is a reply to message #1780211] |
Thu, 18 January 2018 16:37 |
Tobias W. Messages: 10 Registered: May 2017 |
Junior Member |
|
|
Hi Karsten,
we are currently working with Xtext 2.12.0. The grammar is too long to post here but the complete relevant parts are the following (we don't use org.eclipse.xtext.common.Terminals):
grammar com.example.dsl.Ara hidden(WS, ML_COMMENT, SL_COMMENT)
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate ara "http://www.example.com/dsl/Ara"
Domainmodel:
{Domainmodel}
declarations+=AbstractDeclaration*
;
AbstractDeclaration:
Interface
;
Interface:
'Interface' name=PATH '{'
methods+=Method*
'}'
;
Method:
'method' name=ID fireAndForget?=FireAndForget? '('
methodArguments+=MethodArgument*
')'
;
FireAndForget:
'[fireAndForget]'
;
MethodArgument:
InArgument | OutArgument | InOutArgument
;
InArgument:
'in' type=PATH name=ID
;
OutArgument:
'out' type=PATH name=ID
;
InOutArgument:
'inout' type=PATH name=ID
;
terminal fragment DIGIT:
'0'..'9'
;
terminal fragment LOWERCASE_LETTER:
'a'..'z'
;
terminal fragment UPPERCASE_LETTER:
'A'..'Z'
;
terminal ID:
(LOWERCASE_LETTER|UPPERCASE_LETTER|'_') (LOWERCASE_LETTER|UPPERCASE_LETTER|DIGIT|'_')*
;
terminal PATH:
('/' ID)+
;
terminal ML_COMMENT:
'/*' -> '*/'
;
terminal SL_COMMENT:
'//' !('\n'|'\r')* ('\r'? '\n')?
;
terminal WS:
(' '|'\t'|'\r'|'\n')+
;
As you can see I tweaked the Method-ParserRule a little bit but also with no success. But in all other places in our DSL CodeCompletion works just fine. If we remove the Templates for the 3 Arguments from the TemplateStore at least it doesn't get into the endless loop, but also the Templates are not available of course. The only proposals are then 'in' 'out' and 'inout'.
Has there something changed in the handling of Antlr and Tokens between 2.12.0 and 2.13/2.14?
I will try to test it with Xtext >2.12.0 and see if this changes anything
Greetings
Tobias
[Updated on: Thu, 18 January 2018 16:39] Report message to a moderator
|
|
| | | | | | |
Goto Forum:
Current Time: Fri Apr 19 03:05:58 GMT 2024
Powered by FUDForum. Page generated in 0.02349 seconds
|