Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313770

Summary: Organize imports in aspect not working due to spurious compile problem
Product: [Tools] AJDT Reporter: Andrew Eisenberg <andrew.eisenberg>
Component: UIAssignee: AJDT-inbox <AJDT-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0.2   
Target Milestone: 2.1.0   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Andrew Eisenberg CLA 2010-05-20 13:00:23 EDT
From the forum:
http://www.eclipse.org/forums/index.php?t=msg&goto=534694&#msg_534694

=========================

i have an aspect with an inter-type declaration, which looks like this:


package de.wieger.domaindriven.sample;

<lots of unused imports>

privileged aspect Person_ITD {
Person.new(PersonBuilder pBuilder) {
this();
}
}


If i invoke "Organize Imports" in eclipse, i get the following error:
"Compilation unit has parse errors: Constructor call must be the first statement in a constructor".
I'm using AJDT 2.0.2.

It looks like this is a bug. Is anybody else experiencing this?
Should i file a bug for this in bugzilla?

From my prospective, it seems like the method AjOrganizeImportsOperation#collectReferences is a little bit too strict about what should be considered as a relevant parsing error.
I have seen, that AjCompilationUnitProblemFinder filters a lot of problems like the one causing trouble when invoking "organize imports" out.
There is an explicit snippet, dealing with my problem:

if (numArgs == 0 && id == IProblem.InvalidExplicitConstructorCall) {
// ITD constructor making explicit this() call.
// lots of potential for false negatives
return false;
}


Maybe this could indicate the direction for a fix?
What do you think?
Comment 1 Andrew Eisenberg CLA 2010-05-20 13:02:21 EDT
The fix described here is the way to go.  I have implemented a fix such that the AJCompilationUnitProblemFinder is queried in order to determine if the problem that is found is one that can be ignored.  This appears to work, but unfortunately, there are no tests in this area...
Comment 2 Andrew Eisenberg CLA 2010-05-21 12:27:51 EDT
Fixed and committed.