Skip to content

Commit b803983

Browse files
committed
added annotation to find exact package for moxy reflector deleaget
1 parent 3b01fca commit b803983

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

moxy-compiler/src/main/java/com/arellomobile/mvp/compiler/MvpCompiler.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.arellomobile.mvp.compiler;
22

33
import com.arellomobile.mvp.InjectViewState;
4+
import com.arellomobile.mvp.RegisterMoxyReflectorDelegate;
45
import com.arellomobile.mvp.compiler.presenterbinder.InjectPresenterProcessor;
56
import com.arellomobile.mvp.compiler.presenterbinder.PresenterBinderClassGenerator;
67
import com.arellomobile.mvp.compiler.reflector.MoxyReflectorGenerator;
@@ -76,10 +77,12 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
7677
@Override
7778
public Set<String> getSupportedAnnotationTypes() {
7879
Set<String> supportedAnnotationTypes = new HashSet<>();
79-
Collections.addAll(supportedAnnotationTypes,
80+
Collections.addAll(
81+
supportedAnnotationTypes,
8082
InjectPresenter.class.getCanonicalName(),
81-
InjectViewState.class.getCanonicalName()
82-
);
83+
InjectViewState.class.getCanonicalName(),
84+
RegisterMoxyReflectorDelegate.class.getCanonicalName()
85+
);
8386
return supportedAnnotationTypes;
8487
}
8588

@@ -141,16 +144,21 @@ private boolean throwableProcess(RoundEnvironment roundEnv) {
141144
return true;
142145
}
143146

144-
/**
145-
* @return first package associated with this module.
146-
* Probably should return module's top-level package
147-
*/
148147
private String getMoxyReflectorDelegatePackage(
149148
final RoundEnvironment roundEnv
150149
) {
150+
final Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(RegisterMoxyReflectorDelegate.class);
151+
152+
if (elements.isEmpty()) {
153+
getMessager().printMessage(
154+
Diagnostic.Kind.ERROR,
155+
"Cannot find any class annotated with " + RegisterMoxyReflectorDelegate.class.getSimpleName() + " in this module"
156+
);
157+
}
158+
151159
return processingEnv
152160
.getElementUtils()
153-
.getPackageOf(roundEnv.getElementsAnnotatedWith(InjectPresenter.class).iterator().next())
161+
.getPackageOf(elements.iterator().next())
154162
.getQualifiedName()
155163
.toString();
156164
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.arellomobile.mvp;
2+
3+
import java.lang.annotation.Target;
4+
5+
import static java.lang.annotation.ElementType.TYPE;
6+
7+
/**
8+
* Register MoxyReflector package
9+
*/
10+
@Target(TYPE)
11+
public @interface RegisterMoxyReflectorDelegate {}

moxy/src/main/java/com/arellomobile/mvp/RegisterMoxyReflectorPackages.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)