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

Bug 353620

Summary: Annotation processor doesn't generate impl for inner interfaces correctly
Product: z_Archived Reporter: Konstantin Komissarchik <konstantin>
Component: SapphireAssignee: Konstantin Komissarchik <konstantin>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ling.hao
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Konstantin Komissarchik CLA 2011-08-02 13:11:47 EDT
Given the following model element type declaration (notice the inner type declaration), the annotation processor produces implementation classes ParentImpl and ChildImpl whereas it should produce ParentImpl and ParentImpl$ChildImpl classes.

@GenerateImpl

public interface Parent extends IModelElement
{
    ModelElementType TYPE = new ModelElementType( Parent.class );
    
    // *** Children ***

    @GenerateImpl

    public interface Child extends IModelElement
    {
        ModelElementType TYPE = new ModelElementType( Child.class );
    
        // *** Name ***
    
        ValueProperty PROP_NAME = new ValueProperty( TYPE, "Name" );
    
        Value<String> getName();
        void setName( String value );
    }

    @Type( base = ServicePortNameWrapper.class )
    
    ListProperty PROP_CHILDREN = new ListProperty( TYPE, "Children" );
    
    ModelElementList<Child> getChildren();
}
Comment 1 Konstantin Komissarchik CLA 2011-08-02 13:37:13 EDT
> whereas it should produce ParentImpl and ParentImpl$ChildImpl classes.

Thinking about it some more, it should really produce Parent$ChildImpl as the logic that generates the default implementation class name should not making any assumptions about the class/interface containing the model element interface with @GenerateImpl annotation. It could be another model element interface or it could be an arbitrary class.
Comment 2 Konstantin Komissarchik CLA 2011-08-02 15:57:47 EDT
Fixed.

Since the logic for deriving the impl class name has gotten to be fairly involved, I refactored it into a set of new static methods ModelElementType.getImplClassName(). These methods are called by the annotation processor and at runtime when locating the impl class to instantiate. 

TestModelingMisc0006 covers the new method, including the handling of inner classes.
Comment 3 Konstantin Komissarchik CLA 2011-09-02 12:57:56 EDT
I need to back port this to 0.3.1. Re-opening.
Comment 4 Konstantin Komissarchik CLA 2011-09-02 14:09:15 EDT
Done.
Comment 5 Ling Hao CLA 2011-09-28 18:24:25 EDT
Verify via TestModelingMisc0006 and that the original model element sample does generate Parent and IParent$ChildImpl classes.