Package source

Class SourceSpan


  • public final class SourceSpan
    extends java.lang.Object
    The SourceSpan class is used to store information about the location of Expression and Statement objects relative to the source code.

    It holds information about the start index, end index, and total length of each line.

    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      SourceSpan​(int start, int length)
      Constructs a SourceSpan object for storing information about each Expression or Statements location.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static SourceSpan inRange​(int start, int end)
      Creates and returns a SourceSpan object for storing information about each Expression or Statements location.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SourceSpan

        public SourceSpan​(int start,
                          int length)
        Constructs a SourceSpan object for storing information about each Expression or Statements location.

        The end index is automatically calculated by adding the start and length together.

        Parameters:
        start - The start index of the span, relative to the source code
        length - The length of the span
    • Method Detail

      • inRange

        public static SourceSpan inRange​(int start,
                                         int end)
        Creates and returns a SourceSpan object for storing information about each Expression or Statements location.

        This method differs from the SourceSpan constructor as it allows for the creation of an instance where the end index can be manually defined.

        Parameters:
        start - The start index of the span, relative to the source code
        end - The end index of the span, relative to the source code
        Returns:
        A SourceSpan object