alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (Positions.scala)

This example Scala source code file (Positions.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Scala source code examples by using tags.

All credit for the original source code belongs to scala-lang.org; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Scala tags/keywords

anyref, list, noposition, null, pos, position, positions, t, tree, universe

The Positions.scala Scala example source code

package scala
package reflect
package api

/**
 * <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
 *
 * This trait defines the concept of positions and operations on them.
 *
 * @see [[scala.reflect.api.Position]]
 *
 * @contentDiagram hideNodes "*Api"
 * @group ReflectionAPI
 */
trait Positions {
  self: Universe =>

  /** Defines a universe-specific notion of positions.
   *  The main documentation entry about positions is located at [[scala.reflect.api.Position]].
   *  @group Positions
   */
  type Position >: Null <: AnyRef with scala.reflect.api.Position { type Pos = Position }

  /** A special "missing" position.
   *  @group Positions
   */
  val NoPosition: Position

  /** Assigns a given position to all position-less nodes of a given AST.
   *  @group Positions
   */
  def atPos[T <: Tree](pos: Position)(tree: T): T

  /** A position that wraps a set of trees.
   *  The point of the wrapping position is the point of the default position.
   *  If some of the trees are ranges, returns a range position enclosing all ranges
   *  Otherwise returns default position.
   *  @group Positions
   */
  def wrappingPos(default: Position, trees: List[Tree]): Position

  /** A position that wraps the non-empty set of trees.
   *  The point of the wrapping position is the point of the first trees' position.
   *  If all some the trees are non-synthetic, returns a range position enclosing the non-synthetic trees
   *  Otherwise returns a synthetic offset position to point.
   *  @group Positions
   */
  def wrappingPos(trees: List[Tree]): Position
}

Other Scala source code examples

Here is a short list of links related to this Scala Positions.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.