Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 313770 - Organize imports in aspect not working due to spurious compile problem
Summary: Organize imports in aspect not working due to spurious compile problem
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: UI (show other bugs)
Version: 2.0.2   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 2.1.0   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-20 13:00 EDT by Andrew Eisenberg CLA
Modified: 2010-05-21 12:27 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.