scala.meta.contrib.equality.Syntactically.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalameta_native0.5_2.13 Show documentation
Show all versions of scalameta_native0.5_2.13 Show documentation
Scalameta umbrella module that includes all public APIs
package scala.meta.contrib.equality
import scala.meta.Tree
import scala.meta.XtensionSyntax
import scala.language.implicitConversions
/**
* Represents syntactic equality between trees Two trees are syntactically equal if their .syntax is
* equal.
*/
class Syntactically[+A <: Tree](val tree: A) extends TreeEquality[A] {
private lazy val syntax = tree.syntax
override def hashCode(): Int = syntax.hashCode
override def equals(obj: scala.Any): Boolean = obj match {
case e2: Syntactically[_] => syntax == e2.syntax
case _ => false
}
}
object Syntactically {
def apply[A <: Tree](tree: A): Syntactically[A] = new Syntactically(tree)
implicit def SyntacticEq[A <: Tree]: Equal[Syntactically[A]] = new Equal[Syntactically[A]] {
override def isEqual(a: Syntactically[A], b: Syntactically[A]): Boolean = a.equals(b)
}
implicit def toSyntactic[A <: Tree](e: A): Syntactically[A] = apply(e)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy