Class SourceCodeLocation.SourceCodePoint

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<SourceCodeLocation.SourceCodePoint>
    Enclosing class:
    SourceCodeLocation

    public static class SourceCodeLocation.SourceCodePoint
    extends java.lang.Object
    implements java.lang.Comparable<SourceCodeLocation.SourceCodePoint>, java.io.Serializable
    This describes a point in a string. A point is the location between two characters and is indicated by the character index of the immediately following character. For example, in the string "abc", point 0 refers to the location immediately before the 'a' and point 2 to the location before the 'c'.

    For convenience we also store the line number of the point (the line that contains the character following the point) and the index in that line. Both of these indices start at 1. The first line of a file is line 1 and the point before its first character has index 1 on line 1.

    The exact definition of lines depends on the language conventions and is best left for the parser to handle. If you want to display the text at that location, either use the character index or use the line number and the index in the line together with lines as they were split by the parser.

    It might happen that the source code point for something is not known. This is modeled by a point with the special value -1 for the character index. The line and the index on the line must be 0 in this case.

    Instances of this class are immutable.

    See Also:
    Serialized Form
    • Method Detail

      • equals

        public boolean equals​(@Nullable
                              java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object