Skip to content

Commit

Permalink
Scripted: Codemod ReactApplicationContext creators to BridgeReactContext
Browse files Browse the repository at this point in the history
Summary:
The things that create ReactApplicationContext should instead create BridgeReactContext.

Long-term, ReactApplicationContext will be abstract. This diff pulls noise out from that eventual diff.

Changelog: [Internal]

Differential Revision: https://internalfb.com/D55218591
  • Loading branch information
RSNara authored and facebook-github-bot committed Mar 22, 2024
1 parent 5a5ba8f commit 7212061
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.facebook.react

import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ViewManager
Expand All @@ -33,7 +34,7 @@ class CompositeReactPackageTest {
packageNo1 = mock(ReactPackage::class.java)
packageNo2 = mock(ReactPackage::class.java)
packageNo3 = mock(ReactPackage::class.java)
reactContext = ReactApplicationContext(RuntimeEnvironment.getApplication())
reactContext = BridgeReactContext(RuntimeEnvironment.getApplication())
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.CatalystInstance
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.ReactTestHelper
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object ReactTestHelper {
*/
@JvmStatic
fun createCatalystContextForTest(): ReactApplicationContext =
ReactApplicationContext(RuntimeEnvironment.getApplication()).apply {
BridgeReactContext(RuntimeEnvironment.getApplication()).apply {
initializeWithInstance(createMockCatalystInstance())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.facebook.react.fabric

import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ViewManagerRegistry
import com.facebook.react.uimanager.events.BatchEventDispatchedListener
Expand All @@ -31,7 +32,7 @@ class FabricUIManagerTest {

@Before
fun setup() {
reactContext = ReactApplicationContext(RuntimeEnvironment.getApplication())
reactContext = BridgeReactContext(RuntimeEnvironment.getApplication())
viewManagerRegistry = ViewManagerRegistry(emptyList())
batchEventDispatchedListener = FakeBatchEventDispatchedListener()
underTest = FabricUIManager(reactContext, viewManagerRegistry, batchEventDispatchedListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

package com.facebook.react.internal.interop

import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContext
import com.facebook.testutils.fakes.FakeEventDispatcher
import org.junit.Assert.assertEquals
Expand All @@ -29,7 +29,7 @@ class InteropEventEmitterTest {

@Before
fun setup() {
reactContext = ReactApplicationContext(RuntimeEnvironment.getApplication())
reactContext = BridgeReactContext(RuntimeEnvironment.getApplication())
eventDispatcher = FakeEventDispatcher()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package com.facebook.react.modules.clipboard
import android.annotation.SuppressLint
import android.content.ClipboardManager
import android.content.Context
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.BridgeReactContext
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
Expand All @@ -28,7 +28,7 @@ class ClipboardModuleTest {

@Before
fun setUp() {
clipboardModule = ClipboardModule(ReactApplicationContext(RuntimeEnvironment.getApplication()))
clipboardModule = ClipboardModule(BridgeReactContext(RuntimeEnvironment.getApplication()))
clipboardManager =
RuntimeEnvironment.getApplication().getSystemService(Context.CLIPBOARD_SERVICE)
as ClipboardManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package com.facebook.react.uimanager

import android.view.View
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.common.MapBuilder
Expand Down Expand Up @@ -84,7 +84,7 @@ class ReactPropConstantsTest {
@Test
fun testNativePropsIncludeCorrectTypes() {
val viewManagers = listOf<ViewManager<*, *>>(ViewManagerUnderTest())
val reactContext = ReactApplicationContext(RuntimeEnvironment.getApplication())
val reactContext = BridgeReactContext(RuntimeEnvironment.getApplication())
val uiManagerModule = UIManagerModule(reactContext, viewManagers, 0)
val constants: Map<*, *> =
valueAtPath(uiManagerModule.constants as Map<*, *>, "SomeView", "NativeProps")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

package com.facebook.react.uimanager

import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.uimanager.annotations.ReactProp
Expand Down Expand Up @@ -65,7 +65,7 @@ class ReactPropForShadowNodeSetterTest {

init {
setViewClassName("ShadowViewUnderTest")
val context = ReactApplicationContext(RuntimeEnvironment.getApplication())
val context = BridgeReactContext(RuntimeEnvironment.getApplication())
setThemedContext(ThemedReactContext(context, context, null, -1))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package com.facebook.react.uimanager

import android.graphics.drawable.ColorDrawable
import android.view.View
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.CatalystInstance
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactTestHelper.createMockCatalystInstance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.uimanager

import android.view.View
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.common.MapBuilder
import org.assertj.core.api.Assertions
Expand Down Expand Up @@ -49,7 +50,7 @@ class UIManagerModuleConstantsTest {

@Before
fun setUp() {
reactContext = ReactApplicationContext(RuntimeEnvironment.getApplication())
reactContext = BridgeReactContext(RuntimeEnvironment.getApplication())
}

@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.util.DisplayMetrics
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.CatalystInstance
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import android.util.DisplayMetrics
import android.view.Gravity
import android.view.inputmethod.EditorInfo
import androidx.core.content.res.ResourcesCompat.ID_NULL
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.CatalystInstance
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactTestHelper.createMockCatalystInstance
Expand Down

0 comments on commit 7212061

Please sign in to comment.