|
1 | 1 | package com.arellomobile.mvp.compiler; |
2 | 2 |
|
3 | 3 | import com.arellomobile.mvp.InjectViewState; |
| 4 | +import com.arellomobile.mvp.RegisterMoxyReflectorDelegate; |
4 | 5 | import com.arellomobile.mvp.compiler.presenterbinder.InjectPresenterProcessor; |
5 | 6 | import com.arellomobile.mvp.compiler.presenterbinder.PresenterBinderClassGenerator; |
6 | 7 | import com.arellomobile.mvp.compiler.reflector.MoxyReflectorGenerator; |
@@ -76,10 +77,12 @@ public synchronized void init(ProcessingEnvironment processingEnv) { |
76 | 77 | @Override |
77 | 78 | public Set<String> getSupportedAnnotationTypes() { |
78 | 79 | Set<String> supportedAnnotationTypes = new HashSet<>(); |
79 | | - Collections.addAll(supportedAnnotationTypes, |
| 80 | + Collections.addAll( |
| 81 | + supportedAnnotationTypes, |
80 | 82 | InjectPresenter.class.getCanonicalName(), |
81 | | - InjectViewState.class.getCanonicalName() |
82 | | - ); |
| 83 | + InjectViewState.class.getCanonicalName(), |
| 84 | + RegisterMoxyReflectorDelegate.class.getCanonicalName() |
| 85 | + ); |
83 | 86 | return supportedAnnotationTypes; |
84 | 87 | } |
85 | 88 |
|
@@ -141,16 +144,21 @@ private boolean throwableProcess(RoundEnvironment roundEnv) { |
141 | 144 | return true; |
142 | 145 | } |
143 | 146 |
|
144 | | - /** |
145 | | - * @return first package associated with this module. |
146 | | - * Probably should return module's top-level package |
147 | | - */ |
148 | 147 | private String getMoxyReflectorDelegatePackage( |
149 | 148 | final RoundEnvironment roundEnv |
150 | 149 | ) { |
| 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 | + |
151 | 159 | return processingEnv |
152 | 160 | .getElementUtils() |
153 | | - .getPackageOf(roundEnv.getElementsAnnotatedWith(InjectPresenter.class).iterator().next()) |
| 161 | + .getPackageOf(elements.iterator().next()) |
154 | 162 | .getQualifiedName() |
155 | 163 | .toString(); |
156 | 164 | } |
|
0 commit comments