Skip to content

Commit 0e03c02

Browse files
Fabio Carballofacebook-github-bot
authored andcommitted
Remove debug specific configurations from ComponentsConfiguration
Summary: ## Important This is a "copy" of D52563388, which was reverted due to three classes that were still referring to the old configurations and somehow Sandcastle missed. I'm updating those references on top of this copy. ## Original Description This diff removes debug specific configurations from `ComponentsConfiguration` in Litho into a new abstraction named `LithoDebugConfigurations`. The goal is that we move further into having `ComponentsConfiguration` to be more focused in internals/behaviors of Litho. Reviewed By: adityasharat Differential Revision: D52779201 fbshipit-source-id: 8f540efbe2691f7b8c22d1b199a14ff02f986c9c
1 parent 8fe6f93 commit 0e03c02

File tree

51 files changed

+201
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+201
-143
lines changed

litho-core/src/main/java/com/facebook/litho/Component.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import com.facebook.infer.annotation.ThreadSafe;
5959
import com.facebook.litho.annotations.EventHandlerRebindMode;
6060
import com.facebook.litho.config.ComponentsConfiguration;
61+
import com.facebook.litho.config.LithoDebugConfigurations;
6162
import com.facebook.litho.drawable.ComparableColorDrawable;
6263
import com.facebook.litho.drawable.ComparableDrawable;
6364
import com.facebook.rendercore.Equivalence;
@@ -2304,7 +2305,7 @@ static LinkedList<String> generateHierarchy(String globalKey) {
23042305
*/
23052306
@Nullable
23062307
private final AttributesHolder mDebugAttributesHolder =
2307-
ComponentsConfiguration.isDebugModeEnabled ? new AttributesHolder() : null;
2308+
LithoDebugConfigurations.isDebugModeEnabled ? new AttributesHolder() : null;
23082309

23092310
@Override
23102311
public <T> void setDebugAttributeKey(AttributeKey<T> attributeKey, T value) {

litho-core/src/main/java/com/facebook/litho/ComponentContextUtils.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.facebook.litho
1818

1919
import android.content.Context
2020
import com.facebook.litho.config.ComponentsConfiguration
21+
import com.facebook.litho.config.LithoDebugConfigurations
2122
import com.facebook.rendercore.visibility.VisibilityBoundsTransformer
2223

2324
object ComponentContextUtils {
@@ -37,7 +38,7 @@ object ComponentContextUtils {
3738
componentsConfig = ComponentsConfiguration.defaultInstance,
3839
areTransitionsEnabled = AnimationsDebug.areTransitionsEnabled(context),
3940
isVisibilityProcessingEnabled = true,
40-
incrementalMountEnabled = !ComponentsConfiguration.isIncrementalMountGloballyDisabled,
41+
incrementalMountEnabled = !LithoDebugConfigurations.isIncrementalMountGloballyDisabled,
4142
errorEventHandler = DefaultErrorEventHandler.INSTANCE,
4243
logTag = logTagToUse,
4344
logger = loggerToUse,

litho-core/src/main/java/com/facebook/litho/ComponentTree.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import com.facebook.infer.annotation.ThreadSafe;
7575
import com.facebook.litho.LithoLifecycleProvider.LithoLifecycle;
7676
import com.facebook.litho.config.ComponentsConfiguration;
77+
import com.facebook.litho.config.LithoDebugConfigurations;
7778
import com.facebook.litho.debug.AttributionUtils;
7879
import com.facebook.litho.debug.DebugOverlay;
7980
import com.facebook.litho.debug.LithoDebugEvent;
@@ -521,7 +522,7 @@ protected ComponentTree(Builder builder) {
521522
null,
522523
builder.parentTreeProps);
523524

524-
if (ComponentsConfiguration.isTimelineEnabled) {
525+
if (LithoDebugConfigurations.isTimelineEnabled) {
525526
mTimeMachine = new DebugComponentTreeTimeMachine(this);
526527
} else {
527528
mTimeMachine = null;
@@ -559,7 +560,7 @@ protected ComponentTree(Builder builder) {
559560
}
560561

561562
private static boolean incrementalMountGloballyDisabled() {
562-
return ComponentsConfiguration.isIncrementalMountGloballyDisabled;
563+
return LithoDebugConfigurations.isIncrementalMountGloballyDisabled;
563564
}
564565

565566
/**

litho-core/src/main/java/com/facebook/litho/DebugDraw.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import android.graphics.Paint
2222
import android.graphics.Rect
2323
import android.graphics.drawable.Drawable
2424
import android.view.View
25-
import com.facebook.litho.config.ComponentsConfiguration
25+
import com.facebook.litho.config.LithoDebugConfigurations
2626

2727
/** Draw operations used in developer options. */
2828
internal object DebugDraw {
@@ -56,10 +56,10 @@ internal object DebugDraw {
5656

5757
@JvmStatic
5858
fun draw(host: ComponentHost, canvas: Canvas) {
59-
if (ComponentsConfiguration.debugHighlightInteractiveBounds) {
59+
if (LithoDebugConfigurations.debugHighlightInteractiveBounds) {
6060
highlightInteractiveBounds(host, canvas)
6161
}
62-
if (ComponentsConfiguration.debugHighlightMountBounds) {
62+
if (LithoDebugConfigurations.debugHighlightMountBounds) {
6363
highlightMountBounds(host, canvas)
6464
}
6565
}

litho-core/src/main/java/com/facebook/litho/DefaultComponentsReporter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.facebook.litho
1818

1919
import android.util.Log
20-
import com.facebook.litho.config.ComponentsConfiguration
20+
import com.facebook.litho.config.LithoDebugConfigurations
2121
import com.facebook.rendercore.ErrorReporterDelegate
2222
import com.facebook.rendercore.LogLevel
2323
import java.lang.RuntimeException
@@ -59,7 +59,7 @@ open class DefaultComponentsReporter : ErrorReporterDelegate {
5959
}
6060

6161
private fun applyOnInternalBuild(block: () -> Unit) {
62-
if (ComponentsConfiguration.IS_INTERNAL_BUILD) {
62+
if (LithoDebugConfigurations.isDebugModeEnabled) {
6363
block()
6464
}
6565
}

litho-core/src/main/java/com/facebook/litho/DefaultComponentsSystrace.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.facebook.litho
1818

1919
import android.os.Build
2020
import android.os.Trace
21-
import com.facebook.litho.config.ComponentsConfiguration
21+
import com.facebook.litho.config.LithoDebugConfigurations
2222
import com.facebook.rendercore.RenderCoreSystrace
2323
import com.facebook.rendercore.Systracer
2424
import com.facebook.rendercore.Systracer.ArgsBuilder
@@ -57,7 +57,7 @@ open class DefaultComponentsSystrace : Systracer {
5757
}
5858

5959
override fun isTracing(): Boolean =
60-
ComponentsConfiguration.IS_INTERNAL_BUILD &&
60+
LithoDebugConfigurations.isDebugModeEnabled &&
6161
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 &&
6262
(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || Trace.isEnabled())
6363

litho-core/src/main/java/com/facebook/litho/LayoutState.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.facebook.litho.EndToEndTestingExtension.EndToEndTestingExtensionInput;
3434
import com.facebook.litho.LithoViewAttributesExtension.ViewAttributesInput;
3535
import com.facebook.litho.config.ComponentsConfiguration;
36+
import com.facebook.litho.config.LithoDebugConfigurations;
3637
import com.facebook.rendercore.LayoutCache;
3738
import com.facebook.rendercore.LayoutResult;
3839
import com.facebook.rendercore.MountItemsPool;
@@ -679,7 +680,8 @@ public TransitionId getRootTransitionId() {
679680

680681
/** Debug-only: return a string representation of this LayoutState and its LayoutOutputs. */
681682
String dumpAsString() {
682-
if (!ComponentsConfiguration.isDebugModeEnabled && !ComponentsConfiguration.isEndToEndTestRun) {
683+
if (!LithoDebugConfigurations.isDebugModeEnabled
684+
&& !ComponentsConfiguration.isEndToEndTestRun) {
683685
throw new RuntimeException(
684686
"LayoutState#dumpAsString() should only be called in debug mode or from e2e tests!");
685687
}

litho-core/src/main/java/com/facebook/litho/LithoNode.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import com.facebook.infer.annotation.ThreadConfined
3737
import com.facebook.litho.CommonProps.DefaultLayoutProps
3838
import com.facebook.litho.Transition.TransitionKeyType
3939
import com.facebook.litho.annotations.ImportantForAccessibility
40-
import com.facebook.litho.config.ComponentsConfiguration
40+
import com.facebook.litho.config.LithoDebugConfigurations
4141
import com.facebook.litho.drawable.ComparableColorDrawable
4242
import com.facebook.rendercore.LayoutCache
4343
import com.facebook.rendercore.LayoutContext
@@ -103,7 +103,7 @@ open class LithoNode : Node<LithoLayoutContext>, Cloneable {
103103

104104
val debugLayoutEditor: LayoutProps?
105105
get() {
106-
if (ComponentsConfiguration.isDebugModeEnabled && debugLayoutProps == null) {
106+
if (LithoDebugConfigurations.isDebugModeEnabled && debugLayoutProps == null) {
107107
debugLayoutProps = DefaultLayoutProps()
108108
}
109109
return debugLayoutProps
@@ -1470,7 +1470,7 @@ open class LithoNode : Node<LithoLayoutContext>, Cloneable {
14701470
}
14711471

14721472
private fun applyOverridesRecursive(node: LithoNode) {
1473-
if (ComponentsConfiguration.isDebugModeEnabled) {
1473+
if (LithoDebugConfigurations.isDebugModeEnabled) {
14741474
DebugComponent.applyOverrides(node.tailComponentContext, node)
14751475
for (i in 0 until node.childCount) {
14761476
applyOverridesRecursive(node.getChildAt(i))

litho-core/src/main/java/com/facebook/litho/LithoNodeUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import androidx.core.view.ViewCompat
2424
import com.facebook.litho.Component.MountType
2525
import com.facebook.litho.MountSpecLithoRenderUnit.UpdateState
2626
import com.facebook.litho.annotations.ImportantForAccessibility
27-
import com.facebook.litho.config.ComponentsConfiguration
27+
import com.facebook.litho.config.LithoDebugConfigurations
2828
import com.facebook.litho.drawable.BorderColorDrawable
2929
import com.facebook.rendercore.LayoutResult
3030
import com.facebook.rendercore.MountState
@@ -397,7 +397,7 @@ object LithoNodeUtils {
397397

398398
@JvmStatic
399399
fun getDebugKey(componentKey: String?, @OutputUnitType outputUnitType: Int): String? =
400-
if (ComponentsConfiguration.isDebugModeEnabled) {
400+
if (LithoDebugConfigurations.isDebugModeEnabled) {
401401
null
402402
} else {
403403
when (outputUnitType) {

litho-core/src/main/java/com/facebook/litho/LithoReducer.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import android.graphics.Rect
2020
import androidx.collection.LongSparseArray
2121
import androidx.core.view.ViewCompat
2222
import com.facebook.litho.config.ComponentsConfiguration
23+
import com.facebook.litho.config.LithoDebugConfigurations
2324
import com.facebook.rendercore.LayoutResult
2425
import com.facebook.rendercore.MountState
2526
import com.facebook.rendercore.RenderTreeNode
@@ -130,7 +131,7 @@ object LithoReducer {
130131
layoutState.mLayoutResult = null
131132

132133
// enabled for debugging and end to end tests
133-
if (ComponentsConfiguration.isDebugModeEnabled || ComponentsConfiguration.isEndToEndTestRun) {
134+
if (LithoDebugConfigurations.isDebugModeEnabled || ComponentsConfiguration.isEndToEndTestRun) {
134135
layoutState.mRoot = nodeForSaving
135136
layoutState.mLayoutResult = layoutResultForSaving
136137
return
@@ -902,7 +903,7 @@ object LithoReducer {
902903
private fun LithoNode.getDebugHierarchy(
903904
parentHierarchy: DebugHierarchy.Node? = null,
904905
): DebugHierarchy.Node? {
905-
if (!ComponentsConfiguration.isDebugHierarchyEnabled) {
906+
if (!LithoDebugConfigurations.isDebugHierarchyEnabled) {
906907
return null
907908
}
908909
val infos: List<ScopedComponentInfo> = scopedComponentInfos

0 commit comments

Comments
 (0)