Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Auto complition
Auto complition [message #1058884] Wed, 15 May 2013 14:22 Go to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi all ,

I want to do auto completion according to bracket .but I do not use curly bracket ,is it possible

best regards,
Re: Auto complition [message #1058885 is a reply to message #1058884] Wed, 15 May 2013 14:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

i thought you were already working on your autoeditstraegy


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058888 is a reply to message #1058885] Wed, 15 May 2013 14:41 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,
Yes I worked autoeditstraegy .I want to use "{" .I use "=" my code works but "{" not work. if the user enter curly bracket ,elements name's gabs removed
Re: Auto complition [message #1058891 is a reply to message #1058888] Wed, 15 May 2013 14:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
And what is your problem, you should be able to detect the { in the strategy

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058894 is a reply to message #1058891] Wed, 15 May 2013 15:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Btw if you have already have cvode it would be really helpful to share it Wink

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058919 is a reply to message #1058894] Wed, 15 May 2013 18:32 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi ,

I tried {in the strategy .but curly bracket has already auto edit completion.I am confised, How solved remove gabs from the qualifiedname ( ıd) with autoeditstraegy.I tryied different kind of method for this problem.

public void customizeDocumentCommand(IDocument document,
DocumentCommand command) {
try {
if (command.text.equals("{") && document.get(command.offset-4, 4).equals("web ")){
contents = document.get();

document.set(getText());
command.text="";
Re: Auto complition [message #1058923 is a reply to message #1058919] Wed, 15 May 2013 19:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
And what is your grammar?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058924 is a reply to message #1058923] Wed, 15 May 2013 19:33 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

I share a part of my grammar .I want to take all of the element's QualifiedName,and then if Qualifiedname has a gap,remove this gap with auto edit strategy.


ContentModel returns ContentModel:
	'ContentModel'
	name=QualifiedName
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	ownedWebApplication=WebApplication
	'}';
	
ContentUnit returns ContentUnit:
	ContentModel | WebApplication | SiteCollection | Web | WebList | ContentType | Field;

WebApplication returns WebApplication:
	'WebApplication'
	name=QualifiedName
	'{'
	'guID' '=' guID=STRING
	('description' '=' description=STRING)?
	ownedSiteColection+=SiteCollection (ownedSiteColection+=SiteCollection)*
	'}';
Re: Auto complition [message #1058925 is a reply to message #1058924] Wed, 15 May 2013 19:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Interesting part (QualifiedName) is missing

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058926 is a reply to message #1058925] Wed, 15 May 2013 19:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
btw why do you want to do this at all

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058927 is a reply to message #1058925] Wed, 15 May 2013 19:36 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
sorry , I forget it
QualifiedName :
ID('.'ID)*
;
Re: Auto complition [message #1058928 is a reply to message #1058927] Wed, 15 May 2013 19:39 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Because required for my system .There are internal and display names.display name showed by the user.internal name may be gaped .
Re: Auto complition [message #1058931 is a reply to message #1058928] Wed, 15 May 2013 19:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
and why do you want to autoedit?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058932 is a reply to message #1058931] Wed, 15 May 2013 19:58 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
If the user enter gabed name that is stored in the displayname ,and then romove blank from the name and then user may shows not blanked name.I can use autoedit for this problem.such as user enter a { : if qualifiedname has gap ,remove gaps after enter {
Re: Auto complition [message #1058934 is a reply to message #1058932] Wed, 15 May 2013 20:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
And why dont you simply forbid blanks?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058936 is a reply to message #1058934] Wed, 15 May 2013 20:11 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Because ,I want to take blanked name.I will store it anywhere.
PS:already user do not enter blank for qualifiedname (such as : home web is not entered for qualifiedname )
Re: Auto complition [message #1058937 is a reply to message #1058936] Wed, 15 May 2013 20:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
sorry then i still dont get your problem
how can one identify the string that should be trimmed?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058938 is a reply to message #1058937] Wed, 15 May 2013 20:30 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
yes I want to trimmed identify string .such as : Web ww w {

between Web and { :find ww w string is took and then tripped .I want to do this
Re: Auto complition [message #1058939 is a reply to message #1058938] Wed, 15 May 2013 20:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Is it always Web?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058940 is a reply to message #1058939] Wed, 15 May 2013 20:36 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
No Sad for every elements
Re: Auto complition [message #1058941 is a reply to message #1058940] Wed, 15 May 2013 20:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
But it is static defined?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058942 is a reply to message #1058941] Wed, 15 May 2013 20:41 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
I give an example .such as Webapplication web app {
Re: Auto complition [message #1058944 is a reply to message #1058942] Wed, 15 May 2013 20:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
hmmm still have no clue if you need the xtext model (AST) to decide what the text is or not ?!?
can it be BlaBla web app too?

you may use this as starting point

if (command.offset > 0 && "{".equals(command.text)) {
IRegion r = u.searchBackwardsInSamePartition("Web", document, command.offset);
String text = document.get(r.getOffset(), command.offset-r.getOffset());
String textx = "Web " + text.substring(4).replaceAll(" ", "") + "";
document.replace(r.getOffset(), command.offset-1-r.getOffset(), textx);

}

i dont know if is a good idea to go that way. since the edit strategy is not xtext specific you might find examples
at other places.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058945 is a reply to message #1058944] Wed, 15 May 2013 20:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
(with

@Inject DocumentUtil u
)


for more digging i dont have the time.
maybe sebastian knows


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058946 is a reply to message #1058945] Wed, 15 May 2013 21:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Btw you can have a look at the arithmetics example too.
there the ast is actually accessed in the edit strategy


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1058977 is a reply to message #1058946] Thu, 16 May 2013 06:36 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian ,

Can I use Mydsljavavalidator class for this problem ( auto edit for blanked name ).
or ıf we enter a qualified name with gaped ,Xtext framework checks this gabed name and give an error. can I reach this checked ıd class ,and then Can I override ?
Re: Auto complition [message #1058986 is a reply to message #1058977] Thu, 16 May 2013 06:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
you could try a validator+quickfix. you could try to implement a iqualifiednameprovider that simulates a "as if"
or you could simply prevent the user doing this.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1059002 is a reply to message #1058986] Thu, 16 May 2013 07:49 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
I will try,If the error (detected blanked name ) ,it fixed automatically. Can I do this with custom validation.can I use edit strategy
Re: Auto complition [message #1059009 is a reply to message #1059002] Thu, 16 May 2013 08:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
no. and yes: but the problem is: you are the guy that has to digg into the edit strategy and it will be very very ugly.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complition [message #1059012 is a reply to message #1059009] Thu, 16 May 2013 08:30 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
My problem is not solved with custom validation.I must use edit strategy
Re: Auto complition [message #1059020 is a reply to message #1058944] Thu, 16 May 2013 09:05 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi ,

I try starting point but if (command.offset > 0 && "{".equals(command.text))not work .

not enter if .

Christian Dietrich wrote on Wed, 15 May 2013 16:52
hmmm still have no clue if you need the xtext model (AST) to decide what the text is or not ?!?
can it be BlaBla web app too?

you may use this as starting point

if (command.offset > 0 && "{".equals(command.text)) {
IRegion r = u.searchBackwardsInSamePartition("Web", document, command.offset);
String text = document.get(r.getOffset(), command.offset-r.getOffset());
String textx = "Web " + text.substring(4).replaceAll(" ", "") + "";
document.replace(r.getOffset(), command.offset-1-r.getOffset(), textx);

}

i dont know if is a good idea to go that way. since the edit strategy is not xtext specific you might find examples
at other places.
Re: Auto complition [message #1059507 is a reply to message #1059020] Mon, 20 May 2013 06:32 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian ,

I Receive beetween keywords and {,hence I take all names .Such as
Web app p {
List list {

I receive app p and list .

When user enter {+space .
Web appp {
List list {
My problem is rewrite names in the editor.I must go from "{"+space and then I must write names .if names are blanked ,replace not blanked name with blanked name.I tried searchBackwardsInSamePartition() but not succesfully.How can I do ?

Best Regards,
Re: Auto complition [message #1059516 is a reply to message #1059507] Mon, 20 May 2013 08:29 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Sorry i dont know Autordit in Detail. It is ugly and i dont want to digg

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Mixing up XEpressions and my custom expressions
Next Topic:A custom scope problem (Cyclic resolution of lazy links)
Goto Forum:
  


Current Time: Tue Sep 24 10:42:26 GMT 2024

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

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

Back to the top