Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » New Quick Assist's
New Quick Assist's [message #171004] Sun, 01 August 2004 00:39 Go to next message
Eclipse UserFriend
Originally posted by: scheglov_ke.nlmk.ru

I've added several new useful (at least for me) quick assist's in class
QuickAssistProcessor (from 3.0 release). Here i list of them:

1. Split condition.
For example you have following code:
if (condition_1 && condition_2) {
do_something2();
}
Now you decide that you need also execute do_something3() when
condition_1 && condition_3. I.e. you want following code:
if (condition_1) {
if (condition_2)
do_something2();
if (condition_3)
do_something3();
}
Currently you will need to copy condition_2 by hands. I don't know how
all other, but I am very lazy. With new quick assist you can position
caret on condition (for example on &&) and transform initial code in:
if (condition_1) {
if (condition_2)
do_something2();
}

2. Join 'if' statements.
This is reverse operation to "split condition". You can point on inner
or outer "if" statement and ask for joining. Depending on context, quick
assist will suggest to join outer "if" to inner or inner to outer, or
both, if possible. Join can be used only if there are no "else" parts in
"if" statements.

3. Add paranoidal parenthesis for conditions.
I don't like to look on conditions and think "And what is order of
executing these conditions?", so usually add parenthesis around each
expression like: "collection.size() == 1" or (object == null), etc.
However sometimes I have to change someone else code and would like to
change source to make it more readable for me. So, I've added quick assist
for adding parenthesis in such cases. For example this:
list.size() == 3 && list instanceof List && c
will be converted to:
(list.size() == 3) && (list instanceof List) && c
Just select block of code and invoke quick asisst, it will change all
conditions in selected code.

4. Remove extra parenthesis.
One more reverse operation.
If you don't like extra parenthesis in your code, you can remove all of
them and keep them only where required. For example this:
(list.size() == 2) && (a || b)
will be converted to:
list.size() == 2 && (a || b)
As you can see, it keeps parenthesis where needed. It uses precedence
table for operators, so knows, where to keep parenthesis.

5. Inverse condition.
Select condition and inverse it, for example when you see that there are
too many "not" operators or want to exchange "then" and "else" branches in
"if" statement (BTW, may be such quick assist also required?...). For
example, this:
a || !b && !c
will be converted to:
!a && (b || c)

BTW, I often use what I call "fail fast" checking. I.e. when you do chain
of checks, each next can be executed only if previous were successful,
instead of writing deep chain of "if" statements:
prepare_1;
if (condition_1) {
prepare_2;
if (condition_2) {
prepare_3;
if (condition_3) {
...
}
}
}
I prefer to have
prepare_1;
if (!condition_1)
return false; // or may be 'continue'
prepare_2;
if (!condition_2)
return false;
prepare_3;
if (!condition_3)
return false;
...

So, condition inversing could be useful to implement assists for
changing from one style of chain checking to another...

Ok, now when I've described them, does anybody need these quick assists?
Do you have more ideas? I would like to have them in Eclipse, so would
like to contribute them to Eclipse. But I am not sure how to do this. Open
feature request? Write in jdt-ui-dev?

--
SY, Kosta.
Re: New Quick Assist's [message #171086 is a reply to message #171004] Mon, 02 August 2004 05:55 Go to previous messageGo to next message
Eclipse UserFriend
Konstantin Scheglov wrote:
> I've added several new useful (at least for me) quick assist's in class
> QuickAssistProcessor (from 3.0 release). Here i list of them:
[..]
> Ok, now when I've described them, does anybody need these quick assists?
> Do you have more ideas? I would like to have them in Eclipse, so would
> like to contribute them to Eclipse. But I am not sure how to do this. Open
> feature request? Write in jdt-ui-dev?

Hi Konstantin

This sounds very useful. The best way to contribute patches is to open a
feature request in bugzilla (against JDT/UI in this case) and to attach the
patch there.

Thanks,
Markus
Re: New Quick Assist's [message #171172 is a reply to message #171086] Mon, 02 August 2004 13:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: scheglov_ke.nlmk.ru

Markus Keller wrote:

> > like to contribute them to Eclipse. But I am not sure how to do this. Open
> > feature request? Write in jdt-ui-dev?

> This sounds very useful. The best way to contribute patches is to open a
> feature request in bugzilla (against JDT/UI in this case) and to attach the
> patch there.

Ok, done.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=71244

--
SY, Kosta.
Re: New Quick Assist's [message #171180 is a reply to message #171172] Mon, 02 August 2004 13:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smesh.openrules.com

Konstantin Scheglov wrote:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=

It's not OK to hardcode contributions into *kernel code*.

Is there more non-intrusive and convenient way to contribute to ^1?

--
Sam Mesh - http://openrules.com
Re: New Quick Assist's [message #171271 is a reply to message #171180] Tue, 03 August 2004 03:22 Go to previous message
Eclipse UserFriend
Sam Mesh wrote:
[..]
> Is there more non-intrusive and convenient way to contribute to ^1?

Yes, your plug-in can extend the org.eclipse.jdt.ui.quickAssistProcessors
extension point.

Markus
Previous Topic:Error when starting Eclipse
Next Topic:Auto update always wants to install upgrade...
Goto Forum:
  


Current Time: Thu May 08 10:23:06 EDT 2025

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

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

Back to the top