All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scala.meta.internal.tokens.Reflection.scala Maven / Gradle / Ivy

Go to download

Bag of private and public helpers used in scala.meta's APIs and implementations

There is a newer version: 4.12.6
Show newest version
package scala.meta
package internal
package tokens

import org.scalameta.adt.{Reflection => AdtReflection}
import scala.meta.internal.tokens.{Metadata => TokenMetadata}

trait Reflection extends AdtReflection {
  import u._

  implicit class XtensionTokenMetadataSymbol(sym: Symbol) {
    def isToken: Boolean = sym.hasAnnotation[TokenMetadata.tokenClass]
    def isFreeform: Boolean = {
      Predef.require(sym.isToken)
      val Some(q"new $_($_, ${freeform: Boolean})") = sym.getAnnotation[TokenMetadata.tokenClass]
      freeform
    }
    def isFixed: Boolean = !sym.isFreeform
    def tokenName: String = {
      Predef.require(sym.isToken)
      val Some(q"new $_(${tokenName: String}, $_)") = sym.getAnnotation[TokenMetadata.tokenClass]
      tokenName
    }
  }

  implicit class XtensionTokenMetadataLeaf(leaf: Leaf) {
    def isToken: Boolean = leaf.sym.isToken
    def isFreeform: Boolean = leaf.sym.isFreeform
    def isFixed: Boolean = leaf.sym.isFixed
    def tokenName: String = leaf.sym.tokenName
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy