Bug 213513 - [plan] [jdt-weaving] [editor] [refactoring] Files deleted upon failed move refactoring of aspect (.aj) file
Summary: [plan] [jdt-weaving] [editor] [refactoring] Files deleted upon failed move re...
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.6.1   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-19 14:22 EST by Adrian Sampaleanu CLA
Modified: 2012-04-03 14:18 EDT (History)
2 users (show)

See Also:


Attachments
The project .classpath file (1.48 KB, application/xml)
2007-12-19 14:22 EST, Adrian Sampaleanu CLA
no flags Details
The project file (1.45 KB, application/xml)
2007-12-19 14:24 EST, Adrian Sampaleanu CLA
no flags Details
The Maven 2 pom file (19.77 KB, application/xml)
2007-12-19 14:26 EST, Adrian Sampaleanu CLA
no flags Details
The Eclipse log file (123.96 KB, text/plain)
2007-12-19 14:27 EST, Adrian Sampaleanu CLA
no flags Details
when jdt weaving is applied, this patch will enable proper compilation unit rename refactoring for aj files (2.54 KB, patch)
2008-10-13 13:09 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Sampaleanu CLA 2007-12-19 14:22:37 EST
Created attachment 85591 [details]
The project .classpath file

Build ID: M20071205-0800

Steps To Reproduce:
1. Aspect file (.aj ext) exists in one package
2. Context click in project explorer and select move refactoring
3. Select destination package
4. Dialog pops up informing of problem - non related xml file opened in editor disappears and is later found to be deleted. Additional files (all were non source i.e. neither .java or .aj) were found to have been deleted.


More information:
Aspect was moved to target package even though the exceptions were thrown in the refactoring. Additionally, a name refactoring for the same file failed just before this operation when the file was opened in an editor - the refactoring was initiated in the project explorer by context clicking the .java file child in the tree (there is a child with an .aj extension as well, not sure if this is normal). The result of the name change refactoring left the file with a changed name, but with the old name as the aspect name inside the file. 
The reason I'm mentioning the name change refactoring is that it might be related to the failed move refactoring.

The build is controlled by Eclipse and Maven 2 - I have Maven integration through the m2eclipse plugin. Eclipse is set up to build to the same target directories as Maven. The files that were deleted are specified in the .classpath file in a nonstandard way in terms of source and output directories. The reason is that when Maven builds, there is some token expansion, so it doesn't make sense for Eclipse to automatically copy these to the output without this expansion so these source directories are mapped to themselves as the output. This necessitates a Maven build before everything is available in the output location, but this is a minor annoyance compared to the benefit of being able to use Eclipse and Maven in parallel. We haven't really had any issues with the build so far.

This deletion of non source files has also happened with another co-worker when she added aspect support to the same project (my changes to add this nature to the project are local as I was afraid of committing with this possible freak occurrence).

Interestingly, I don't see anything in the log related to this refactoring, but I do see one exception due to one of the files (mockApplicationBeanRef.xml) being missing after the deletion happened. I will include the complete log file as an attachment.

eclipse.buildId=M20071205-0800
java.version=1.6.0_03
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_CA
Framework arguments:  -showlocation
Command-line arguments:  -os win32 -ws win32 -arch x86 -clean -showlocation
This is a continuation of log file C:\dev\eclipse-workspace-general\.metadata\.bak_0.log
Created Time: 2007-12-18 23:28:02.248
Comment 1 Adrian Sampaleanu CLA 2007-12-19 14:24:13 EST
Created attachment 85592 [details]
The project file
Comment 2 Adrian Sampaleanu CLA 2007-12-19 14:26:00 EST
Created attachment 85593 [details]
The Maven 2 pom file
Comment 3 Adrian Sampaleanu CLA 2007-12-19 14:27:26 EST
Created attachment 85594 [details]
The Eclipse log file
Comment 4 Andrew Eisenberg CLA 2008-08-22 17:35:19 EDT
Thanks for the detailed information on this bug.  I will look into this after 1.6.0 comes out.

I think it is related to bug 151067.  (Not necessarily duplicate, though.
Comment 5 Andrew Eisenberg CLA 2008-10-13 12:58:12 EDT
There seems to be 2 issues here.

First, I think the problem is that JDT has changed the way it processes resource rename refactoring.  In the past resource rename refactorings used the same factory class as compilation unit rename refactorings.  Now it is created in a different manner.  So, when we ask the old factory to create a rename resource refactoring, it returns null.

The second problem is that AJDT is using the rename *resource* refactoring instead of the rename *compilation unit* refactoring.  So, even if it did refactor properly, the Aspect would still have the old name.

When I change the action to use the proper kind of refactoring, still doesn't work.  The reason is that there is a call to org.eclipse.jdt.internal.corext.refactoring.Checks.checkIfCuBroken(IMember)  gets the underlying resource and asks JavaCore to create an ICompilationUnit for it.  This creates a CompilationUnit, not an AJCompilationUnit.  And hence the unit thinks there are syntax errors and the refactoring cannot proceed.

When I get jdt weaving to work, this problem should go away as long as the proper Compilation unit refactoring is being used.
Comment 6 Andrew Eisenberg CLA 2008-10-13 13:09:40 EDT
Created attachment 114961 [details]
when jdt weaving is applied, this patch will enable proper compilation unit rename refactoring for aj files

This patch on its own will not enable rename refactoring for compilation units, but will turn it on once jdt weaving is in place.
Comment 7 Andrew Clement CLA 2008-10-16 13:51:28 EDT
patch from comment 6 is in.
Comment 8 Andrew Eisenberg CLA 2008-12-16 11:31:32 EST
This problem is now fixed with JDT weaving enabled