add viewManager param to @ReactModuleList

Reviewed By: achen1

Differential Revision: D4338871

fbshipit-source-id: 4ac175e0a9049d5fb08c9d01f630a3e17124e08e
This commit is contained in:
Aaron Chiu 2016-12-16 15:22:53 -08:00 committed by Facebook Github Bot
parent 71f32fb5a3
commit c27cc9c1ac
3 changed files with 26 additions and 18 deletions

View File

@ -52,20 +52,22 @@ import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_M
* require special integration with other framework parts (e.g. with the list of packages to load * require special integration with other framework parts (e.g. with the list of packages to load
* view managers from). * view managers from).
*/ */
@ReactModuleList({ @ReactModuleList(
AndroidInfoModule.class, javaModules = {
AnimationsDebugModule.class, AndroidInfoModule.class,
DeviceEventManagerModule.class, AnimationsDebugModule.class,
ExceptionsManagerModule.class, DeviceEventManagerModule.class,
HeadlessJsTaskSupportModule.class, ExceptionsManagerModule.class,
SourceCodeModule.class, HeadlessJsTaskSupportModule.class,
Timing.class, SourceCodeModule.class,
UIManagerModule.class, Timing.class,
// Debug only UIManagerModule.class,
DebugComponentOwnershipModule.class, // Debug only
JSCHeapCapture.class, DebugComponentOwnershipModule.class,
JSCSamplingProfiler.class, JSCHeapCapture.class,
}) JSCSamplingProfiler.class,
}
)
/* package */ class CoreModulesPackage extends LazyReactPackage { /* package */ class CoreModulesPackage extends LazyReactPackage {
private final ReactInstanceManager mReactInstanceManager; private final ReactInstanceManager mReactInstanceManager;

View File

@ -19,8 +19,14 @@ import static java.lang.annotation.RetentionPolicy.SOURCE;
public @interface ReactModuleList { public @interface ReactModuleList {
/** /**
* The native modules in this list should be annotated with {@link ReactModule}. * The Java modules in this list should be annotated with {@link ReactModule}.
* @return List of native modules. * @return List of Java modules in the package.
*/ */
Class<? extends NativeModule>[] value(); Class<? extends NativeModule>[] javaModules();
/**
* The View Managers in this list should be annotated with {@link ReactModule}.
* @return List of view manager in the package.
*/
Class<? extends NativeModule>[] viewManagers() default {};
} }

View File

@ -87,7 +87,7 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
ReactModuleList reactModuleList = typeElement.getAnnotation(ReactModuleList.class); ReactModuleList reactModuleList = typeElement.getAnnotation(ReactModuleList.class);
List<String> nativeModules = new ArrayList<>(); List<String> nativeModules = new ArrayList<>();
try { try {
reactModuleList.value(); // throws MirroredTypesException reactModuleList.javaModules(); // throws MirroredTypesException
} catch (MirroredTypesException mirroredTypesException) { } catch (MirroredTypesException mirroredTypesException) {
List<? extends TypeMirror> typeMirrors = mirroredTypesException.getTypeMirrors(); List<? extends TypeMirror> typeMirrors = mirroredTypesException.getTypeMirrors();
for (TypeMirror typeMirror : typeMirrors) { for (TypeMirror typeMirror : typeMirrors) {