declex icon indicating copy to clipboard operation
declex copied to clipboard

@Export should support "onlyIn" parameter

Open smaugho opened this issue 6 years ago • 0 comments

The @Export annotation should permit to specify in which classes it should Export the method. For instance, commonly some methods are intended to be used only in an activity, but the class itself can be used in many different classes (Fragments, ViewModels), for instance:

    @Export
    @RunWith("onActivityResult")
    public void facebookLoginOnActivityResult(int requestCode, int resultCode, Intent data) {
        if (callbackManager != null) {
            callbackManager.onActivityResult(requestCode, resultCode, data);
        }
    }

Currently, if you inject a class which has this into another class (ie: a ViewModel), it will try to export the "facebookLoginOnActivityResult" method there (even if it is not used). This causes unnecessary grow of the generated code.

It would be good to have something like:

@Export(onlyIn={Activity.class, SomeOther.class})
...

So, it will export the method only for the given classes or its subclasses.

smaugho avatar Jan 30 '18 10:01 smaugho