Bug 59933 - applying exclusion filter to opened java file makes it appear twice [build path]
Summary: applying exclusion filter to opened java file makes it appear twice [build path]
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-26 09:32 EDT by Luzius Meisser CLA
Modified: 2004-05-18 18:27 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 Luzius Meisser CLA 2004-04-26 09:32:58 EDT
How to reproduce bug:
1. Open .java file in javaeditor
2. Use build path property to add that file to exclusion filter
3. File is displayed twice in package explorer
Comment 1 Martin Aeschlimann CLA 2004-05-16 11:58:56 EDT
the package explorer does a full refresh of the project when receiving the delta
resulting from setting the exclusion filter (class path change)
It seems that after the delta the model still contains file.

Moving to jdt.core
Comment 2 Philipe Mulet CLA 2004-05-17 06:22:16 EDT
Isn't this a consequence of the concurrency bug in package explorer ?
Comment 3 Dirk Baeumer CLA 2004-05-17 12:13:46 EDT
No, this isn't a consequence of the concurrency bug since we get the delta and 
do a refresh. The concurrency bug happens when we get another delta during 
refreshing the viewer.
Comment 4 Dirk Baeumer CLA 2004-05-18 03:48:48 EDT
Here is what is happening:

The delta:

org.eclipse.jdt.core.ElementChangedEvent[source=Java Model[*]: {CHILDREN}
	Test[*]: {CHILDREN | CLASSPATH CHANGED}
		<project root>[*]: {ADDED TO CLASSPATH | REMOVED FROM 
CLASSPATH}
		ResourceDelta(/Test/.classpath)[*]]

The children when asking the package fragment for is Java and Non Java chidren:

children= Object[4]  (id=834132)
	[0]= CompilationUnit  (id=834144)
		name= "Inline2.java"
		occurrenceCount= 1
		owner= DefaultWorkingCopyOwner  (id=833952)
		parent= PackageFragment  (id=834104)
	[1]= CompilationUnit  (id=833844)
		name= "Inline.java"
		occurrenceCount= 1
		owner= DefaultWorkingCopyOwner  (id=833952)
		parent= PackageFragment  (id=833956)
	[2]= CompilationUnit  (id=834148)
		name= "M.java"
		occurrenceCount= 1
		owner= DefaultWorkingCopyOwner  (id=833952)
		parent= PackageFragment  (id=834104)
	[3]= File  (id=834152)
		path= Path  (id=834232)
		workspace= Workspace  (id=833564)

Selecting[1] prints:

[Working copy] Inline.java [in p1 [in <project root> [in Test]]]
  package p1
  class Inline

Selecting [3] prints:

L/Test/p1/Inline.java


The problem seems to be that the compilation unit is open in the editor and 
therefore a primary working copy exists. 

I see another problem here: since the CU isn't on the class path anymore the 
Java editor must be converted into a "non" Java Editor since some of the 
functions aren't available anymore. However we don't receive an event for this.


Comment 5 Philipe Mulet CLA 2004-05-18 07:22:33 EDT
Indeed, once excluded from classpath, and as long as it is opened; a primary 
working copy is answered amongst package children.

Fixed PackageFragment#getCompilationUnits(WorkingCopyOwner).
Comment 6 Philipe Mulet CLA 2004-05-18 07:23:05 EDT
Need testcase.
Comment 7 Philipe Mulet CLA 2004-05-18 07:38:58 EDT
> I see another problem here: since the CU isn't on the class path anymore the 
> Java editor must be converted into a "non" Java Editor since some of the 
> functions aren't available anymore. However we don't receive an event 
> for this.

We do not broadcast this change, since the working copy still exists, but 
lives outside the classpath. You would need to handle it by yourself, when 
notified about source folder being ADDED/REMOVED from classpath.
Comment 8 Jerome Lanneluc CLA 2004-05-18 08:02:39 EDT
Added regression test 
ExclusionPatternsTest.testAddExclusionOnPrimaryWorkingCopy()
Comment 9 Dirk Baeumer CLA 2004-05-18 09:03:24 EDT
Philippe, can we simply do the following when we receive the class path delta: 
take the project of the working copy and ask if the working copy is on the 
class path. Will this answer false in this case.

CC Dani, since this affects the editor.
Comment 10 Jerome Lanneluc CLA 2004-05-18 09:39:55 EDT
That's correct: if the working copy is excluded, IJavaProject#isOnClasspath
(IJavaElement) will return false for the working copy.
Comment 11 Martin Aeschlimann CLA 2004-05-18 17:00:22 EDT
fix verified in package explorer (I20040518-0816)
Comment 12 Olivier Thomann CLA 2004-05-18 18:27:53 EDT
Closed as verified.