Class CrossSourceErrors

java.lang.Object
org.ek9lang.compiler.support.CrossSourceErrors

public final class CrossSourceErrors extends Object
THE emission of a diagnostic raised by a whole-program analysis, which finds its error listener by LOOKING UP the source its token belongs to (call-graph detectors, the deadlock check, construction recursion, injection reachability). The lookup can miss - a source-name form nobody anticipated - and a miss must never swallow the error: "if it compiles, it is free of this" would silently stop being true. So an unresolved listener is a hard internal error naming the place and the code (front-end rationalisation D-4: the deadlock check threw, five other emitters returned quietly - the very drop the deadlock check's own javadoc calls the original defect).
  • Method Details

    • emit

      public static void emit(ErrorListener errorListener, IToken location, String message, ErrorListener.SemanticClassification classification)
      Report the diagnostic through the listener of the token's source.
      Parameters:
      errorListener - the listener the lookup found, or null when it found none
      location - the token the diagnostic is reported on
      message - the diagnostic's text
      classification - what it is
      Throws:
      CompilerException - when no listener was found
    • listenerOrThrow

      public static ErrorListener listenerOrThrow(ErrorListener errorListener, IToken location, String what)
      The listener, or a hard internal error saying which diagnostic would have been dropped and where.
      Parameters:
      errorListener - the listener the lookup found, or null
      location - where the diagnostic was to be reported (may be null)
      what - what was to be reported - normally its error code