Bug 142059 - [efs] renaming package fails to update references
Summary: [efs] renaming package fails to update references
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2.1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-16 15:13 EDT by Rafael Chaves CLA
Modified: 2006-09-12 09:00 EDT (History)
3 users (show)

See Also:


Attachments
Thanks Rafael. Here is the corresponding fix. (1.06 KB, patch)
2006-06-20 11:06 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 Rafael Chaves CLA 2006-05-16 15:13:21 EDT
3.2m6

Renaming a package updates contained compilation units but fails to update references in other packages. The trigger seems to be the fact that the project lives on a project based on a non local file system is triggering the problem. This is always reproducible on our filesystem.
Comment 1 Rafael Chaves CLA 2006-05-16 17:19:51 EDT
Clarifying, the second sentence should read: "The trigger seems to be the fact that the project lives on a project based on a non local file system".

Increasing severity as this strongly limits the usefulness of refactoring on products that use alternate EFS file systems.
Comment 2 Dani Megert CLA 2006-05-17 02:52:29 EDT
>fails to update references in other packages.
Does it fail with an error or does it just not do it?

Anything in .log?
Comment 3 Markus Keller CLA 2006-05-17 07:03:36 EDT
Is there a (free) non local file system that we could use to reproduce?
Why do you think the problem is in the refactoring code and not in the file system implementation?
Does a Java search for references to the package find the references?
Comment 4 John Arthorne CLA 2006-05-17 10:11:15 EDT
There is a in memory file system implementation in the plugin org.eclipse.ui.examples.filesystem.  However, I cannot reproduce the failure with the memory file system.  Rafael, I created the following:

Project1
  src
    p1
      A.java
    p2
      B.java

Where B.java is a subclass of A.java, and it contains a single type import statement.  When I refactor->rename "p1" to "pnew", the reference in B.java is correctly updated.  Does this case fail for you?  If not, can you describe a case that fails?
Comment 5 Rafael Chaves CLA 2006-05-17 10:58:27 EDT
Re: comment 2 - no errors logged, it just fails to update references in other packages

Re: comment 3 - I am not sure yet, and I should have made that clear, the only thing I find suspicious is that no errors are logged, so the I/O operation seems to complete successfully. As you suspected, search will fail to find references in the cases I saw the problem. But testing this I noticed that contrary to what I said initially, the problem happens for some packages only (every time), not all of them. I don't understand yet what is the trigger. 

Re: comment 4 - John, one case I saw this happening was when having the org.eclipse.core.content plug-in imported as source into a project that lives in our file system implementation. Renaming the org.eclipse.core.internal.content package to org.eclipse.core.internal.content2 did not update references from org.eclipse.core.content.

Meanwhile, I will try to reproduce the problem in debug mode and see what is going on.
Comment 6 Rafael Chaves CLA 2006-05-17 11:41:19 EDT
John, I could not make a test case that reproduced the problem, other than our own code base and the case in org.eclipse.core.content. Using import package.* instead of import package.type affects the results of my testing, in the cases I was able to reproduce the problem. It seems that having import package.* will cause the reference to be properly found.

Will try to see if I can reproduce the problem with the in-memory filesystem and the content type project.
Comment 7 Markus Keller CLA 2006-05-17 11:56:24 EDT
Rafael, this sounds like a broken search index for the affected file. Can you try to reproduce in a new workspace? If it works in another workspace, then it might be enough to rebuild the search index.
Comment 8 Rafael Chaves CLA 2006-05-17 13:12:05 EDT
I cannot reproduce it with the wrapper file system from org.eclipse.core.tests.resources, which is similar to ours. That would indicate that the problem is indeed in our EFS file system implementation.

Feel free to close as user error.
Comment 9 Frederic Fusier CLA 2006-05-18 02:57:47 EDT
Thanks for the feedback
Comment 10 Rafael Chaves CLA 2006-05-18 12:04:31 EDT
Ok, I ended up taking the wrong track while investigating this, but now I think I understand the problem.

ResourceCompilationUnit will take the file location URI scheme specific part as the compilation unit file name. In my case, the URI has a query as well, it looks like this:

protocol:/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/Activator.java?file:/D:/dev/runtime-New_configuration

So the compilation unit in this case will be /path/?query. For instance:

/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/Activator.java?file:/D:/dev/runtime-New_configuration

URI.getPath() returns the path only, shouldn't that be used as the compilation unit name instead?

Search will use the bogus compilation unit name later on in PackageReferenceLocator#isDeclaringPackageFragment() and will get confused by the query part.
Comment 11 Philipe Mulet CLA 2006-05-18 15:01:07 EDT
Given EFS is new to 3.2, we want to address it in maintenance release.
I don't think it is a stop ship issue for 3.2.0 at this stage in the game.
Comment 12 John Arthorne CLA 2006-05-19 10:06:15 EDT
Agree this is not critical for 3.2.  The CompilationUnit class later assumes that the "fileName" field refers to the local file system in the getContents method, so this would be non-trivial to fix.
Comment 13 Jerome Lanneluc CLA 2006-05-19 10:38:12 EDT
getContents() is actually overriden in ResourceCompilationUnit. CompilationUnit is used by the batch compiler only, so the assumption is ok.
Comment 14 Jerome Lanneluc CLA 2006-06-20 11:06:18 EDT
Created attachment 44920 [details]
Thanks Rafael. Here is the corresponding fix.
Comment 15 Jerome Lanneluc CLA 2006-06-20 11:10:01 EDT
Fix released for 3.3 M1 in HEAD and released for 3.2.1 in TARGET_321 branch.
Comment 16 Frederic Fusier CLA 2006-08-07 06:23:27 EDT
Verified for 3.3 M1 using build I20060807-0010.
Comment 17 David Audel CLA 2006-09-12 09:00:52 EDT
Verified for 3.2.1 using build M20060908-1655