Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 313808 - "Organize Imports" on inter-type constructor declaration with this() in body complains "Compilation unit has parse errors"
Summary: "Organize Imports" on inter-type constructor declaration with this() in body ...
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 16:14 EDT by Thomas Wieger CLA
Modified: 2010-05-20 19:51 EDT (History)
1 user (show)

See Also:


Attachments
mini project with problematic inter-type constructor declaration (4.05 KB, application/zip)
2010-05-20 16:14 EDT, Thomas Wieger CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wieger CLA 2010-05-20 16:14:58 EDT
Created attachment 169412 [details]
mini project with problematic inter-type constructor declaration

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

package de.wieger.sample;

public aspect Person_ITD {
    public Person.new() {
        this();
        // intentionally left blank
    }
}


When 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".

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#isARealProblem filters out a lot of problems like the one causing trouble when invoking "organize imports". The method conains an explicit snippet, dealing with the problematic syntactic construct:

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?

I have attached an archive with a mini project containing the source code, which demonstrates the problem when invoking "organize imports" on the inter-type declaration.

regards,

Thomas Wieger
Comment 1 Andrew Eisenberg CLA 2010-05-20 19:51:36 EDT
Fix is available in the latest dev build.  Thanks for the sample project.
Comment 2 Andrew Eisenberg CLA 2010-05-20 19:51:57 EDT
fixed.