PluginOps

io.github.polentino.redacted.helpers.PluginOps$
object PluginOps

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Value members

Concrete methods

def createToStringBody(tree: TypeDef)(using Context): Try[Tree]

Creates the full body of the new toString method. For example, given the following case class

Creates the full body of the new toString method. For example, given the following case class

 case class User(id: UUID, nickname: String, @redacted email: String)

this method will create the AST equivalent of the following string concatenation

   "User(" + this.id + "," + this.nickname + "," + "***" + ")"

Attributes

tree

the tpd.Tree from which we want to derive a customized toString body implementation.

x$2

implicit Context parameter.

Returns:

the tpd.Tree of the customized toString body implementation, wrapped in a Try.

def getTreeTemplate(tree: TypeDef)(using Context): Option[Template]

Does this tree contain a reference to a tpd.Template? If so, return it wrapped into an Option.

Does this tree contain a reference to a tpd.Template? If so, return it wrapped into an Option.

Attributes

tree

the tree from which return its tpd.Template

x$2

implicit Context parameter.

Returns:

the template wrapped in an Option, if it does exist, or None if not.

def patchToString(template: Template, newToStringBody: Tree)(using Context): Try[Template]

Given the original tpd.Template that represents a case class, and a tpd.Tree that contains the new body implementation of the toString method, this utility function will search for the existing toString method defined in the template, and replace the default one (provided by the Scala compiler) with the one passed as second parameter.

Given the original tpd.Template that represents a case class, and a tpd.Tree that contains the new body implementation of the toString method, this utility function will search for the existing toString method defined in the template, and replace the default one (provided by the Scala compiler) with the one passed as second parameter.

Attributes

newToStringBody

the new implementation of the toString body.

template

the tpd.Template for which we want to replace the current toString body implementation.

x$3

implicit Context parameter.

Returns:

the tpd.Template with the updated toString method, wrapped in a Try.

def patchTypeDef(tree: TypeDef, newTemplate: Template)(using Context): Try[TypeDef]

Given the original tpd.TypeDef, try to replace its tpd.Template with the one provided as second argument.

Given the original tpd.TypeDef, try to replace its tpd.Template with the one provided as second argument.

Attributes

newTemplate

the tpd.Template that contains the updated toString method.

tree

the original tpd.TypeDef that we would like to update..

x$3

implicit Context parameter.

Returns:

the tpd.TypeDef with the updated toString method, wrapped in a Try.

def validate(tree: TypeDef)(using Context): Option[TypeDef]

Checks whether the tpd.TypeDef being inspected:

Checks whether the tpd.TypeDef being inspected:

  1. is a case class
  2. has fields annotated with @redacted

and returns an option containing the validated tpd.TypeDef.

Attributes

tree

the tree to be validated.

x$2

implicit Context parameter.

Returns:

the tree wrapped in an optional, if valid, or None if not.

Extensions

Extensions

extension [Out](opt: Option[Out])
def withLog(message: String)(using Context): Option[Out]
extension [Out](t: Try[Out])
def withLog(message: String)(using Context): Option[Out]