From 1929ebd00ee6a0429ea30c4ee940e57dd443f43b Mon Sep 17 00:00:00 2001 From: Gijs Weterings Date: Wed, 9 Apr 2025 09:07:30 -0700 Subject: [PATCH] fix nullsafe FIXMEs for ReactTextViewManager.java and mark nullsafe Summary: Gone trough all the FIXMEs added in the previous diff by the nullsafe tool, marked the class as nullsafe and ensured no remaining violations. Changelog: [Android][Fixed] Made ReactTextViewManager.java nullsafe Reviewed By: javache Differential Revision: D72460124 fbshipit-source-id: a75705ac4ab486ccaa9162dee5bfd8cae77967c7 --- .../com/facebook/react/views/text/ReactTextViewManager.java | 6 +++--- .../com/facebook/react/views/text/TextLayoutManager.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java index de67c38f129..7d9e51cd45b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java @@ -13,6 +13,7 @@ import android.text.Spannable; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.facebook.common.logging.FLog; +import com.facebook.infer.annotation.Nullsafe; import com.facebook.react.R; import com.facebook.react.common.MapBuilder; import com.facebook.react.common.annotations.VisibleForTesting; @@ -35,6 +36,7 @@ import java.util.Map; * Concrete class for {@link ReactTextAnchorViewManager} which represents view managers of anchor * {@code } nodes. */ +@Nullsafe(Nullsafe.Mode.LOCAL) @ReactModule(name = ReactTextViewManager.REACT_CLASS) public class ReactTextViewManager extends ReactTextAnchorViewManager @@ -143,14 +145,13 @@ public class ReactTextViewManager } @Override - public Object updateState( + public @Nullable Object updateState( ReactTextView view, ReactStylesDiffMap props, StateWrapper stateWrapper) { try (SystraceSection s = new SystraceSection("ReactTextViewManager.updateState")) { MapBuffer stateMapBuffer = stateWrapper.getStateDataMapBuffer(); if (stateMapBuffer != null) { return getReactTextUpdate(view, props, stateMapBuffer); } else { - // NULLSAFE_FIXME[Return Not Nullable] return null; } } @@ -225,7 +226,6 @@ public class ReactTextViewManager widthMode, height, heightMode, - // NULLSAFE_FIXME[Parameter Not Nullable] mReactTextViewManagerCallback, attachmentsPositions); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index 02223810297..aeadd79dfe4 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -502,7 +502,7 @@ public class TextLayoutManager { MapBuffer paragraphAttributes, float width, float height, - ReactTextViewManagerCallback reactTextViewManagerCallback) { + @Nullable ReactTextViewManagerCallback reactTextViewManagerCallback) { Spannable text = getOrCreateSpannableForText(context, attributedString, reactTextViewManagerCallback); @@ -666,7 +666,7 @@ public class TextLayoutManager { YogaMeasureMode widthYogaMeasureMode, float height, YogaMeasureMode heightYogaMeasureMode, - ReactTextViewManagerCallback reactTextViewManagerCallback, + @Nullable ReactTextViewManagerCallback reactTextViewManagerCallback, @Nullable float[] attachmentsPositions) { // TODO(5578671): Handle text direction (see View#getTextDirectionHeuristic) Layout layout =