Trait/Object

com.tersesystems.blindsight.inspection

InspectionMacros

Related Docs: object InspectionMacros | package inspection

Permalink

trait InspectionMacros extends AnyRef

Macros used for close inspection and debugging values.

Easiest way to use these is to pay the import tax up front, or incorporate them into an Inspections trait.

import com.tersesystems.blindsight.inspection._
import com.tersesystems.blindsight.inspection.InspectionMacros._

These macros are intended to be used in situations where you would use "printf debugging" to get a read on individual values and branches.

The macros here have not been rigorously tested and should be considered experimental.

Source
InspectionMacros.scala
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. InspectionMacros
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from InspectionMacros to any2stringadd[InspectionMacros] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (InspectionMacros, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from InspectionMacros to ArrowAssoc[InspectionMacros] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @throws( ... )
  8. macro def decorateIfs[A](output: (BranchInspection) ⇒ Unit)(ifStatement: A): A

    Permalink

    Decorates the given if statement with logging statements.

    Decorates the given if statement with logging statements.

    For example, the following code:

    decorateIfs(dif: BranchInspection => logger.debug(s"${dif.code} = ${dif.result}")) {
      if (System.currentTimeMillis() % 17 == 0) {
        println("branch 1")
      } else if (System.getProperty("derp") == null) {
        println("branch 2")
      } else {
        println("else branch")
      }
    }

    would cause the logger to debug two lines:

    "System.currentTimeMillis() % 17 == 0 = false" "System.getProperty("derp") == null = true"

    A

    the result type

    output

    the logging statement to apply on each branch.

    ifStatement

    the if statement to decorate with statements

    returns

    the result of the if statement.

  9. macro def decorateMatch[A](output: (BranchInspection) ⇒ Unit)(matchStatement: A): A

    Permalink

    Decorates a match statement with logging statements at each case.

    Decorates a match statement with logging statements at each case.

    For example, given the following code:

    val string = java.time.Instant.now().toString
    decorateMatch(dm: BranchInspection => logger.debug(s"${dm.code} = ${dm.result}")) {
      string match {
        case s if s.startsWith("20") =>
          println("this example is still valid")
        case _ =>
          println("oh dear")
      }
    }

    This will log the following at DEBUG level:

    "string match case s if s.startsWith("20") = true"

    A

    the result type

    output

    the logging statement to apply to each case

    matchStatement

    the match statement to decorate with statements

  10. macro def decorateVals[A](output: (ValDefInspection) ⇒ Unit)(block: A): A

    Permalink

    Decorates a given block with logging statements after each val or var (technically a ValDef).

    Decorates a given block with logging statements after each val or var (technically a ValDef).

    For example, given the following statement:

    decorateVals(dval: ValDefInspection => logger.debug(s"${dval.name} = ${dval.value}")) {
      val a = 5
      val b = 15
      a + b
    }

    There would be two statements logged at DEBUG level:

    "a = 5" "b = 15"

    A

    the result type

    output

    the logging statement to put after each ValDef

    block

    the block to decorate with logging statements.

    returns

    the result, if any

  11. macro def dumpExpression[A](block: A): ExprInspection[A]

    Permalink

    Creates a DebugResult containing the code and result of a block / expression.

    Creates a DebugResult containing the code and result of a block / expression.

    For example, the following statement:

    val dr: ExprInspection[Int] = dumpExpression(1 + 1)
    logger.debug(s"result: ${dr.code} = ${dr.value}")

    would result in "result: 1 + 1 = 2"

    A

    the result type

    block

    the block or expression

    returns

    a debug result containing the code and value.

  12. macro def dumpPublicFields[A](instance: A): Seq[ValDefInspection]

    Permalink

    Dumps public fields from an object.

    Dumps public fields from an object.

    class ExampleClass(val someInt: Int) {
      protected val protectedInt = 22
    }
    val exObj        = new ExampleClass(42)
    val publicFields: Seq[ValDefInspection] = dumpPublicFields(exObj)
    
    logger.debug(publicFields.toString)

    Should result in:

    "Seq(DebugVal(someInt,42))"

    A

    the type of the object

    instance

    the object instance

    returns

    the DebugVal representing the public fields of the object.

  13. def ensuring(cond: (InspectionMacros) ⇒ Boolean, msg: ⇒ Any): InspectionMacros

    Permalink
    Implicit information
    This member is added by an implicit conversion from InspectionMacros to Ensuring[InspectionMacros] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: (InspectionMacros) ⇒ Boolean): InspectionMacros

    Permalink
    Implicit information
    This member is added by an implicit conversion from InspectionMacros to Ensuring[InspectionMacros] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean, msg: ⇒ Any): InspectionMacros

    Permalink
    Implicit information
    This member is added by an implicit conversion from InspectionMacros to Ensuring[InspectionMacros] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean): InspectionMacros

    Permalink
    Implicit information
    This member is added by an implicit conversion from InspectionMacros to Ensuring[InspectionMacros] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  19. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from InspectionMacros to StringFormat[InspectionMacros] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  20. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  21. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  22. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  23. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  24. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  25. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  27. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  28. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. def [B](y: B): (InspectionMacros, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from InspectionMacros to ArrowAssoc[InspectionMacros] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Deprecated Value Members

  1. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from InspectionMacros to any2stringadd[InspectionMacros]

Inherited by implicit conversion StringFormat from InspectionMacros to StringFormat[InspectionMacros]

Inherited by implicit conversion Ensuring from InspectionMacros to Ensuring[InspectionMacros]

Inherited by implicit conversion ArrowAssoc from InspectionMacros to ArrowAssoc[InspectionMacros]

Ungrouped