Skip to content

Commit

Permalink
Scripted: Codemod ReactApplicationContext creators to BridgeReactCont…
Browse files Browse the repository at this point in the history
…ext (#43626)

Summary:
Pull Request resolved: #43626

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]

Reviewed By: arushikesarwani94

Differential Revision: D55218591

fbshipit-source-id: d359c794f3da4a1ecb2fa8edbed5eeeb620b137b
  • Loading branch information
RSNara authored and facebook-github-bot committed Mar 26, 2024
1 parent a984169 commit 8eb1bd1
Show file tree
Hide file tree
Showing 8 changed files with 15 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 @@ -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 @@ -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

0 comments on commit 8eb1bd1

Please sign in to comment.