Class SourceLocationUtils


  • public final class SourceLocationUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static SourceLocation javaLocation()
      Returns the source code location of the caller.
      static java.lang.String stackTraceForm​(SourceLocation sourceLocation)
      Prints a source location in "stack trace form": `filename:linenumber`.
      • Methods inherited from class java.lang.Object

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

      • javaLocation

        public static SourceLocation javaLocation()
        Returns the source code location of the caller. This is very helpful when determining where rules generated from Java-based builders originated.

        Library-local and JDK stack frames are discarded. If no relevant location can be found, `SourceLocation.none()` is returned.

        Returns:
        The SourceLocation.
      • stackTraceForm

        public static java.lang.String stackTraceForm​(SourceLocation sourceLocation)
        Prints a source location in "stack trace form": `filename:linenumber`.
        Parameters:
        sourceLocation - Source location to print
        Returns:
        formatted source location