Skip to content

Commit

Permalink
Migrate google java format from 1.7 -> 1.19.2
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/hhvm#9431

X-link: WhatsApp/eqwalizer#52

X-link: facebookincubator/spectrum#1858

X-link: fbsamples/metapay#1

X-link: facebookincubator/fbjni#95

X-link: facebookincubator/Battery-Metrics#30

X-link: facebook/ktfmt#440

X-link: facebook/flipper#5456

X-link: facebook/hermes#1290

X-link: facebook/TextLayoutBuilder#35

X-link: facebook/SoLoader#122

This diff migrates google java format form 1.7 to 1.19.2. This update will allow for new language features from java 17 and 21. This diff also formats all necessary files.

 Changelog:
    [Internal][Changed] - Updated format from google-java-format 1.7 -> 1.19.2

Reviewed By: IanChilds

Differential Revision: D52786052

fbshipit-source-id: 628739a74c7c2ce0ca6016c00c10a79a011c5d6f
  • Loading branch information
j-bahr authored and facebook-github-bot committed Jan 31, 2024
1 parent 25c5d1c commit a08b63f
Show file tree
Hide file tree
Showing 90 changed files with 431 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

@Deprecated(
since =
"CompositeReactPackageTurboModuleManagerDelegate is deprecated and will be deleted in the future. Please use ReactPackage interface or BaseReactPackage instead.")
"CompositeReactPackageTurboModuleManagerDelegate is deprecated and will be deleted in the"
+ " future. Please use ReactPackage interface or BaseReactPackage instead.")
@DoNotStrip
public class CompositeReactPackageTurboModuleManagerDelegate
extends ReactPackageTurboModuleManagerDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ private static void appendMap(
map.put(name, ModuleSpec.viewManagerSpec(provider));
}

