Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content Assist don't work in first column of second line...
Content Assist don't work in first column of second line... [message #848050] Tue, 17 April 2012 22:48 Go to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Hi again,
I've implemented a new pilot to test importing resources stuffs... It is reaally cool !

But there are something wrong with content assist that I couldn't find why...:

If I type crtl-space in a empty file at first position, It shows me the content assist with Risk:, Roles: and import options.

So, If I choose any option and type enter, at the second line and first column the content assist doesn't work. It just works after I enter a space...

could someone give me a tip here?

That is my grammar:
grammar org.xtext.example.risks.RiskDsl with org.eclipse.xtext.common.Terminals hidden(WS, NewLine)

generate riskDsl "http://www.xtext.org/example/risks/RiskDsl"

RiskModel :
	{RiskModel}
	(
	(imports += Import*)
	(rolesLibrary=RoleLibrary)?
	(risks+=Risk*)
	)

;

Risk:
	{Risk}
	'Risk:' ((name=STRING)
	('roles=' (assignedRoles+=[Role|STRING]) (',' roles+=[Role|STRING])*)? 
	)
;

RoleLibrary :
	{RoleLibrary}
	'Roles:' (id=ID
		(roles+=Role*)
	)
;

Role :
	{Role}
	'Role:' 
		(id=ID 'name=' name=STRING)
	
;

Import hidden (WS, ID):
	'import' (importURI=STRING) 
;
terminal SL_COMMENT 	: '!-' -> NewLine
	
;
terminal WS:
	(' ' | '\t')+
;
terminal NewLine:
	('\r'? '\n')+
;


This is the text that I enter. repare in the space that I'm forced to enter before "Role:"
Roles:
 Role: id=kb name="Kill Bill"
 Role: id=jim name="Jim M"

[Updated on: Wed, 18 April 2012 01:57]

Report message to a moderator

Re: Content Assist don't work in first column of second line... [message #849017 is a reply to message #848050] Wed, 18 April 2012 20:06 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
That's intended Eclipse behavior. Content assist tries to complete the
current word when there is no whitespace before the caret position. Same
as in JDT and any other editor.

Am 18.04.12 00:49, schrieb Cristiano Gaviao:
> Hi again,
> I've implemented a new pilot to test importing resources stuffs... It is
> reaally cool !
>
> But there are something wrong with content assist that I couldn't find
> why...:
> If I type crtl-space in a empty file at first position, It shows me the
> content assist with Risk:, Roles: and import options.
>
> So, If I choose anyone option and type enter, at the second line and
> first column the content assist doesn't work. It just works after I
> enter a space...
>
> could someone give me a tip here?
>
> That is my grammar:
>
> grammar org.xtext.example.risks.RiskDsl with
> org.eclipse.xtext.common.Terminals hidden(WS, NewLine)
>
> generate riskDsl "http://www.xtext.org/example/risks/RiskDsl"
>
> RiskModel :
> {RiskModel}
> (
> (imports += Import*)
> (rolesLibrary=RoleLibrary)?
> (risks+=Risk*)
> )
> ;
> Risk:
> {Risk}
> ('Risk:' ('name=' name=STRING)
> ('roles=' (roles+=[Role|STRING]) ((',' (roles+=[Role|STRING]))*)?)? )
> ;
> RoleLibrary :
> {RoleLibrary}
> ('Roles:'
> (roles+=Role*)
> )
> ;
> Role :
> ('Role:' ('id=' id=ID 'name=' name=STRING)
> )
> ;
> Import hidden (WS, ID):
> ('import' importURI=STRING) ;
> terminal SL_COMMENT : '!-' -> NewLine
>
> ;
> terminal WS:
> (' ' | '\t')+
> ;
> terminal NewLine:
> ('\r'? '\n')+
> ;
>
>
> This is the text that I enter. repare in the space that I'm forced to
> enter before "Role:"
>
> Roles:
> Role: id=kb name="Kill Bill"
> Role: id=jim name="Jim M"
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Content Assist don't work in first column of second line... [message #849803 is a reply to message #849017] Thu, 19 April 2012 13:11 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Jan Kohnlein wrote on Wed, 18 April 2012 23:06
That's intended Eclipse behavior. Content assist tries to complete the
current word when there is no whitespace before the caret position. Same
as in JDT and any other editor.


Hi Jan,

Thanks for the worry, but I think you didn't understood well my point Smile


In JDT or Xtend Class for example, if I enter this
import whatever.package.clazz; [hit enter here]


and hit a enter, the content assist will work properly in the first column of the line below the first import, am I right ?

so in this example we will have this:
import whatever.package.clazz;[hit enter here]
<content assist works here in the first column of the next line>


and in my dsl it just don't happen... if I hit the enter after the first import sentence, content assist doesn't appears in the next line at the first column...

So, or I just did something wrong (that I can't find or it is a bug)

regards,

Cristiano
Re: Content Assist don't work in first column of second line... [message #851053 is a reply to message #848050] Fri, 20 April 2012 15:49 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
After long hours of trials and errors I've found the culprit. :/

It seems that exists some code in content assist api that is based on WS terminal.

After I've removed this:
terminal WS:
	(' ' | '\t')+
;
terminal NewLine:
	('\r'? '\n')+
;


This change let me use the content assist in first column, but still showing something that wouldn't appear. So after I have included '{' '}' delimiters the content assist starts to work properly.

Could someone explain me this relationship between WS terminal and delimiters with Content Assist ?

cheers,

Cristiano
Re: Content Assist don't work in first column of second line... [message #851152 is a reply to message #851053] Fri, 20 April 2012 17:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i just gave it a debug session. the problem is a combination of
you not obeying Xtext's naming conventions
and Xtext relying on this conventions

The name of the Rule is NewLine but Xtext searches for NEWLINE in
org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser.createLeafNode(Token, EObject)

would you please file a bugzilla

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Content Assist don't work in first column of second line... [message #851235 is a reply to message #851152] Fri, 20 April 2012 19:45 Go to previous message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Hi Christian,

I've confirmed the problem... it have worked after I have changed the terminal named as NewLine to NEWLINE instead...

I've opened the bug.

thanks,

Cristiano


Previous Topic:append instead of appendImmediate for "AFTER" in loops
Next Topic:Another Content Assist doubt
Goto Forum:
  


Current Time: Fri Apr 19 18:46:13 GMT 2024

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

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

Back to the top