Bug 154170 - Printing warnings breaks in-editor quick fixes
Summary: Printing warnings breaks in-editor quick fixes
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 3.2.1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-16 18:57 EDT by Barney Boisvert CLA
Modified: 2006-09-18 11:51 EDT (History)
4 users (show)

See Also:


Attachments
Project that exhibits bug (13.72 KB, application/octet-stream)
2006-08-17 19:47 EDT, Jess Garms CLA
no flags Details
Proposed fix and regression test (3.45 KB, patch)
2006-08-30 09:34 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Barney Boisvert CLA 2006-08-16 18:57:53 EDT
If an annotation processor adds a warning, such as via this code,

   messager.printWarning(mirror.getPosition(), message + annoValue.getValue());

all quick fix options loaded from clicking in the gutter disappear.  They are still available from the problems view.  Note that it's not just quick fixes from the particular annotation processor (or annotation processors in general), but all quick fixes for any error/warning (unimported type, missing field declaration, etc).
Comment 1 Jess Garms CLA 2006-08-16 19:15:51 EDT
This actually looks to be a problem in the jdt-ui component. APT adds a categorized problem via the CompilationParticipant in jdt-core, and this seems to break the quick-fixes for all other reported problems.

Let me know if you need a detailed repro for the problem.
Comment 2 Dani Megert CLA 2006-08-17 03:43:03 EDT
>Let me know if you need a detailed repro for the problem.
A simple test case would be good. Also: which build?
Comment 3 Jess Garms CLA 2006-08-17 19:47:00 EDT
Created attachment 48150 [details]
Project that exhibits bug
Comment 4 Jess Garms CLA 2006-08-17 19:49:40 EDT
The attached project can be imported to reproduce the bug.

This was tested with 3.2.1 build M20060810-0800-win32.zip.

To reproduce, import the project into your workspace. Open Test.java. Right-click on the gutter of the line that contains "InputStream s;", and select Quick-fix. You should only get an option to rename. If you remove the annotation on the file, then try right-clicking for the quick-fix, you will see the other options, including import java.io.InputStream.

Let me know if you need any more info.
Comment 5 Martin Aeschlimann CLA 2006-08-21 14:42:58 EDT
Problem is in org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation()

makeConsistent collects Java problems only if the CU is not consistent any more 
  (ReconcileWorkingCopyOperation.makeConsistent(CompilationUnit, IProblemRequestor) line 128)
however, notifyParticipants is called every time and APT creates problems every time

So after a reconcile after no changes, a new problem reporting seesion is started but only APT problems are reported. Quick fix doesn't know what to fix and only suggests the 'Rename' quick assist.

So maybe
- notifyParticipants should only be called when the file is not consistent
or
- APT has to check cu.isConsistent before collecting problems

I think the first option is easier for participants.

I realized that quick fixes happens to cause several unnecessary reconciles. I'll fix that. 
Comment 6 Jerome Lanneluc CLA 2006-08-22 05:56:34 EDT
After discussing with Martin, it appears that the original problem is caused by IProblemRequestor#beginReporting() and endReporting() being called with no acceptProblem() for Java problems even if forceProblemDetection is off. This causes the Java problems to be removed.

Jess, would it be acceptable to not notify participants of problems if the working copy is already consistent and forceProblemDetection is off ?
Comment 7 Jess Garms CLA 2006-08-22 12:46:41 EDT
> Jess, would it be acceptable to not notify participants of problems if the
> working copy is already consistent and forceProblemDetection is off ?

Yes, this seems like correct behavior to me.
Comment 8 Philipe Mulet CLA 2006-08-29 12:39:44 EDT
+1 for 3.2.1.
When participants are contributing problems but forceProblemDetection is off, these problems shouldn't be reported, as they are not accurately representing the set of detected problems.
In 3.3, we may want to expose the state of the force flag in the reconcile context, for participants to avoid wasting their time detecting problems unless they will be reported for real.
Comment 9 Jerome Lanneluc CLA 2006-08-30 09:34:37 EDT
Created attachment 49051 [details]
Proposed fix and regression test
Comment 10 Jerome Lanneluc CLA 2006-09-01 04:38:28 EDT
Fix and regression test released for 3.2.1 in R3_2_maintenance branch and released for 3.3 M2 in HEAD.
Comment 11 David Audel CLA 2006-09-12 08:24:54 EDT
Verified for 3.2.1 using build M20060908-1655
Comment 12 Frederic Fusier CLA 2006-09-18 11:51:40 EDT
Verified for 3.3 M2 using build I20060918-0010.