Bug 77283 - Incremental and full builds produce different problem markers for same duplicate type error
Summary: Incremental and full builds produce different problem markers for same duplic...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-29 09:06 EDT by Markus Keller CLA
Modified: 2005-02-15 10:08 EST (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 Markus Keller CLA 2004-10-29 09:06:36 EDT
I200410260800, same in 3.0.0. Maybe connected to bug 77273.

- new workspace, autobuild on, new project "J" with p/C.java:
package p;
class C { }

class CC extends C {
	void method() { }
}

- copy C.java, paste it again, resolve name conflict with new name "D"
=> autobuild incrementally compiles D.java
=> Problems View: "The type CC is already defined" in D.java, *no line*

- clean the project
=> autobuild does full build
=> Problems View: "The type CC is already defined" in D.java, *line 5*
(range: CC)

Expected: same range in both cases
Comment 1 Kent Johnson CLA 2004-10-29 12:15:24 EDT
In the full build case, the compiler creates the error on the type declaration 
of the duplicate type, since it has all the types in source form.

In the incremental case, the builder detects the error when the classfile 
collides with an existing class file from another source file. We do not know 
nor have access to the parsed structure.

Not sure we'll change this.

Philippe?
Comment 2 Philipe Mulet CLA 2004-10-29 12:20:50 EDT
Can we blame both source files each time ?
Comment 3 Kent Johnson CLA 2004-10-29 13:05:00 EDT
Markus: do you care which range you get? No line vs. line 5...
Comment 4 Markus Keller CLA 2004-11-01 05:18:34 EST
As a user, I would prefer the exact range. As a refactoring implementor, I don't
care, since I'm not affected. It's just not nice to see the marker jumping.

Maybe Martin has an opinion here, since we could offer a QuickFix for this
problem. However, I don't think that it could be more than a "Rename in file".
Comment 5 Martin Aeschlimann CLA 2004-11-01 05:40:23 EST
The name range would of course be nice for quick fix. But there's currently no 
fix implementented for this problem
Comment 6 Kent Johnson CLA 2004-11-25 13:19:02 EST
Philippe: I've looked around in the JavaModel but I cannot find the source 
position of a type's name.

Is it possible to retrieve just the position of the name, not the entire type 
declaration?
Comment 7 Markus Keller CLA 2004-11-25 15:18:46 EST
IMember has a query ISourceRange getNameRange(). This is inherited by IType.
Comment 8 Kent Johnson CLA 2004-11-25 15:59:44 EST
thanks Markus.

We now highlight the type name in both cases.
Comment 9 Olivier Thomann CLA 2004-12-14 15:00:49 EST
The type is highlighted, but there is no line in the first case. Is this expected?
Comment 10 Olivier Thomann CLA 2004-12-15 11:33:36 EST
Verified in 200412142000
Comment 11 Markus Keller CLA 2005-01-03 11:40:35 EST
Sorry, this does not seem to be fixed properly in I20041221-0800.

When I repeat the steps from comment 0 with all editors closed, the Problems
View still doesn't show a line number, and doubleclicking the error selects the
first character in D.java.

The behaviour is different when C.java is opened in the java editor before the
steps are executed:

The Problems View still doesn't show a line number, but the error range is "CC"
in D.java (correct range).

When the copy is called "CopyOfC", the Problems View still doesn't show a line
number, and the error range is "cl" in "class CC extends CopyOfC" in
CopyOfC.java (incorrect range).
Comment 12 Kent Johnson CLA 2005-01-04 15:03:51 EST
So is the line number of the type name available from IType?

I don't see it.

Unlikely we can do more than we have.
Comment 13 Markus Keller CLA 2005-01-05 05:20:15 EST
I don't think that the IType knows about line numbers. I think we can live
without  a line number here, if that resolution (building a Document and asking
it) is too expensive.

However, I mainly reopened the bug because of the incorrect range problems when
the editor is not open or when the copy is called "CopyOfC".
Comment 14 Kent Johnson CLA 2005-01-11 12:39:30 EST
Jerome, can you please have a look at this one.

Follow the steps in comment 11.

Can the Java Model not answer the source range of a type if an editor is not 
open?
Comment 15 Jerome Lanneluc CLA 2005-01-12 07:50:48 EST
AbtractImageBuilder#acceptResult(...) was using IJavaProject#findType(...) for a
secondary type. This doesn't work if the editor containing the secondary type is
closed.

Changed AbtractImageBuilder#acceptResult(...) to first find the main type, then
construct the secondary type from this main type.

Added regression test IncrementalTests#testAddDuplicateSecondaryType()
Comment 16 David Audel CLA 2005-02-15 10:08:10 EST
Verified in I20050214-0927