Convert debug/holder module (#43747)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43747

Convert module to Kotlin.
changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D55598977

fbshipit-source-id: d289e230bae721de6d7d209663fcdc35ec37fbac
This commit is contained in:
Thomas Nardone
2024-04-03 16:15:45 -07:00
committed by Facebook GitHub Bot
parent 1139700424
commit 7a458025ca
6 changed files with 54 additions and 80 deletions
@@ -1,31 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.debug.holder;
import com.facebook.debug.debugoverlay.model.DebugOverlayTag;
import com.facebook.infer.annotation.Nullsafe;
/** No-op implementation of {@link Printer}. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class NoopPrinter implements Printer {
public static final NoopPrinter INSTANCE = new NoopPrinter();
private NoopPrinter() {}
@Override
public void logMessage(DebugOverlayTag tag, String message, Object... args) {}
@Override
public void logMessage(DebugOverlayTag tag, String message) {}
@Override
public boolean shouldDisplayLogMessage(final DebugOverlayTag tag) {
return false;
}
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.debug.holder
import com.facebook.debug.debugoverlay.model.DebugOverlayTag
/** No-op implementation of [Printer]. */
public object NoopPrinter : Printer {
public override fun logMessage(tag: DebugOverlayTag, message: String, vararg args: Any?): Unit =
Unit
public override fun logMessage(tag: DebugOverlayTag, message: String): Unit = Unit
public override fun shouldDisplayLogMessage(tag: DebugOverlayTag): Boolean = false
}
@@ -1,20 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.debug.holder;
import com.facebook.debug.debugoverlay.model.DebugOverlayTag;
/** Interface to debugging tool. */
public interface Printer {
void logMessage(final DebugOverlayTag tag, final String message, Object... args);
void logMessage(final DebugOverlayTag tag, final String message);
boolean shouldDisplayLogMessage(final DebugOverlayTag tag);
}
@@ -0,0 +1,20 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.debug.holder
import com.facebook.debug.debugoverlay.model.DebugOverlayTag
/** Interface to debugging tool. */
public interface Printer {
public fun logMessage(tag: DebugOverlayTag, message: String, vararg args: Any?)
public fun logMessage(tag: DebugOverlayTag, message: String)
public fun shouldDisplayLogMessage(tag: DebugOverlayTag): Boolean
}
@@ -1,29 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.debug.holder;
import com.facebook.infer.annotation.Nullsafe;
/** Holder for debugging tool instance. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class PrinterHolder {
private static Printer sPrinter = NoopPrinter.INSTANCE;
public static void setPrinter(Printer printer) {
if (printer == null) {
sPrinter = NoopPrinter.INSTANCE;
} else {
sPrinter = printer;
}
}
public static Printer getPrinter() {
return sPrinter;
}
}
@@ -0,0 +1,13 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.debug.holder
/** Holder for debugging tool instance. */
public object PrinterHolder {
@JvmStatic public var printer: Printer = NoopPrinter
}