mirror of https://github.com/sbt/sbt.git
Add tailrec annotations (#8785)
This commit is contained in:
parent
b7b3947b81
commit
611cea8fbd
|
|
@ -17,6 +17,7 @@ import Def.{ ScopedKey, Setting, Settings }
|
||||||
import Scope.GlobalScope
|
import Scope.GlobalScope
|
||||||
import sbt.internal.parser.SbtParser
|
import sbt.internal.parser.SbtParser
|
||||||
import sbt.io.IO
|
import sbt.io.IO
|
||||||
|
import scala.annotation.tailrec
|
||||||
import scala.jdk.CollectionConverters.*
|
import scala.jdk.CollectionConverters.*
|
||||||
import xsbti.PathBasedFile
|
import xsbti.PathBasedFile
|
||||||
import xsbti.VirtualFile
|
import xsbti.VirtualFile
|
||||||
|
|
@ -299,6 +300,7 @@ private[sbt] object EvaluateConfigurations {
|
||||||
): (Seq[(String, Tree, LineRange)], Seq[(String, Tree, LineRange)]) =
|
): (Seq[(String, Tree, LineRange)], Seq[(String, Tree, LineRange)]) =
|
||||||
lines partition { case (_, tree, _) => isDefinition(tree) }
|
lines partition { case (_, tree, _) => isDefinition(tree) }
|
||||||
|
|
||||||
|
@tailrec
|
||||||
private def isDefinition(tree: Tree): Boolean = {
|
private def isDefinition(tree: Tree): Boolean = {
|
||||||
tree match {
|
tree match {
|
||||||
case Annotated(arg, annot) => isDefinition(arg)
|
case Annotated(arg, annot) => isDefinition(arg)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ package parser
|
||||||
|
|
||||||
import dotty.tools.dotc.ast.untpd
|
import dotty.tools.dotc.ast.untpd
|
||||||
import dotty.tools.dotc.core.Contexts.Context
|
import dotty.tools.dotc.core.Contexts.Context
|
||||||
|
import scala.annotation.tailrec
|
||||||
|
|
||||||
private[sbt] object SbtRefactorings:
|
private[sbt] object SbtRefactorings:
|
||||||
|
|
||||||
|
|
@ -91,6 +92,7 @@ private[sbt] object SbtRefactorings:
|
||||||
seq.toMap
|
seq.toMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@tailrec
|
||||||
private def extractSettingName(tree: untpd.Tree): String = tree match
|
private def extractSettingName(tree: untpd.Tree): String = tree match
|
||||||
case untpd.Ident(name) => name.toString
|
case untpd.Ident(name) => name.toString
|
||||||
case untpd.InfixOp(lhs, _, _) => extractSettingName(lhs)
|
case untpd.InfixOp(lhs, _, _) => extractSettingName(lhs)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ package complete
|
||||||
import Parser.*
|
import Parser.*
|
||||||
import sbt.internal.util.Types.{ left, right, some }
|
import sbt.internal.util.Types.{ left, right, some }
|
||||||
import sbt.internal.util.Util.{ makeList, separate }
|
import sbt.internal.util.Util.{ makeList, separate }
|
||||||
|
import scala.annotation.tailrec
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A String parser that provides semi-automatic tab completion. A successful parse results in a
|
* A String parser that provides semi-automatic tab completion. A successful parse results in a
|
||||||
|
|
@ -505,6 +506,7 @@ trait ParserMain {
|
||||||
|
|
||||||
// intended to be temporary pending proper error feedback
|
// intended to be temporary pending proper error feedback
|
||||||
def result[T](p: Parser[T], s: String): Either[() => (Seq[String], Int), T] = {
|
def result[T](p: Parser[T], s: String): Either[() => (Seq[String], Int), T] = {
|
||||||
|
@tailrec
|
||||||
def loop(i: Int, a: Parser[T]): Either[() => (Seq[String], Int), T] =
|
def loop(i: Int, a: Parser[T]): Either[() => (Seq[String], Int), T] =
|
||||||
a match {
|
a match {
|
||||||
case Invalid(f) => Left(() => (f.errors, i))
|
case Invalid(f) => Left(() => (f.errors, i))
|
||||||
|
|
@ -1003,6 +1005,7 @@ private final class Repeat[T](
|
||||||
repeat(Some(repeated.derive(c)), repeated, scala.math.max(0, min - 1), max.decrement, accRev)
|
repeat(Some(repeated.derive(c)), repeated, scala.math.max(0, min - 1), max.decrement, accRev)
|
||||||
|
|
||||||
def completions(level: Int) = {
|
def completions(level: Int) = {
|
||||||
|
@tailrec
|
||||||
def pow(comp: Completions, exp: Completions, n: Int): Completions =
|
def pow(comp: Completions, exp: Completions, n: Int): Completions =
|
||||||
if (n == 1) comp else pow(comp.x(exp), exp, n - 1)
|
if (n == 1) comp else pow(comp.x(exp), exp, n - 1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ package sbt.internal.util
|
||||||
import Types.*
|
import Types.*
|
||||||
import sbt.util.Show
|
import sbt.util.Show
|
||||||
import Util.{ nil, nilSeq }
|
import Util.{ nil, nilSeq }
|
||||||
|
import scala.annotation.tailrec
|
||||||
import scala.jdk.CollectionConverters.*
|
import scala.jdk.CollectionConverters.*
|
||||||
|
|
||||||
// delegates should contain the input ScopeType as the first entry
|
// delegates should contain the input ScopeType as the first entry
|
||||||
|
|
@ -590,6 +591,7 @@ trait Init:
|
||||||
val processed = new mutable.HashSet[ScopedKey[?]]
|
val processed = new mutable.HashSet[ScopedKey[?]]
|
||||||
|
|
||||||
// derives settings, transitively so that a derived setting can trigger another
|
// derives settings, transitively so that a derived setting can trigger another
|
||||||
|
@tailrec
|
||||||
def process(rem: List[Setting[?]]): Unit = rem match {
|
def process(rem: List[Setting[?]]): Unit = rem match {
|
||||||
case s :: ss =>
|
case s :: ss =>
|
||||||
val sk = s.key
|
val sk = s.key
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue