Skip to content

Commit

Permalink
Mark classes of package fabric as @nullsafe (#42725)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #42725

All these classes are NullSafe, let's mark them as NullSafe(Local) to ensure lint detect errors in the future

changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D53200097

fbshipit-source-id: dad54f5bf03967b5d4126757ab0d5424534af888
  • Loading branch information
mdvacca authored and facebook-github-bot committed Feb 2, 2024
1 parent 239f9bf commit 4e6eba7
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.NativeMap;
Expand All @@ -20,6 +21,7 @@
import com.facebook.react.fabric.events.EventEmitterWrapper;
import com.facebook.react.uimanager.PixelUtil;

@Nullsafe(Nullsafe.Mode.LOCAL)
@DoNotStrip
@SuppressLint("MissingNativeLoadLibrary")
public class BindingImpl implements Binding {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
package com.facebook.react.fabric;

import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;

@Nullsafe(Nullsafe.Mode.LOCAL)
@DoNotStrip
public class ComponentFactory {

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

package com.facebook.react.fabric;

import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;

@Nullsafe(Nullsafe.Mode.LOCAL)
@DoNotStrip
public class CoreComponentsRegistry {
static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import static com.facebook.react.bridge.ReactMarkerConstants.FABRIC_UPDATE_UI_MAIN_THREAD_START;

import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class DevToolsReactPerfLogger implements ReactMarker.FabricMarkerListener {

private final Map<Integer, FabricCommitPoint> mFabricCommitMarkers = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.fabric;

import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -17,6 +18,7 @@
* <p>TODO T97384889: remove this class when the component names are unified between JS - Android -
* iOS - C++
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public class FabricComponents {

private static @NonNull final Map<String, String> sComponentNames = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;

import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.soloader.SoLoader;
import com.facebook.systrace.Systrace;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class FabricSoLoader {
private static volatile boolean sDidInit = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

import android.view.Choreographer;
import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.JSExceptionHandler;
import com.facebook.react.bridge.ReactContext;

@Nullsafe(Nullsafe.Mode.LOCAL)
public abstract class GuardedFrameCallback implements Choreographer.FrameCallback {

@NonNull private final JSExceptionHandler mExceptionHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.NativeMap;
Expand All @@ -23,6 +24,7 @@
* This class holds reference to the C++ EventEmitter object. Instances of this class are created on
* the Bindings.cpp, where the pointer to the C++ event emitter is set.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
@SuppressLint("MissingNativeLoadLibrary")
@DoNotStrip
public class StateWrapperImpl implements StateWrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getMinSize;

import androidx.annotation.IntDef;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.NativeMap;
import com.facebook.react.interfaces.fabric.SurfaceHandler;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class SurfaceHandlerBinding implements SurfaceHandler {
static {
FabricSoLoader.staticInit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactApplicationContext;
Expand All @@ -18,6 +19,7 @@
/**
* Class that acts as a proxy between the list of EventBeats registered in C++ and the Android side.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
@SuppressLint("MissingNativeLoadLibrary")
public final class EventBeatManager implements BatchEventDispatchedListener {

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

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.fabric.FabricUIManager;
Expand All @@ -18,6 +19,7 @@
import com.facebook.react.uimanager.events.TouchEvent;
import com.facebook.systrace.Systrace;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class FabricEventEmitter implements RCTModernEventEmitter {

@NonNull private final FabricUIManager mUIManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import static android.view.View.MeasureSpec.EXACTLY;

import android.view.View;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.yoga.YogaMeasureMode;

@Nullsafe(Nullsafe.Mode.LOCAL)
public interface LayoutMetricsConversions {

static float getMinSize(int viewMeasureSpec) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
package com.facebook.react.fabric.mounting.mountitems;

import androidx.annotation.UiThread;
import com.facebook.infer.annotation.Nullsafe;

/**
* This is a common interface for View Command operations. Once we delete the deprecated {@link
* DispatchIntCommandMountItem}, we can delete this interface too. It provides a set of common
* operations to simplify generic operations on all types of ViewCommands.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public abstract class DispatchCommandMountItem implements MountItem {
private int mNumRetries = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.fabric.mounting.MountingManager;

@Nullsafe(Nullsafe.Mode.LOCAL)
final class DispatchIntCommandMountItem extends DispatchCommandMountItem {

private final int mSurfaceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.fabric.mounting.MountingManager;

@Nullsafe(Nullsafe.Mode.LOCAL)
final class DispatchStringCommandMountItem extends DispatchCommandMountItem {

private final int mSurfaceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.fabric.mounting.mountitems;

import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -17,6 +18,7 @@
* <p>TODO T97384889: remove this class when the component names are unified between JS - Android -
* iOS - C++
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
class FabricNameComponentMapping {

private static @NonNull final Map<String, String> sComponentNames = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.fabric.events.EventEmitterWrapper;
import com.facebook.react.uimanager.StateWrapper;

/** Factory class that expose creation of {@link MountItem} */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class MountItemFactory {

/** @return a {@link DispatchCommandMountItem} for commands identified by an int */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.fabric.events.EventEmitterWrapper;
import com.facebook.react.fabric.mounting.MountingManager;
import com.facebook.react.fabric.mounting.SurfaceMountingManager;
import com.facebook.react.uimanager.StateWrapper;

/** {@link MountItem} that is used to pre-allocate views for JS components. */
@Nullsafe(Nullsafe.Mode.LOCAL)
final class PreAllocateViewMountItem implements MountItem {

private final @NonNull String mComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
package com.facebook.react.fabric.mounting.mountitems;

import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
import com.facebook.react.bridge.RetryableMountingLayerException;
import com.facebook.react.fabric.mounting.MountingManager;

@Nullsafe(Nullsafe.Mode.LOCAL)
class SendAccessibilityEvent implements MountItem {

private final String TAG = "Fabric.SendAccessibilityEvent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
package com.facebook.react.fabric.mounting.mountitems;

import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
import com.facebook.react.bridge.RetryableMountingLayerException;
import com.facebook.react.fabric.mounting.MountingManager;

@Nullsafe(Nullsafe.Mode.LOCAL)
final class SendAccessibilityEventMountItem implements MountItem {

private final String TAG = "Fabric.SendAccessibilityEvent";
Expand Down

0 comments on commit 4e6eba7

Please sign in to comment.