object Patch
- Alphabetic
- By Inheritance
- Patch
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- def addAround(tree: Tree, left: String, right: String): Patch
- def addAround(tok: scala.meta.Token, left: String, right: String): Patch
- def addGlobalImport(symbol: Symbol)(implicit c: SemanticContext): Patch
Place named import for this symbol at the bottom of the global import list
- def addGlobalImport(importer: Importer): Patch
Add this importer to the global import list.
- def addLeft(tree: Tree, toAdd: String): Patch
Add this string to the left of this tree.
- def addLeft(tok: scala.meta.Token, toAdd: String): Patch
Add this string to the left of this token.
- def addRight(tree: Tree, toAdd: String): Patch
Add this string to the right of this tree.
- def addRight(tok: scala.meta.Token, toAdd: String): Patch
Add this string to the right of this token.
- val empty: Patch
Do nothing: no diff, no diagnostics.
- def fromIterable(seq: Iterable[Patch]): Patch
Combine a sequence of patches into a single patch.
- def lint(msg: lint.Diagnostic): Patch
Reports error/warning/info message at a position.
- def removeGlobalImport(symbol: Symbol)(implicit c: SemanticContext): Patch
Remove named imports for this symbol.
Remove named imports for this symbol.
Does not remove wildcard imports for the enclosing package or class.
- def removeImportee(importee: Importee): Patch
Remove this importee reference.
- def removeToken(token: scala.meta.Token): Patch
Remove this single token from the source file.
- def removeTokens(tokens: Iterable[scala.meta.Token]): Patch
Remove all of the these tokens from the source file.
- def renameSymbol(fromSymbol: Symbol, toName: String)(implicit c: SemanticContext): Patch
Replace occurrences of fromSymbol to use toName instead
- def replaceSymbols(toReplace: (String, String)*)(implicit c: SemanticContext): Patch
Replace occurrences of fromSymbol to reference toSymbol instead.
Replace occurrences of fromSymbol to reference toSymbol instead.
toSymbol
must be a global symbol such as an object/class or a static method.May produce broken code in some cases, works best when toSymbol has the same depth as fromSymbol, example:
- good: replace:com.foo.Bar/org.qux.Buz
- bad: replace:com.Bar/org.qux.Buz
- def replaceToken(token: scala.meta.Token, toReplace: String): Patch
Remove the token and insert this string at the same position.
- def replaceTree(from: Tree, to: String): Patch
Remove all tokens from this tree and add a string add the same position.
Remove all tokens from this tree and add a string add the same position.
Beware that this patch does not compose with other patches touching the same tree node or its children. Avoid using this method for large tree nodes like classes of methods. It's recommended to target as precise tree nodes as possible.
It is better to use addRight/addLeft if you only insert new code, example:
- bad: Patch.replaceTree(tree, "(" + tree.syntax + ")")
- good: Patch.addLeft(tree, "(") + Patch.addRight(tree, + ")")