Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ trait BasicTypesHelpers { self: StringHelpers with ControlHelpers =>
*/
def compareElem(left: Elem, right: Elem): Boolean =
compareXml(left.child, right.child) &&
left.label == right.label &&
(((null eq left.prefix) && (null eq right.prefix)) || left.prefix == right.prefix) &&
left.label == right.label &&
(((null eq left.prefix) && (null eq right.prefix)) || left.prefix == right.prefix) &&
left.scope == right.scope &&
compareMetaData(left.attributes.toList, right.attributes.toList)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ trait CombParserHelpers {
* of the case (uppercase or lowercase)
*/
def acceptCI[ES](es: ES)(implicit ev: ES => List[Elem]): Parser[List[Elem]] =
es.foldRight[Parser[List[Elem]]](
ev(es).foldRight[Parser[List[Elem]]](

Copilot AI Oct 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explicit call to ev(es) is unnecessary since the implicit conversion should be applied automatically. This suggests a potential issue with the implicit conversion or type inference.

Suggested change
ev(es).foldRight[Parser[List[Elem]]](
es.foldRight[Parser[List[Elem]]](

Copilot uses AI. Check for mistakes.
success(Nil)){(x, pxs) => acceptCIChar(x) ~ pxs ^^ mkList}

def xform(in: Char): Char = Character.toUpperCase(in)
Expand Down
3 changes: 1 addition & 2 deletions core/util/src/main/scala/net/liftweb/util/CssSel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,7 @@ object CanBind extends CssBindImplicits {

implicit def iterableDouble[T[Double]](implicit f: T[Double] => Iterable[Double]): CanBind[T[Double]] =
new CanBind[T[Double]] {
def apply(info: => T[Double])(ns: NodeSeq): Seq[NodeSeq] = f(info).toSeq.flatMap(a =>
if (a == null) Nil else List(Text(a.toString)))
def apply(info: => T[Double])(ns: NodeSeq): Seq[NodeSeq] = f(info).toSeq.flatMap(a => List(Text(a.toString)))
}

implicit def iterableBindableTransform[T[_]](implicit f: T[Bindable] => Iterable[Bindable]): CanBind[T[Bindable]] =
Expand Down
2 changes: 1 addition & 1 deletion core/util/src/main/scala/net/liftweb/util/FatLazy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FatLazy[T](f: => T) {
* Test whether the value of this class has been set or initialized from the default.
*/
def defined_? = synchronized {
value != None
value.toOption != None
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ trait HtmlHelpers extends CssBindImplicits {
</i>
</div>)

case _ => Empty
case _ => Empty
}
}

Expand Down
9 changes: 9 additions & 0 deletions core/util/src/main/scala/net/liftweb/util/HtmlParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,15 @@ trait Html5Parser {
}
buffer.setLength(0)
}

// Override endDocument to handle empty hStack case in Scala 3
// Scala 3's List.last throws "None.get" error on empty lists
override def endDocument(): Unit = {
if (hStack.nonEmpty) {
epilogue = hStack.init.reverse
hStack = hStack.last :: Nil
}
}
}

saxer.scopeStack = saxer.scopeStack.prepended(TopScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sealed trait IterableFunc extends Function1[NodeSeq, Seq[NodeSeq]] {
}

object IterableFunc {
implicit def itNodeSeq[C](it: NodeSeq => C)(implicit ev: C => Iterable[NodeSeq]): IterableFunc =
implicit def itNodeSeq[C <: Iterable[NodeSeq]](it: NodeSeq => C)(implicit ev: C => Iterable[NodeSeq]): IterableFunc =
new IterableFunc {
def apply(in: NodeSeq): Seq[NodeSeq] = it(in).toSeq
}
Expand Down
18 changes: 9 additions & 9 deletions core/util/src/main/scala/net/liftweb/util/LD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ object LD {
(ly: @unchecked) match {
case w :: Nil => (w, this(root, f(w)))

case w :: ws =>
val tv = this(root, f(w))
val rest = this(root, ws, f)
if (tv < rest._2) (w, tv)
else rest
case w :: ws =>
val tv = this(root, f(w))
val rest = this(root, ws, f)
if (tv < rest._2) (w, tv)
else rest
}

/**
Expand All @@ -77,10 +77,10 @@ object LD {
case Nil => acc.toList
case c :: cs =>
val cost = if (c == ch) 0 else 1
val i = dist.head
val calc = min(left + cost, i + 1, top + 1)
acc += calc
column(cs, dist.tail, i, calc, ch, acc)
val i = dist.head
val calc = min(left + cost, i + 1, top + 1)
acc += calc
column(cs, dist.tail, i, calc, ch, acc)
}

def matrix(word: List[Char], pos: Int, dist: List[Int]): List[Int] =
Expand Down
4 changes: 2 additions & 2 deletions core/util/src/main/scala/net/liftweb/util/ListHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ trait ListHelpers {
*/
def enumToList[T](`enum`: java.util.Enumeration[T]): List[T] = {
import scala.jdk.CollectionConverters._
enum.asScala.toList
`enum`.asScala.toList
}

/**
* Convert a java.util.Enumeration to a List[String] using the toString method on each element
*/
def enumToStringList[C](`enum`: java.util.Enumeration[C]): List[String] =
enumToList(enum).map(_.toString)
enumToList(`enum`).map(_.toString)

/**
* Return the first element of a List or a default value if the list is empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class PCDataXmlParser(val input: Source) extends ConstructingHandler with PCData
val preserveWS = true
ent ++= HtmlEntities()
import scala.xml._

/** Public accessor for curInput.hasNext to work around Scala 3 protected access restrictions */
def hasMoreInput: Boolean = curInput.hasNext
/** parse attribute and create namespace scope, metadata
* [41] Attributes ::= { S Name Eq AttValue }
*/
Expand Down Expand Up @@ -190,7 +193,7 @@ object PCDataXmlParser {
private def apply(source: Source): Box[NodeSeq] = {
for {
p <- tryo{new PCDataXmlParser(source)}
_ = while (p.ch != '<' && p.curInput.hasNext) p.nextch() // side effects, baby
_ = while (p.ch != '<' && p.hasMoreInput) p.nextch() // side effects, baby
bd <- tryo(p.document())
doc <- Box !! bd
} yield (doc.children: NodeSeq)
Expand Down
2 changes: 1 addition & 1 deletion core/util/src/main/scala/net/liftweb/util/Props.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private[util] trait Props extends Logger {
}

val interpolated = for {
interpolateRegex(before, key, after) <- interpolateRegex.findAllMatchIn(value.toString)
case interpolateRegex(before, key, after) <- interpolateRegex.findAllMatchIn(value.toString)
} yield {
val lookedUp = lookup(key).getOrElse(("${" + key + "}"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class RestoringWeakReference[T <: AnyRef](private var reference:WeakReference[T]
}
object RestoringWeakReference {
def apply[T <: AnyRef](restorer:()=>T) = {
new RestoringWeakReference(new WeakReference(restorer()), restorer)
new RestoringWeakReference(new WeakReference(restorer()), restorer)
}
def apply[T <: AnyRef](starter:T, restorer:()=>T) = {
new RestoringWeakReference(new WeakReference(starter), restorer)
new RestoringWeakReference(new WeakReference(starter), restorer)
}
}

12 changes: 6 additions & 6 deletions core/util/src/main/scala/net/liftweb/util/Schedule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ sealed trait Schedule extends Loggable {
/**
* Re-create the underlying <code>SingleThreadScheduledExecutor</code>
*/
def restart: Unit = synchronized
{ if ((service eq null) || service.isShutdown)
service = buildService()
if ((pool eq null) || pool.isShutdown)
pool = buildExecutor()
}
def restart: Unit = synchronized { if ((service eq null) || service.isShutdown)

Copilot AI Oct 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a duplicated condition check. The second if statement on line 84 appears to be a copy-paste error from line 83, creating unreachable or redundant logic.

Suggested change
def restart: Unit = synchronized { if ((service eq null) || service.isShutdown)
def restart: Unit = synchronized {

Copilot uses AI. Check for mistakes.
if ((service eq null) || service.isShutdown)
service = buildService()
if ((pool eq null) || pool.isShutdown)
pool = buildExecutor()
}


/**
Expand Down
132 changes: 0 additions & 132 deletions core/util/src/main/scala/net/liftweb/util/SourceInfo.scala

This file was deleted.

4 changes: 2 additions & 2 deletions core/util/src/main/scala/net/liftweb/util/StringHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ trait StringHelpers {
def splitNameValuePairs(props: String): Map[String, String] = {
val list = props.split(",").toList.map(in => {
val pair = in.roboSplit("=")
(pair(0), unquote(pair(1)))
(pair(0), unquote(pair(1)))
})
val map: Map[String, String] = Map.empty

(list.foldLeft(map))((m, next) => m + (next))
list.foldLeft(map) { (m, next) => m + (next) }
}

/**
Expand Down
37 changes: 1 addition & 36 deletions core/util/src/main/scala/net/liftweb/util/TimeHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -280,39 +280,11 @@ trait TimeHelpers { self: ControlHelpers =>
divideInUnits(millis).filter(_._1 > 0).map(formatAmount(_)).mkString(", ")
}

/**
* Convert a Date to a TimeSpan
*/
@deprecated("Date to TimeSpan conversion will be removed for possibility of mistakes in on-duration operations", "3.0.0")
implicit def dateToTS(in: Date): TimeSpan =
new TimeSpan(Left(new Duration(in.getTime)))


/**
* Convert a Duration to a TimeSpan
*/
implicit def durationToTS(in: Duration): TimeSpan =
new TimeSpan(Left(in))

/**
* Convert a Period to a TimeSpan
*/
@deprecated("Implicit conversion from Period to TimeSpan will be removed due to its unclear behavior; use new Period(timeSpan.millis) instead.", "3.0.0")
implicit def periodToTS(in: Period): TimeSpan =
new TimeSpan(Right(in))

/**
* Convert a TimeSpan to a Period
*/
@deprecated("Implicit conversion from TimeSpan to Period will be removed due to its unclear behavior; use new TimeSpan(period.toDurationFrom(startDateTime)) instead.", "3.0.0")
implicit def tsToPeriod[TS <% TimeSpan](in: TS): Period = in.toPeriod

/**
* Convert a DateTime to a TimeSpan
*/
@deprecated("Implicit conversion from DateTime to TimeSpan will be removed due to its unclear behavior; use new TimeSpan(dateTime.getMillis) instead.", "3.0.0")
implicit def dateTimeToTS(in: DateTime): TimeSpan =
new TimeSpan(Left(new Duration(in.getMillis)))
}

/** @return the current System.nanoTime() */
Expand Down Expand Up @@ -517,13 +489,6 @@ trait TimeHelpers { self: ControlHelpers =>
case e: Exception => logger.debug("Error parsing date "+in, e); Failure("Bad date: "+in, Full(e), Empty)
}
}

implicit class PeriodExtension[P](period: P)(implicit ev: P => Period) {
def later: DateTime = new DateTime(millis).plus(period)

def ago: DateTime = new DateTime(millis).minus(period)
}

}

trait ConvertableToDate {
Expand All @@ -536,4 +501,4 @@ object ConvertableToDate {
implicit def toDate(in: ConvertableToDate): Date = in.toDate
implicit def toDateTime(in: ConvertableToDate): DateTime = in.toDateTime
implicit def toMillis(in: ConvertableToDate): Long = in.millis
}
}
Loading