Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 353620 - Annotation processor doesn't generate impl for inner interfaces correctly
Summary: Annotation processor doesn't generate impl for inner interfaces correctly
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Sapphire (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Konstantin Komissarchik CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-02 13:11 EDT by Konstantin Komissarchik CLA
Modified: 2021-11-19 09:22 EST (History)
1 user (show)

See Also:


Attachments

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