12 comments
Comment actions Permalink

Dave, could you insert in next version of ipp:

- inspection to change visilibity: public, protected, private



U¿ytkownik "Dave Griffith" <dave.griffith@cnn.com> napisa³ w wiadomo¶ci
news:8924570.1065463214617.JavaMail.itn@is.intellij.net...
>

Recompiled for build 944. No other changes. Available at

http://www.intellij.org/twiki/bin/view/Main/IntentionPowerPack
>

Let me know if there are any issues.

>

--Dave Griffith



0
Comment actions Permalink


Sadly no. I've already got inspections for detecting fields and inner classes with too high of visibility, but there are no quick-fixes for those inspections. In cases of excessive visibility for fields, the Right Thing to do isn't to simply tag them "private". The built-in "declaration access can be weaker" inspection will do that for you, if such tagging won't break the code. Instead, the Right Thing for me to do is to fire the "Encapsulate Fields" refactoring, which would not only tag the field with a tighter visibility, but will also replace any external references to it with setters and getters, as appropriate. At present, there is no open or semi-open API in IDEA for firing refactorings, although I've got an open tracker request for such an API. With it, I would be able to have such nifties as having the naming convention inspections have "Rename" as their quick fix, and other such handy tools. Until then, the right answer is to call "Encapsulate Fields" by hand. (What an amazingly powerful tool we have where that seems unnecessarily clunky.)

0
Comment actions Permalink


I'm an idiot, and thought you were asking about InspectionGadgets. I've pretty much stopped active development on IntentionPowerPack, but will put your request on the list.

0
Comment actions Permalink


U¿ytkownik "Dave Griffith" <dave.griffith@cnn.com> napisa³ w wiadomo¶ci
news:24446686.1065473413690.JavaMail.itn@is.intellij.net...
>

I'm an idiot, and thought you were asking about InspectionGadgets. I've

pretty much stopped active development on IntentionPowerPack, but will put
your request on the list.

No, you are not an idiot, just human. InspectionGadgets of course, looks
much more powerful compared to IntentionPowerPack, especially when it comes
to cleaning up the code. I just needed quick fix to change
public/protected/private for given field.


0
Comment actions Permalink

Thanks for the update! This plugin is one I use almost every day.

Dave Griffith wrote:

Let me know if there are any issues.


I do have one issue with the "replace ?: with if-else" intention. Applying
the intention on the following test code produces uncompilable code:

public class ReplaceConditionalAssignmentWithIfIntentionTest {
public void test() {
int i = true ? 10 : 20;
}
}

This could be an issue with IDEA though, but I guess you're the expert on
that:-)

Thanks for all your work,
Bas


0
Comment actions Permalink


This is a known issue. The code generated isn't actually uncompilable, it's just got red lines because IDEA's compilability checker gets confused by the steps I take to alter the code. If run Ctrl-Alt-L, that resets the checker, and the red lines go away. Annoying, but I haven't found any other workaround.

--Dave

0
Comment actions Permalink

Dave Griffith wrote:

This is a known issue. The code generated isn't actually
uncompilable, it's just got red lines because IDEA's compilability
checker gets confused by the steps I take to alter the code. If run
Ctrl-Alt-L, that resets the checker, and the red lines go away.
Annoying, but I haven't found any other workaround.


Euhm, in my case the code is uncompilable. Maybe a previous IDEA version
generated different code but when I try the "replace ?: with if-else"
intention on the code I get:


0
Comment actions Permalink

Whoops, Outlook Expres problems... Ctrl+enter is such an easy keystroke to
make by accident:-)

Bas Leijdekkers wrote:

Dave Griffith wrote:

>> This is a known issue. The code generated isn't actually
>> uncompilable, it's just got red lines because IDEA's compilability
>> checker gets confused by the steps I take to alter the code. If run
>> Ctrl-Alt-L, that resets the checker, and the red lines go away.
>> Annoying, but I haven't found any other workaround.
>

Euhm, in my case the code is uncompilable. Maybe a previous IDEA
version generated different code but when I try the "replace ?: with
if-else" intention on the code I get:


public class ReplaceConditionalAssignmentWithIfIntentionTest {
public void test() {
{
int i;
}
if (true) {
i = 10;
}
else {
i = 20;
}
}
}

Which definately doesn't compile. It also isn't layed out according to my
preferences, which a Ctrl-Alt-L doesn't fix...

Bas


0
Comment actions Permalink

Small typo: 'priniciple' in description of 'Value of ++ or -- used'


0
Comment actions Permalink

Thanks. Fixed in next release.

0
Comment actions Permalink

Bug:
The textfields to configure for example naming convention patterns seem to be in some strange overwrite-mode which can't be turned off.

Question:

MY_SWITCH is reported from "Constant conditions & exceptions" as being always true. Can't we make an exception for such obvious switches? Maybe that would be a switch itself. I'm not sure about this, though.

0
Comment actions Permalink

Got this when navigating from hierarchy view to some class/method.
It endlessly repeats itself until the inspection is disabled.

0

Please sign in to leave a comment.