trait RuleCtx extends PatchOps

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

Abstract Value Members

  1. abstract def addGlobalImport(symbol: Symbol)(implicit index: util.SemanticdbIndex): patch.Patch

    Add an import on symbol among the global imports.

    Add an import on symbol among the global imports.

    This patch is not reference, unlike removeImportee(Importee). It is only necessary to use this patch once per tree, duplicate symbols are ignored.

    Definition Classes
    PatchOps
  2. abstract def addGlobalImport(importer: Importer): patch.Patch

    Add this importer to the global imports at the top of this file.

    Add this importer to the global imports at the top of this file.

    It is OK to pass in a quasiquote here. The importer has no attached semantic information, so it's not possible to deduplicate Importers.

    Definition Classes
    PatchOps
  3. abstract def addLeft(tree: Tree, toAdd: String): patch.Patch

    Add the string toAdd to the first token of tree.

    Add the string toAdd to the first token of tree. Does not remove tokens.

    Definition Classes
    PatchOps
  4. abstract def addLeft(token: scala.meta.Token, toAdd: String): patch.Patch

    Add the string toAdd to the left side of token, while keeping token.

    Add the string toAdd to the left side of token, while keeping token.

    Definition Classes
    PatchOps
  5. abstract def addRight(tree: Tree, toAdd: String): patch.Patch

    Add the string toAdd to the last token of tree.

    Add the string toAdd to the last token of tree. Does not remove tokens.

    Definition Classes
    PatchOps
  6. abstract def addRight(token: scala.meta.Token, toAdd: String): patch.Patch

    Add the string toAdd to the right side of token, while keeping token.

    Add the string toAdd to the right side of token, while keeping token.

    Definition Classes
    PatchOps
  7. abstract def comments: AssociatedComments

    Find comments/docstrings associated with tree nodes.

    Find comments/docstrings associated with tree nodes. *

  8. abstract def debugIndex()(implicit index: SemanticdbIndex, fileLine: FileLine): Unit

    Print out the contents of SemanticdbIndex for this input only.

    Print out the contents of SemanticdbIndex for this input only. *

  9. abstract def index(implicit index: SemanticdbIndex): SemanticdbIndex

    Get SemanticdbIndex for this single tree alone.

  10. abstract def input: scala.meta.Input

    The input where the tree was parsed from.

    The input where the tree was parsed from.

    This is typically either Input.VirtualFile for semantic rules and Input.File for syntactic rules. For Input.VirtualFile, it is possible to trace back to the original file path via SemanticdbIndex.sourcepath.

  11. abstract def lint(msg: lint.Diagnostic): patch.Patch

    Report a linter message.

    Report a linter message.

    To construct a LintMessage, start by creating a lint category. Example:

    class MyLinter extends Rule {
      val divisionByZero = scalafix.LintCategory.error("Division by zero!")
      val divisionTree: scala.meta.Tree = ???
      PatchOps.lint(divisionByZero.at(divisionTree.pos))
    }

    Each LintCategory is assigned a unique identifier, which is formatted as "RuleName.categoryID". The divisionByZero example would have the id "MyLinter.divisionByZero". A LintCategory has a default severity level (warning, error) that the user can override in .scalafix.conf.

    Definition Classes
    PatchOps
  12. abstract def matchingParens: MatchingParens

    Find matching open/close pairs of parens/braces/brackets.

    Find matching open/close pairs of parens/braces/brackets. *

  13. abstract def removeGlobalImport(symbol: Symbol)(implicit index: util.SemanticdbIndex): patch.Patch

    Remove importees that resolve to symbol.

    Remove importees that resolve to symbol.

    Note, this patch is not reference, unlike removeImportee(Importee). It is only necessary to use this patch once per tree, duplicate symbols are ignored.

    Definition Classes
    PatchOps
  14. abstract def removeImportee(importee: Importee): patch.Patch

    Remove this particular instance of Importee.

    Remove this particular instance of Importee.

    Handles tricky cases like trailing commas or curly braces. Example, removeImportee(b) in import a.{b, c} produces import a.c.

    Note, importee instance is by reference, so removing quasiquotes (example, removeImportee(importee"b")) does nothing.

    Definition Classes
    PatchOps
  15. abstract def removeToken(token: scala.meta.Token): patch.Patch

    Replace single token with empty string.

    Replace single token with empty string.

    Definition Classes
    PatchOps
  16. abstract def removeTokens(tokens: Iterable[scala.meta.Token]): patch.Patch
    Definition Classes
    PatchOps
  17. abstract def removeTokens(tokens: scala.meta.Tokens): patch.Patch

    Replace all tokens with empty string.

    Replace all tokens with empty string.

    Definition Classes
    PatchOps
  18. abstract def renameSymbol(fromSymbol: Global, toName: String)(implicit index: util.SemanticdbIndex): patch.Patch

    Replace appearances of names that reference fromSymbol with toName.

    Replace appearances of names that reference fromSymbol with toName.

    toName should be a legal identifier, it cannot be a tree such as foo(). Use this patch for example to rename a methods on a class.

    Definition Classes
    PatchOps
  19. abstract def replaceSymbol(fromSymbol: Global, toSymbol: Global)(implicit index: util.SemanticdbIndex): patch.Patch

    Replace references/call-sites to fromSymbol with references to toSymbol.

    Replace references/call-sites to fromSymbol with references to toSymbol.

    toSymbol must be a static method or a globally accessible object. toSymbol should not be path dependent. To rename a class method, use renameSymbol.

    Experimental. May produce broken code in some cases. This is the same patch as replace:com.foo/com.bar from sbt-scalafix.

    Definition Classes
    PatchOps
  20. abstract def replaceSymbols(toReplace: Seq[(String, String)])(implicit noop: DummyImplicit, index: util.SemanticdbIndex): patch.Patch

    Helper for calling replaceSymbols without needing _*

    Helper for calling replaceSymbols without needing _*

    Defers work to replaceSymbols((String, String)*). Needs a dummy implicit to differentiate from replaceSymbols((String, String)*) after type erasure

    Definition Classes
    PatchOps
  21. abstract def replaceSymbols(toReplace: (String, String)*)(implicit index: util.SemanticdbIndex): patch.Patch

    Shorthand for calling replaceSymbol from strings.

    Shorthand for calling replaceSymbol from strings.

    String values are treated as Symbol.Global.

    Definition Classes
    PatchOps
  22. abstract def replaceToken(token: scala.meta.Token, toReplace: String): patch.Patch

    Replace the entire contents of this Token with toReplace.

    Replace the entire contents of this Token with toReplace.

    Definition Classes
    PatchOps
  23. abstract def replaceTree(tree: Tree, toReplace: String): patch.Patch

    Replace all tokens of tree contents with toReplace.

    Replace all tokens of tree contents with toReplace.

    Definition Classes
    PatchOps
  24. abstract def tokenList: TokenList

    Traverse tokens as a doubly linked list.

    Traverse tokens as a doubly linked list. *

  25. abstract def tokens: Tokens

    The tokenized tokens of this this tree.

    The tokenized tokens of this this tree. *

  26. abstract def tree: Tree

    The parsed syntax tree that should be fixed.

    The parsed syntax tree that should be fixed.

    The scalafix API does not support fixing un-parseable code at this point.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from RuleCtx toany2stringadd[RuleCtx] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (RuleCtx, B)
    Implicit
    This member is added by an implicit conversion from RuleCtx toArrowAssoc[RuleCtx] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  8. def ensuring(cond: (RuleCtx) => Boolean, msg: => Any): RuleCtx
    Implicit
    This member is added by an implicit conversion from RuleCtx toEnsuring[RuleCtx] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  9. def ensuring(cond: (RuleCtx) => Boolean): RuleCtx
    Implicit
    This member is added by an implicit conversion from RuleCtx toEnsuring[RuleCtx] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: Boolean, msg: => Any): RuleCtx
    Implicit
    This member is added by an implicit conversion from RuleCtx toEnsuring[RuleCtx] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean): RuleCtx
    Implicit
    This member is added by an implicit conversion from RuleCtx toEnsuring[RuleCtx] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  15. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from RuleCtx toStringFormat[RuleCtx] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  16. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Deprecated Value Members

  1. def [B](y: B): (RuleCtx, B)
    Implicit
    This member is added by an implicit conversion from RuleCtx toArrowAssoc[RuleCtx] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from PatchOps

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromRuleCtx to any2stringadd[RuleCtx]

Inherited by implicit conversion StringFormat fromRuleCtx to StringFormat[RuleCtx]

Inherited by implicit conversion Ensuring fromRuleCtx to Ensuring[RuleCtx]

Inherited by implicit conversion ArrowAssoc fromRuleCtx to ArrowAssoc[RuleCtx]

Ungrouped