/** @return a map of view managers that should be registered with {@link UIManagerModule} */
/**
* @return a map of view managers that should be registered with {@link UIManagerModule}
*/
private Map<String, ModuleSpec> getViewManagersMap() {
if (mViewManagers == null) {
Map<String, ModuleSpec> viewManagers = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public final List<NativeModule> createNativeModules(ReactApplicationContext reac
}
return modules;
}

/**
* @param reactContext react application context that can be used to create View Managers.
* @return list of module specs that can create the View Managers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ public void processPackage(ReactPackage reactPackage) {
+ name
+ " tried to override "
+ existingNativeModule.getClassName()
+ ". Check the getPackages() method in MainApplication.java, it might be that module is being created twice. If this was your intention, set canOverrideExistingModule=true. "
+ "This error may also be present if the package is present only once in getPackages() but is also automatically added later during build time by autolinking. Try removing the existing entry and rebuild.");
+ ". Check the getPackages() method in MainApplication.java, it might be that"
+ " module is being created twice. If this was your intention, set"
+ " canOverrideExistingModule=true. This error may also be present if the package"
+ " is present only once in getPackages() but is also automatically added later"
+ " during build time by autolinking. Try removing the existing entry and"
+ " rebuild.");
}
mModules.remove(existingNativeModule);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public void onDestroy() {
super.onDestroy();
mReactDelegate.onHostDestroy();
}

// endregion

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,9 @@ public void removeReactInstanceEventListener(
mReactInstanceEventListeners.remove(listener);
}

/** @return current ReactApplicationContext */
/**
* @return current ReactApplicationContext
*/
@VisibleForTesting
public @Nullable ReactContext getCurrentReactContext() {
synchronized (mReactContextLock) {
Expand Down Expand Up @@ -1333,7 +1335,9 @@ private void tearDownReactContext(ReactContext reactContext) {
mDevSupportManager.onReactInstanceDestroyed(reactContext);
}

/** @return instance of {@link ReactContext} configured a {@link CatalystInstance} set */
/**
* @return instance of {@link ReactContext} configured a {@link CatalystInstance} set
*/
private ReactApplicationContext createReactContext(
JavaScriptExecutor jsExecutor, JSBundleLoader jsBundleLoader) {
FLog.d(ReactConstants.TAG, "ReactInstanceManager.createReactContext()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
*/
@DeprecatedInNewArchitecture(
message =
"This class will be replaced by com.facebook.react.ReactHost in the new architecture of React Native.")
"This class will be replaced by com.facebook.react.ReactHost in the new architecture of"
+ " React Native.")
public abstract class ReactNativeHost {

private final Application mApplication;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public interface ReactPackage {
@DeprecatedInNewArchitecture
List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext);

/** @return a list of view managers that should be registered with {@link UIManagerModule} */
/**
* @return a list of view managers that should be registered with {@link UIManagerModule}
*/
@NonNull
List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ public TurboModule getModule(String moduleName) {
FLog.e(
ReactConstants.TAG,
ex,
"Caught exception while constructing module '%s'. This was previously ignored but will not be caught in the future.",
"Caught exception while constructing module '%s'. This was previously ignored but will"
+ " not be caught in the future.",
moduleName);
}
}
Expand Down Expand Up @@ -243,7 +244,8 @@ public NativeModule getLegacyModule(String moduleName) {
FLog.e(
ReactConstants.TAG,
ex,
"Caught exception while constructing module '%s'. This was previously ignored but will not be caught in the future.",
"Caught exception while constructing module '%s'. This was previously ignored but will"
+ " not be caught in the future.",
moduleName);
}
}
Expand Down Expand Up @@ -294,10 +296,12 @@ protected abstract ReactPackageTurboModuleManagerDelegate build(
public ReactPackageTurboModuleManagerDelegate build() {
Assertions.assertNotNull(
mContext,
"The ReactApplicationContext must be provided to create ReactPackageTurboModuleManagerDelegate");
"The ReactApplicationContext must be provided to create"
+ " ReactPackageTurboModuleManagerDelegate");
Assertions.assertNotNull(
mPackages,
"A set of ReactPackages must be provided to create ReactPackageTurboModuleManagerDelegate");
"A set of ReactPackages must be provided to create"
+ " ReactPackageTurboModuleManagerDelegate");
return build(mContext, mPackages);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ public void requestChildFocus(View child, View focused) {
if (!hasActiveReactContext() || !isViewAttachedToReactInstance()) {
FLog.w(
TAG,
"Unable to handle child focus changed event as the catalyst instance has not been attached");
"Unable to handle child focus changed event as the catalyst instance has not been"
+ " attached");
super.requestChildFocus(child, focused);
return;
}
Expand Down Expand Up @@ -420,8 +421,9 @@ public void run() {
ReactSoftExceptionLogger.logSoftException(
TAG,
new ReactNoCrashSoftException(
"A view was illegally added as a child of a ReactRootView. "
+ "This View should not be a direct child of a ReactRootView, because it is not visible and will never be reachable. Child: "
"A view was illegally added as a child of a ReactRootView. This View should"
+ " not be a direct child of a ReactRootView, because it is not visible"
+ " and will never be reachable. Child: "
+ child.getClass().getCanonicalName().toString()
+ " child ID: "
+ child.getId()));
Expand Down Expand Up @@ -758,11 +760,11 @@ protected void finalize() throws Throwable {
super.finalize();
Assertions.assertCondition(
!mIsAttachedToInstance,
"The application this ReactRootView was rendering was not unmounted before the "
+ "ReactRootView was garbage collected. This usually means that your application is "
+ "leaking large amounts of memory. To solve this, make sure to call "
+ "ReactRootView#unmountReactApplication in the onDestroy() of your hosting Activity or in "
+ "the onDestroyView() of your hosting Fragment.");
"The application this ReactRootView was rendering was not unmounted before the"
+ " ReactRootView was garbage collected. This usually means that your application is"
+ " leaking large amounts of memory. To solve this, make sure to call"
+ " ReactRootView#unmountReactApplication in the onDestroy() of your hosting Activity"
+ " or in the onDestroyView() of your hosting Fragment.");
}

public int getRootViewTag() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public interface ViewManagerOnDemandReactPackage {
* Typically, this is ViewManager.getName().
*/
Collection<String> getViewManagerNames(ReactApplicationContext reactContext);

/**
* Creates and returns a ViewManager with a specific name {@param viewManagerName}. It's up to an
* implementing package how to interpret the name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ private void initializeLifecycleEventListenersForViewTag(final int viewTag) {
ReactSoftExceptionLogger.logSoftException(
NAME,
new RuntimeException(
"initializeLifecycleEventListenersForViewTag could not get NativeAnimatedNodesManager"));
"initializeLifecycleEventListenersForViewTag could not get"
+ " NativeAnimatedNodesManager"));
}

// Subscribe to UIManager (Fabric or non-Fabric) lifecycle events if we haven't yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ public void connectAnimatedNodeToView(int animatedNodeTag, int viewTag) {
}
if (mReactApplicationContext == null) {
throw new IllegalStateException(
"connectAnimatedNodeToView: Animated node could not be connected, no ReactApplicationContext: "
"connectAnimatedNodeToView: Animated node could not be connected, no"
+ " ReactApplicationContext: "
+ viewTag);
}

Expand All @@ -438,7 +439,8 @@ public void connectAnimatedNodeToView(int animatedNodeTag, int viewTag) {
ReactSoftExceptionLogger.logSoftException(
TAG,
new ReactNoCrashSoftException(
"connectAnimatedNodeToView: Animated node could not be connected to UIManager - uiManager disappeared for tag: "
"connectAnimatedNodeToView: Animated node could not be connected to UIManager -"
+ " uiManager disappeared for tag: "
+ viewTag));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
/** An empty implementation of {@link ActivityEventListener} */
public class BaseActivityEventListener implements ActivityEventListener {

/** @deprecated use {@link #onActivityResult(Activity, int, int, Intent)} instead. */
/**
* @deprecated use {@link #onActivityResult(Activity, int, int, Intent)} instead.
*/
@Deprecated
public void onActivityResult(int requestCode, int resultCode, Intent data) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public BaseJavaModule(@Nullable ReactApplicationContext reactContext) {
mReactApplicationContext = reactContext;
}

/** @return a map of constants this module exports to JS. Supports JSON types. */
/**
* @return a map of constants this module exports to JS. Supports JSON types.
*/
@DeprecatedInNewArchitecture()
public @Nullable Map<String, Object> getConstants() {
return null;
Expand Down Expand Up @@ -94,7 +96,8 @@ public void invalidate() {}
protected final ReactApplicationContext getReactApplicationContext() {
return Assertions.assertNotNull(
mReactApplicationContext,
"Tried to get ReactApplicationContext even though NativeModule wasn't instantiated with one");
"Tried to get ReactApplicationContext even though NativeModule wasn't instantiated with"
+ " one");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public interface CatalystInstance

@DoNotStrip
void callFunction(String module, String method, NativeArray arguments);

/**
* Destroys this catalyst instance, waiting for any other threads in ReactQueueConfiguration
* (besides the UI thread) to finish running. Must be called from the UI thread so that we can
Expand Down Expand Up @@ -73,7 +74,9 @@ public interface CatalystInstance

@Deprecated(
since =
"getJSIModule(JSIModuleType moduleType) is deprecated and will be deleted in the future. Please use ReactInstanceEventListener to subscribe for react instance events instead.")
"getJSIModule(JSIModuleType moduleType) is deprecated and will be deleted in the future."
+ " Please use ReactInstanceEventListener to subscribe for react instance events"
+ " instead.")
JSIModule getJSIModule(JSIModuleType moduleType);

Collection<NativeModule> getNativeModules();
Expand Down Expand Up @@ -136,21 +139,26 @@ public interface CatalystInstance

@Deprecated(
since =
"setTurboModuleManager(JSIModule getter) is deprecated and will be deleted in the future. Please use setTurboModuleRegistry(TurboModuleRegistry turboModuleRegistry)instead.")
"setTurboModuleManager(JSIModule getter) is deprecated and will be deleted in the future."
+ " Please use setTurboModuleRegistry(TurboModuleRegistry"
+ " turboModuleRegistry)instead.")
void setTurboModuleManager(JSIModule getter);

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
"This method will be deprecated later as part of Stable APIs with bridge removal and not"
+ " encouraged usage.")
void setTurboModuleRegistry(TurboModuleRegistry turboModuleRegistry);

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
"This method will be deprecated later as part of Stable APIs with bridge removal and not"
+ " encouraged usage.")
void setFabricUIManager(UIManager fabricUIManager);

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
"This method will be deprecated later as part of Stable APIs with bridge removal and not"
+ " encouraged usage.")
UIManager getFabricUIManager();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public final class FallbackJSBundleLoader extends JSBundleLoader {
// Reasons why we fell-back on previous loaders, in order of occurrence.
private final ArrayList<Exception> mRecoveredErrors = new ArrayList<>();

/** @param loaders Loaders for the sources to try, in descending order of preference. */
/**
* @param loaders Loaders for the sources to try, in descending order of preference.
*/
public FallbackJSBundleLoader(List<JSBundleLoader> loaders) {
mLoaders = new Stack<>();
ListIterator<JSBundleLoader> it = loaders.listIterator(loaders.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
/** Interface used to initialize JSI Modules into the JSI Bridge. */
public interface JSIModulePackage {

/** @return a {@link List< JSIModuleSpec >} that contain the list of JSI Modules. */
/**
* @return a {@link List< JSIModuleSpec >} that contain the list of JSI Modules.
*/
List<JSIModuleSpec> getJSIModules(
ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext);
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public static JavaOnlyMap deepClone(ReadableMap map) {
return res;
}

/** @param keysAndValues keys and values, interleaved */
/**
* @param keysAndValues keys and values, interleaved
*/
private JavaOnlyMap(Object... keysAndValues) {
if (keysAndValues.length % 2 != 0) {
throw new IllegalArgumentException("You must provide the same number of keys and values");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public static ModuleSpec nativeModuleSpec(
TAG,
"Could not find @ReactModule annotation on "
+ type.getName()
+ ". So creating the module eagerly to get the name. Consider adding an annotation to make this Lazy");
+ ". So creating the module eagerly to get the name. Consider adding an annotation to"
+ " make this Lazy");
NativeModule nativeModule = provider.get();
return new ModuleSpec(provider, nativeModule.getName());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ public Collection<NativeModule> getNativeModules() {
return mCatalystInstance.getNativeModules();
}

/** @return the instance of the specified module interface associated with this ReactContext. */
/**
* @return the instance of the specified module interface associated with this ReactContext.
*/
@Nullable
public <T extends NativeModule> T getNativeModule(Class<T> nativeModuleInterface) {
if (mCatalystInstance == null) {
Expand Down Expand Up @@ -236,7 +238,9 @@ public boolean hasActiveCatalystInstance() {
return hasActiveReactInstance();
}

/** @return true if there is an non-null, alive react native instance */
/**
* @return true if there is an non-null, alive react native instance
*/
public boolean hasActiveReactInstance() {
return mCatalystInstance != null && !mCatalystInstance.isDestroyed();
}
Expand Down Expand Up @@ -417,7 +421,8 @@ public void assertOnNativeModulesQueueThread(String message) {
/** TODO(T85807990): Fail fast if the ReactContext isn't initialized */
if (!mIsInitialized) {
throw new IllegalStateException(
"Tried to call assertOnNativeModulesQueueThread(message) on an uninitialized ReactContext");
"Tried to call assertOnNativeModulesQueueThread(message) on an uninitialized"
+ " ReactContext");
}
Assertions.assertNotNull(mNativeModulesMessageQueueThread).assertIsOnThread(message);
}
Expand Down Expand Up @@ -528,7 +533,9 @@ public boolean startActivityForResult(Intent intent, int code, Bundle bundle) {
return mCurrentActivity.get();
}

/** @deprecated DO NOT USE, this method will be removed in the near future. */
/**
* @deprecated DO NOT USE, this method will be removed in the near future.
*/
@Deprecated
public boolean isBridgeless() {
return false;
Expand All @@ -549,7 +556,8 @@ public boolean isBridgeless() {

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
"This method will be deprecated later as part of Stable APIs with bridge removal and not"
+ " encouraged usage.")
/**
* Get the UIManager for Fabric from the CatalystInstance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/
@DeprecatedInNewArchitecture(
message =
"ReactContextBaseJavaModule will be deprecated in new Architecture of React Native, use BaseJavaModule instead")
"ReactContextBaseJavaModule will be deprecated in new Architecture of React Native, use"
+ " BaseJavaModule instead")
public abstract class ReactContextBaseJavaModule extends BaseJavaModule {

public ReactContextBaseJavaModule() {
Expand Down
Loading

0 comments on commit a08b63f

Please sign in to comment.