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

sangria.schema.AstNodeTransformer.scala Maven / Gradle / Ivy

The newest version!
package sangria.schema

import sangria.ast.{AstLocation, AstNode, Comment}
import sangria.visitor._

object AstNodeTransformer {
  def withoutAstLocations[T <: AstNode](node: T, stripComments: Boolean = false): T = {
    val enterComment = (_: Comment) =>
      if (stripComments) VisitorCommand.Delete else VisitorCommand.Continue

    visit[AstNode](
      node,
      Visit[Comment](enterComment),
      VisitAnyField[AstNode, Option[AstLocation]]((_, _) => VisitorCommand.Transform(None)))
      .asInstanceOf[T]
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy