API Overview
The Scalafix public API documentation is composed of several packages.
Scalafix v1
Latest Scaladoc: v0.9.0-RC1
The Scalafix v1 API is available through import scalafix.v1._
. Key data
structures include:
Patch
: to describe source code rewrites such as removing or replacing tokens and trees.SymbolMatcher
: to match tree nodes that resolve to a specific set of symbols.SemanticType
: a sealed data structure that encodes the Scala type system.SemanticTree
: a sealed data structure that encodes tree nodes that are generated by the compiler from inferred type parameters, implicit arguments, implicit conversions, inferred.apply
and for-comprehensions.Symbol
: a unique identifier for a definition. For example, theString
class has the symboljava/lang/String#
. The type alias toString
in the Scala standard library has the symbolscala/Predef.Symbol#
.SymbolInformation
: a data structure containing metadata about aSymbol
definition.Diagnostic
: a linter error message that can be reported at a source file location.SyntacticRule
: super class for all syntactic rules.SyntacticDocument
: context about a single source file containing syntactic information such as trees/tokens.SemanticRule
: super class for all semantic rules.SemanticDocument
: context about a single source file containing syntactic information such as trees/tokens and semantic information such as symbols/types/synthetics.
Scalafix v0
Latest Scaladoc: v0.9.0-RC1
This is a legacy API that exists to smoothen the migration for existing Scalafix v0.5 rules. If you are writing a new Scalafix rule, please use the v1 API.
Scalameta Trees
Latest Scaladoc: v4.0.0
The tree API is available through import scala.meta._
. Key data structures
include:
Tree
: the supertype of all tree nodes. Key methods include:pos: Position
: the source code position of this tree nodesymbol: Symbol
: extension method made available viaimport scalafix.v1._
, requires an implicitSemanticDocument
. Returns the the symbol of this tree nodesyntax: String
: the pretty-printed tree nodestructure: String
: the raw structure of this tree node, useful for figuring out how to pattern match against a particular tree node.
Term
: the supertype for all term nodes in "term position". Terms are the parts of programs that get executed at runtime such asrun(42)
inval x: String = run(42)
.Type
: the supertype for all type nodes in "type position". Type are the parts of programs that only exist at compile time, such asString
inval x: String = ""
.Stat
: the supertype for all tree nodes that can appear in "statement position". Statement position is theDefn
: the supertype for all definitions
Scalameta Tokens
Latest Scaladoc: v4.0.0
The type scala.meta.Token
is a representation of all lexical tokens in the
Scala language. Each token kind has it's own type, such as Token.Space
, and
Token.KwClass
("keyword class
").
The token API is available through import scala.meta._
. Key data structures
include:
Token
: the supertype for all token kinds. Sub-types ofToken
includeToken.Space
,Token.KwClass
("keywordclass
"),Token.LeftParen
andToken.Colon
.Tokens
: a sequence of tokens with efficient collection operations such as slice, take and drop. It's important to keep in mind that a normal source file can have tens of thousands of tokens so operations likefilter
may perform badly.
case class User(name: String)
User("\"John")
// res0: User = User("\"John")