From 367c71241ab15e7e50a6a4ba37b99851485e564e Mon Sep 17 00:00:00 2001
From: Aaron Chiu
Date: Fri, 2 Sep 2016 19:02:38 -0700
Subject: [PATCH] convert CoreModulesPackage to use @ReactModuleList
Reviewed By: astreet
Differential Revision: D3809512
fbshipit-source-id: 658284c642d55cf5f90e16901fdf6d4229d6b762
---
.../src/main/java/com/facebook/react/BUCK | 2 ++
.../com/facebook/react/CoreModulesPackage.java | 18 ++++++++++++++++--
.../java/com/facebook/react/devsupport/BUCK | 1 +
.../react/devsupport/JSCHeapCapture.java | 2 ++
.../react/devsupport/JSCSamplingProfiler.java | 3 ++-
.../processing/ReactModuleSpecProcessor.java | 3 ++-
.../java/com/facebook/react/uimanager/BUCK | 1 +
.../react/uimanager/UIManagerModule.java | 14 ++++++++------
.../debug/DebugComponentOwnershipModule.java | 2 ++
9 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/ReactAndroid/src/main/java/com/facebook/react/BUCK b/ReactAndroid/src/main/java/com/facebook/react/BUCK
index 8f6ccfd11..1d8a7bc4c 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/BUCK
+++ b/ReactAndroid/src/main/java/com/facebook/react/BUCK
@@ -5,6 +5,8 @@ DEPS = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/devsupport:devsupport'),
+ react_native_target('java/com/facebook/react/module/annotations:annotations'),
+ react_native_target('java/com/facebook/react/module/model:model'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/modules/debug:debug'),
react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'),
diff --git a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java
index 51f4776c5..f490595cd 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java
@@ -13,6 +13,7 @@ import javax.inject.Provider;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import com.facebook.react.bridge.JavaScriptModule;
@@ -23,6 +24,7 @@ import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.devsupport.HMRClient;
import com.facebook.react.devsupport.JSCHeapCapture;
import com.facebook.react.devsupport.JSCSamplingProfiler;
+import com.facebook.react.module.annotations.ReactModuleList;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.core.ExceptionsManagerModule;
@@ -45,6 +47,18 @@ import com.facebook.systrace.Systrace;
* require special integration with other framework parts (e.g. with the list of packages to load
* view managers from).
*/
+@ReactModuleList({
+ AnimationsDebugModule.class,
+ AndroidInfoModule.class,
+ DeviceEventManagerModule.class,
+ ExceptionsManagerModule.class,
+ Timing.class,
+ SourceCodeModule.class,
+ UIManagerModule.class,
+ DebugComponentOwnershipModule.class,
+ JSCHeapCapture.class,
+ JSCSamplingProfiler.class,
+})
/* package */ class CoreModulesPackage extends LazyReactPackage {
private final ReactInstanceManager mReactInstanceManager;
@@ -62,7 +76,7 @@ import com.facebook.systrace.Systrace;
@Override
public List getNativeModules(final ReactApplicationContext reactContext) {
- List moduleSpecList = new ArrayList();
+ List moduleSpecList = new ArrayList<>();
moduleSpecList.add(
new ModuleSpec(AnimationsDebugModule.class, new Provider() {
@Override
@@ -164,7 +178,7 @@ import com.facebook.systrace.Systrace;
@Override
public List createViewManagers(ReactApplicationContext reactContext) {
- return new ArrayList<>(0);
+ return Collections.emptyList();
}
private UIManagerModule createUIManager(ReactApplicationContext reactContext) {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK
index a619b5090..791cf31ef 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK
+++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK
@@ -15,6 +15,7 @@ android_library(
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common/network:network'),
react_native_target('java/com/facebook/react/common:common'),
+ react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/debug:debug'),
react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'),
react_native_target('res:devsupport'),
diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java
index a8824fd79..7db70f572 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java
@@ -20,7 +20,9 @@ import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
+import com.facebook.react.module.annotations.ReactModule;
+@ReactModule(name = "JSCHeapCapture")
public class JSCHeapCapture extends ReactContextBaseJavaModule {
public interface HeapCapture extends JavaScriptModule {
void captureHeap(String path);
diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java
index 89a03e802..4a35aa74d 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java
@@ -11,7 +11,6 @@ package com.facebook.react.devsupport;
import javax.annotation.Nullable;
-import java.io.File;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -20,7 +19,9 @@ import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
+import com.facebook.react.module.annotations.ReactModule;
+@ReactModule(name = "JSCSamplingProfiler")
public class JSCSamplingProfiler extends ReactContextBaseJavaModule {
public interface SamplingProfiler extends JavaScriptModule {
void poke(int token);
diff --git a/ReactAndroid/src/main/java/com/facebook/react/module/processing/ReactModuleSpecProcessor.java b/ReactAndroid/src/main/java/com/facebook/react/module/processing/ReactModuleSpecProcessor.java
index 63cb06699..4d582c9a9 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/module/processing/ReactModuleSpecProcessor.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/module/processing/ReactModuleSpecProcessor.java
@@ -139,7 +139,8 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
TypeElement typeElement = mElements.getTypeElement(nativeModule);
ReactModule reactModule = typeElement.getAnnotation(ReactModule.class);
if (reactModule == null) {
- throw new ReactModuleSpecException(keyString + " not found.");
+ throw new ReactModuleSpecException(keyString + " not found by ReactModuleSpecProcessor. " +
+ "Did you forget to add the @ReactModule annotation the the native module?");
}
String valueString = new StringBuilder()
.append("new ReactModuleInfo(")
diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK
index 3a0956b27..1c4d06fe9 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK
+++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK
@@ -18,6 +18,7 @@ android_library(
react_native_target('java/com/facebook/react/animation:animation'),
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
+ react_native_target('java/com/facebook/react/module/annotations:annotations'),
react_native_target('java/com/facebook/react/modules/i18nmanager:i18nmanager'),
react_native_target('java/com/facebook/react/touch:touch'),
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java
index 7e6c389cd..f0d9938ea 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java
@@ -27,6 +27,7 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.ReactConstants;
+import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace;
@@ -37,12 +38,12 @@ import com.facebook.systrace.SystraceMessage;
*
*
*
== Transactional Requirement ==
- * A requirement of this class is to make sure that transactional UI updates occur all at once, meaning
- * that no intermediate state is ever rendered to the screen. For example, if a JS application
- * update changes the background of View A to blue and the width of View B to 100, both need to
- * appear at once. Practically, this means that all UI update code related to a single transaction
- * must be executed as a single code block on the UI thread. Executing as multiple code blocks
- * could allow the platform UI system to interrupt and render a partial UI state.
+ * A requirement of this class is to make sure that transactional UI updates occur all at once,
+ * meaning that no intermediate state is ever rendered to the screen. For example, if a JS
+ * application update changes the background of View A to blue and the width of View B to 100, both
+ * need to appear at once. Practically, this means that all UI update code related to a single
+ * transaction must be executed as a single code block on the UI thread. Executing as multiple code
+ * blocks could allow the platform UI system to interrupt and render a partial UI state.
*
*
* To facilitate this, this module enqueues operations that are then applied to native view
@@ -61,6 +62,7 @@ import com.facebook.systrace.SystraceMessage;
* consider implementing a pool
* TODO(5483063): Don't dispatch the view hierarchy at the end of a batch if no UI changes occurred
*/
+@ReactModule(name = "RKUIManager")
public class UIManagerModule extends ReactContextBaseJavaModule implements
OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java
index 3500d64f9..a38af1d06 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java
@@ -20,12 +20,14 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
+import com.facebook.react.module.annotations.ReactModule;
/**
* Native module that can asynchronously request the owners hierarchy of a react tag.
*
* Example returned owner hierarchy: ['RootView', 'Dialog', 'TitleView', 'Text']
*/
+@ReactModule(name = "DebugComponentOwnershipModule")
public class DebugComponentOwnershipModule extends ReactContextBaseJavaModule {
public interface RCTDebugComponentOwnership extends JavaScriptModule {