Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333465 - [quick fix] add remove invalid statement
Summary: [quick fix] add remove invalid statement
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-04 07:53 EST by Andreas Höhmann CLA
Modified: 2011-05-30 07:10 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Höhmann CLA 2011-01-04 07:53:46 EST
Build Identifier: 

In situations like the one below, we should have a quick fix that removes the wrong statement.


final Foobar foobar = new Foobar();
foobar.callNoneExistingMethod("compile error here");
       ^^^^^^^^^^^^^^^^^^^^^^^

The method callNoneExistingMethod(String) is undefined for the type Foobar	....

There should be a quickfix "remove statement" available ... that's the easiest way to fix the bug ;)

Reproducible: Always
Comment 1 Dani Megert CLA 2011-01-04 10:03:02 EST
This doesn't make too much sense and you'd still have a compile error afterwards.
Comment 2 Andreas Höhmann CLA 2011-01-04 10:48:54 EST
Dani, let me explain more detailed ...
Imagine you have a Utilclass "Foobar.doIt("XXX")" ...
Now you have 50 Classes where you call this method ...
Then you delete Foobar.doIt (there is no refactoring method "remove method".
After this you have 50 compile errors ... no such method ...

class #1:
foobar.doIt("AAA");
         ^^^
class #2:
foobar.doIt("AAA");
         ^^^
class #3:
foobar.doIt("BBB");
         ^^^
...

I want to go to the ProblemView ... select all this compile errors and want execute quick fix "remove statement" ... after this
all these 50 classes now without compile errors. 

Do you understand?
Comment 3 Dani Megert CLA 2011-01-04 11:01:08 EST
(In reply to comment #2)
> Dani, let me explain more detailed ...
> Imagine you have a Utilclass "Foobar.doIt("XXX")" ...
> Now you have 50 Classes where you call this method ...
> Then you delete Foobar.doIt (there is no refactoring method "remove method".
> After this you have 50 compile errors ... no such method ...
> 
> class #1:
> foobar.doIt("AAA");
>          ^^^
> class #2:
> foobar.doIt("AAA");
>          ^^^
> class #3:
> foobar.doIt("BBB");
>          ^^^
> ...
> 
> I want to go to the ProblemView ... select all this compile errors and want
> execute quick fix "remove statement" ... after this
> all these 50 classes now without compile errors. 
> 
> Do you understand?
Yes, you want to remove the whole line to get rid of the compile . The argument list might have code that you don't want to delete. Also, can use search/replace for that. We won't add a quick fix for this.
Comment 4 Andreas Höhmann CLA 2011-01-05 04:07:12 EST
You are right ... the result maybe (still) wrong.
But anyway ... maybe somebody need such a quick fix ... 
I created a simple plugin to provide this quickfix :D 
Have a look at https://github.com/ahoehma/de.ahoehma.jdt

I think if the quickfix is only available for "missing void methods" the code after
removing the compile-code-statement should work.
Comment 5 Markus Keller CLA 2011-01-05 08:34:24 EST
(In reply to comment #2)
> Then you delete Foobar.doIt (there is no refactoring method "remove method".

If the method is really useless, then just make sure it has an empty body and then inline it.
Comment 6 Andreas Höhmann CLA 2011-01-05 09:06:26 EST
(In reply to comment #5)
> (In reply to comment #2)
> > Then you delete Foobar.doIt (there is no refactoring method "remove method".
> 
> If the method is really useless, then just make sure it has an empty body and
> then inline it.
Ahh ...  brilliant idea Markus! This concept could be used for a "remove method refactoring".