scala.tools.nsc.util

Position

trait Position extends AnyRef

The Position class and its subclasses represent positions of ASTs and symbols. Except for NoPosition and FakePos, every position refers to a SourceFile and to an offset in the sourcefile (its point'). For batch compilation, that's all. For interactive IDE's there are also RangePositions and TransparentPositions. A RangePosition indicates a start and an end in addition to its point. TransparentPositions are a subclass of RangePositions. Range positions that are not transparent are called opaque. Trees with RangePositions need to satisfy the following invariants.

INV1: A tree with an offset position never contains a child with a range position INV2: If the child of a tree with a range position also has a range position, then the child's range is contained in the parent's range. INV3: Opaque range positions of children of the same node are non-overlapping (this means their overlap is at most a single point).

The following tests are useful on positions:

pos.isDefined true if position is not a NoPosition nor a FakePosition pos.isRange true if position is a range pos.isOpaqueRange true if position is an opaque range

The following accessor methods are provided:

pos.source The source file of the position, which must be defined pos.point The offset of the position's point, which must be defined pos.start The start of the position, which must be a range pos.end The end of the position, which must be a range

There are also convenience methods, such as

pos.startOrPoint pos.endOrPoint pos.pointOrElse(default)

These are less strict about the kind of position on which they can be applied.

The following conversion methods are often used:

pos.focus converts a range position to an offset position, keeping its point; returns all other positions unchanged. pos.makeTransparent converts an opaque range position into a transparent one. returns all other positions unchanged.

Source
Position.scala
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Position
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. def column: Int

  9. def dbgString: String

  10. def end: Int

    The end of the position's range, error if not a range position

  11. def endOrPoint: Int

    The end of the position's range, or point if not a range position

  12. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  15. def focus: Position

    If this is a range position, the offset position of its point.

    If this is a range position, the offset position of its point. Otherwise the position itself

  16. def focusEnd: Position

    If this is a range position, the offset position of its end.

    If this is a range position, the offset position of its end. Otherwise the position itself

  17. def focusStart: Position

    If this is a range position, the offset position of its start.

    If this is a range position, the offset position of its start. Otherwise the position itself

  18. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  19. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  20. def inUltimateSource(source: SourceFile): Position

    Map this position to a position in an original source file.

    Map this position to a position in an original source file. If the SourceFile is a normal SourceFile, simply return this.

  21. def includes(pos: Position): Boolean

    Does this position include the given position pos.

    Does this position include the given position pos. This holds if this is a range position and its range [start..end] is the same or covers the range of the given position, which may or may not be a range position.

  22. def isDefined: Boolean

    Is this position neither a NoPosition nor a FakePosition? If isDefined is true, offset and source are both defined.

  23. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  24. def isOpaqueRange: Boolean

    Is this position a non-transparent range position?

  25. def isRange: Boolean

    Is this position a range position?

  26. def isTransparent: Boolean

    Is this position a transparent position?

  27. def line: Int

  28. def lineContent: String

  29. def makeTransparent: Position

    if opaque range, make this position transparent

  30. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  31. final def notify(): Unit

    Definition Classes
    AnyRef
  32. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  33. def overlaps(pos: Position): Boolean

    Does this position overlap with that position? This holds if both positions are ranges and there is an interval of non-zero length that is shared by both position ranges.

  34. def point: Int

    The point (where the ^ is) of the position

  35. def pointOrElse(default: Int): Int

    The point (where the ^ is) of the position, or else default' if undefined

  36. def precedes(pos: Position): Boolean

    Does this position precede that position? This holds if both positions are defined and the end point of this position is not larger than the start point of the given position.

  37. def properlyIncludes(pos: Position): Boolean

    Does this position properly include the given position pos ("properly" meaning their ranges are not the same)?

  38. def properlyPrecedes(pos: Position): Boolean

    Does this position properly precede the given position pos ("properly" meaning their ranges do not share a common point).

  39. def sameRange(pos: Position): Boolean

    Does this position cover the same range as that position? Holds only if both position are ranges

  40. def show: String

  41. def source: SourceFile

    An optional value containing the source file referred to by this position, or None if not defined.

  42. def start: Int

    The start of the position's range, error if not a range position

  43. def startOrPoint: Int

    The start of the position's range, or point if not a range position

  44. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  45. def toSingleLine: Position

    Convert this to a position around point that spans a single source line

  46. def toString(): String

    Definition Classes
    AnyRef → Any
  47. def union(pos: Position): Position

    If this is a range, the union with the other range, with the point of this position.

    If this is a range, the union with the other range, with the point of this position. Otherwise, this position

  48. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  49. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  50. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  51. def withEnd(off: Int): Position

    The same position with a different end value (if a range)

  52. def withPoint(off: Int): Position

    The same position with a different point value (if a range or offset)

  53. def withSource(source: SourceFile, shift: Int): Position

    The same position with a different source value, and its values shifted by given offset

  54. def withStart(off: Int): Position

    The same position with a different start value (if a range)

Deprecated Value Members

  1. def offset: Option[Int]

    Annotations
    @deprecated
    Deprecated

    (Since version 2.9.0) use point instead

Inherited from AnyRef

Inherited from Any