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

smithy4s.deriving.internals.SourcePosition.scala Maven / Gradle / Ivy

The newest version!
package smithy4s.deriving.internals

import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.int
import smithy4s.schema.Schema.recursive
import smithy4s.schema.Schema.string
import smithy4s.schema.Schema.struct

final case class SourcePosition(path: String, start: Int, startLine: Int, startColumn: Int, end: Int, endLine: Int, endColumn: Int)

object SourcePosition extends ShapeTag.Companion[SourcePosition] {
  val id: ShapeId = ShapeId("smithy4s.deriving.internals", "SourcePosition")

  val hints: Hints = Hints(
    smithy.api.Trait(selector = None, structurallyExclusive = None, conflicts = None, breakingChanges = None),
  ).lazily

  // constructor using the original order from the spec
  private def make(path: String, start: Int, startLine: Int, startColumn: Int, end: Int, endLine: Int, endColumn: Int): SourcePosition = SourcePosition(path, start, startLine, startColumn, end, endLine, endColumn)

  implicit val schema: Schema[SourcePosition] = recursive(struct(
    string.required[SourcePosition]("path", _.path),
    int.required[SourcePosition]("start", _.start),
    int.required[SourcePosition]("startLine", _.startLine),
    int.required[SourcePosition]("startColumn", _.startColumn),
    int.required[SourcePosition]("end", _.end),
    int.required[SourcePosition]("endLine", _.endLine),
    int.required[SourcePosition]("endColumn", _.endColumn),
  )(make).withId(id).addHints(hints))
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy