Skip to content

Commit

Permalink
added annotation to find exact package for moxy reflector deleaget
Browse files Browse the repository at this point in the history
  • Loading branch information
svcorporate committed Jul 22, 2019
1 parent 3b01fca commit b803983
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.arellomobile.mvp.compiler;

import com.arellomobile.mvp.InjectViewState;
import com.arellomobile.mvp.RegisterMoxyReflectorDelegate;
import com.arellomobile.mvp.compiler.presenterbinder.InjectPresenterProcessor;
import com.arellomobile.mvp.compiler.presenterbinder.PresenterBinderClassGenerator;
import com.arellomobile.mvp.compiler.reflector.MoxyReflectorGenerator;
Expand Down Expand Up @@ -76,10 +77,12 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
@Override
public Set<String> getSupportedAnnotationTypes() {
Set<String> supportedAnnotationTypes = new HashSet<>();
Collections.addAll(supportedAnnotationTypes,
Collections.addAll(
supportedAnnotationTypes,
InjectPresenter.class.getCanonicalName(),
InjectViewState.class.getCanonicalName()
);
InjectViewState.class.getCanonicalName(),
RegisterMoxyReflectorDelegate.class.getCanonicalName()
);
return supportedAnnotationTypes;
}

Expand Down Expand Up @@ -141,16 +144,21 @@ private boolean throwableProcess(RoundEnvironment roundEnv) {
return true;
}

/**
* @return first package associated with this module.
* Probably should return module's top-level package
*/
private String getMoxyReflectorDelegatePackage(
final RoundEnvironment roundEnv
) {
final Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(RegisterMoxyReflectorDelegate.class);

if (elements.isEmpty()) {
getMessager().printMessage(
Diagnostic.Kind.ERROR,
"Cannot find any class annotated with " + RegisterMoxyReflectorDelegate.class.getSimpleName() + " in this module"
);
}

return processingEnv
.getElementUtils()
.getPackageOf(roundEnv.getElementsAnnotatedWith(InjectPresenter.class).iterator().next())
.getPackageOf(elements.iterator().next())
.getQualifiedName()
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.arellomobile.mvp;

import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;

/**
* Register MoxyReflector package
*/
@Target(TYPE)
public @interface RegisterMoxyReflectorDelegate {}

This file was deleted.

0 comments on commit b803983

Please sign in to comment.