Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Auto complition
Auto complition [message #1058884] Wed, 15 May 2013 10:22 Go to next message
Eclipse UserFriend
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 10:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

i thought you were already working on your autoeditstraegy
Re: Auto complition [message #1058888 is a reply to message #1058885] Wed, 15 May 2013 10:41 Go to previous messageGo to next message
Eclipse UserFriend
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 10:54 Go to previous messageGo to next message
Eclipse UserFriend
And what is your problem, you should be able to detect the { in the strategy
Re: Auto complition [message #1058894 is a reply to message #1058891] Wed, 15 May 2013 11:04 Go to previous messageGo to next message
Eclipse UserFriend
Btw if you have already have cvode it would be really helpful to share it Wink
Re: Auto complition [message #1058919 is a reply to message #1058894] Wed, 15 May 2013 14:32 Go to previous messageGo to next message
Eclipse UserFriend
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 15:16 Go to previous messageGo to next message
Eclipse UserFriend
And what is your grammar?
Re: Auto complition [message #1058924 is a reply to message #1058923] Wed, 15 May 2013 15:33 Go to previous messageGo to next message
Eclipse UserFriend
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 15:35 Go to previous messageGo to next message
Eclipse UserFriend
Interesting part (QualifiedName) is missing
Re: Auto complition [message #1058926 is a reply to message #1058925] Wed, 15 May 2013 15:35 Go to previous messageGo to next message
Eclipse UserFriend
btw why do you want to do this at all
Re: Auto complition [message #1058927 is a reply to message #1058925] Wed, 15 May 2013 15:36 Go to previous messageGo to next message
Eclipse UserFriend
sorry , I forget it
QualifiedName :
ID('.'ID)*
;
Re: Auto complition [message #1058928 is a reply to message #1058927] Wed, 15 May 2013 15:39 Go to previous messageGo to next message
Eclipse UserFriend
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 15:50 Go to previous messageGo to next message
Eclipse UserFriend
and why do you want to autoedit?
Re: Auto complition [message #1058932 is a reply to message #1058931] Wed, 15 May 2013 15:58 Go to previous messageGo to next message
Eclipse UserFriend
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 16:05 Go to previous messageGo to next message
Eclipse UserFriend
And why dont you simply forbid blanks?
Re: Auto complition [message #1058936 is a reply to message #1058934] Wed, 15 May 2013 16:11 Go to previous messageGo to next message
Eclipse UserFriend
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 16:13 Go to previous messageGo to next message
Eclipse UserFriend
sorry then i still dont get your problem
how can one identify the string that should be trimmed?
Re: Auto complition [message #1058938 is a reply to message #1058937] Wed, 15 May 2013 16:30 Go to previous messageGo to next message
Eclipse UserFriend
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 16:34 Go to previous messageGo to next message
Eclipse UserFriend
Is it always Web?
Re: Auto complition [message #1058940 is a reply to message #1058939] Wed, 15 May 2013 16:36 Go to previous messageGo to next message
Eclipse UserFriend
No Sad for every elements
Re: Auto complition [message #1058941 is a reply to message #1058940] Wed, 15 May 2013 16:38 Go to previous messageGo to next message
Eclipse UserFriend
But it is static defined?
Re: Auto complition [message #1058942 is a reply to message #1058941] Wed, 15 May 2013 16:41 Go to previous messageGo to next message
Eclipse UserFriend
I give an example .such as Webapplication web app {
Re: Auto complition [message #1058944 is a reply to message #1058942] Wed, 15 May 2013 16:52 Go to previous messageGo to next message
Eclipse UserFriend
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 #1058945 is a reply to message #1058944] Wed, 15 May 2013 16:54 Go to previous messageGo to next message
Eclipse UserFriend
(with

@Inject DocumentUtil u
)


for more digging i dont have the time.
maybe sebastian knows
Re: Auto complition [message #1058946 is a reply to message #1058945] Wed, 15 May 2013 17:05 Go to previous messageGo to next message
Eclipse UserFriend
Btw you can have a look at the arithmetics example too.
there the ast is actually accessed in the edit strategy
Re: Auto complition [message #1058977 is a reply to message #1058946] Thu, 16 May 2013 02:36 Go to previous messageGo to next message
Eclipse UserFriend
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 02:58 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Auto complition [message #1059002 is a reply to message #1058986] Thu, 16 May 2013 03:49 Go to previous messageGo to next message
Eclipse UserFriend
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 04:09 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Auto complition [message #1059012 is a reply to message #1059009] Thu, 16 May 2013 04:30 Go to previous messageGo to next message
Eclipse UserFriend
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 05:05 Go to previous messageGo to next message
Eclipse UserFriend
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 02:32 Go to previous messageGo to next message
Eclipse UserFriend
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 04:29 Go to previous message
Eclipse UserFriend
Sorry i dont know Autordit in Detail. It is ugly and i dont want to digg
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 Jul 08 17:21:16 EDT 2025

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

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

Back to the top