main

square/leakcanary

Last updated at: 29/12/2023 09:39

ReferencePathNode.kt

TLDR

The provided file defines a sealed class ReferencePathNode and its subclasses. It also includes nested classes and interfaces.

Classes

ReferencePathNode

The ReferencePathNode class is a sealed class that represents a node in a reference path. It is an abstract class that has an objectId property of type Long.

Subclasses:

  • RootNode: A sealed class that represents a root node in the reference path. It inherits from ReferencePathNode and has an additional gcRoot property of type GcRoot. It also overrides the objectId property to return the id of the gcRoot.

    • LibraryLeakRootNode: A class that represents a library leak root node. It inherits from RootNode and has an additional matcher property of type LibraryLeakReferenceMatcher.
    • NormalRootNode: A class that represents a normal root node. It inherits from RootNode.
  • ChildNode: A class that represents a child node in the reference path. It inherits from ReferencePathNode and has an additional parent property of type ReferencePathNode and a lazyDetailsResolver property of type LazyDetails.Resolver.

Note: There are no methods in the provided file.

package shark.internal

import shark.GcRoot
import shark.LibraryLeakReferenceMatcher
import shark.Reference.LazyDetails

sealed class ReferencePathNode {
  abstract val objectId: Long

  sealed class RootNode : ReferencePathNode() {
    abstract val gcRoot: GcRoot
    override val objectId: Long
      get() = gcRoot.id

    class LibraryLeakRootNode(
      override val gcRoot: GcRoot,
      val matcher: LibraryLeakReferenceMatcher
    ) : RootNode()

    class NormalRootNode(
      override val gcRoot: GcRoot
    ) : RootNode()
  }

  class ChildNode(
    override val objectId: Long,
    /**
     * The reference from the parent to this node
     */
    val parent: ReferencePathNode,
    val lazyDetailsResolver: LazyDetails.Resolver,
  ) : ReferencePathNode()
}