A unique identifier for one kind of a linter message.
A unique identifier for one kind of a linter message.
a string ID for this message, typically the name of the assigned variable. If id is empty, then the name of the rewrite reporting this LintCategory is used as id.
An optional explanation for this kind of message.
The default category this message should get reported to. Note that users can configure/override the default category.
An observation of a LintCategory at a particular position
An observation of a LintCategory at a particular position
The message to display to the user. If empty, LintID.explanation is used instead.
Optionally place a caret under a location in a source file. For an empty position use Position.None.
the LintCategory associated with this message.
A Scalafix Rule.
A Scalafix Rule.
To provide automatic fixes for this rule, override the fix
method. Example:
object ReverseNames extends Rule("ReverseNames") { override def fix(ctx: RuleCtx) = ctx.tree.collect { case name @ Name(value) => ctx.replaceTree(name, value.reverse) }.asPatch }
To report violations of this rule (without automatic fix), override
the check
method. Example:
// example syntactic linter object NoNulls extends Rule("NoNulls") { val error = LintCategory.error("Nulls are not allowed.") override def check(ctx: RuleCtx): List[Diagnostic] = ctx.tree.collect { case nil @ q"null" => error.at(nil.pos) } }
An index for looking up data in a scala.meta.Database.
Utility to match against a particular symbol.
Utility to match against a particular symbol.
Can be used both in pattern matching and regular condition testing.
val myMethod = SymbolMatcher(Symbol("_root_.myMethod")) myMethod.matches(Tree) Tree match { case myMethod(_) => // act on tree } myMethod.matches(Tree)