Class AbstractLSPErrorReporter

java.lang.Object
org.apache.xerces.impl.XMLErrorReporter
org.eclipse.lemminx.extensions.xerces.AbstractLSPErrorReporter
All Implemented Interfaces:
org.apache.xerces.xni.parser.XMLComponent
Direct Known Subclasses:
AbstractReferencedGrammarLSPErrorReporter

public abstract class AbstractLSPErrorReporter extends org.apache.xerces.impl.XMLErrorReporter
The SAX ErrorHandler gives just information of the offset where there is an error. To improve highlight XML error, this class extends the Xerces XML reporter to catch location, key, arguments which is helpful to adjust the LSP range.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final org.eclipse.lsp4j.Range
     

    Fields inherited from class org.apache.xerces.impl.XMLErrorReporter

    CONTINUE_AFTER_FATAL_ERROR, ERROR_HANDLER, fContinueAfterFatalError, fDefaultErrorHandler, fErrorHandler, fLocale, fLocator, fMessageFormatters, SEVERITY_ERROR, SEVERITY_FATAL_ERROR, SEVERITY_WARNING
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractLSPErrorReporter(String source, DOMDocument xmlDocument, List<org.eclipse.lsp4j.Diagnostic> diagnostics, boolean hasRelatedInfo)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.eclipse.lsp4j.Diagnostic
    addDiagnostic(org.eclipse.lsp4j.Range adjustedRange, String message, org.eclipse.lsp4j.DiagnosticSeverity severity, String code, List<org.eclipse.lsp4j.DiagnosticRelatedInformation> relatedInformation)
     
    protected org.eclipse.lsp4j.Range
    createDefaultRange(org.apache.xerces.xni.XMLLocator location, DOMDocument document)
     
    protected String
    getCode(String domain, String key, Object[] arguments, Exception exception)
     
    protected DOMDocument
    Returns the DOM document which is validating.
    protected String
    getMessage(String domain, String key, Object[] arguments, Exception exception)
     
    protected org.eclipse.lsp4j.DiagnosticSeverity
    getSeverity(String domain, String key, Object[] arguments, short severity, Exception exception)
     
    static boolean
    initializeReporter(org.apache.xerces.impl.xs.XMLSchemaLoader schemaLoader, org.apache.xerces.impl.XMLErrorReporter reporter, org.apache.xerces.impl.XMLEntityManager entityManager)
     
    static boolean
    initializeReporter(org.apache.xerces.impl.xs.XMLSchemaValidator schemaValidator, org.apache.xerces.impl.XMLErrorReporter reporter, org.apache.xerces.impl.XMLEntityManager entityManager)
     
    protected boolean
     
    reportError(org.apache.xerces.xni.XMLLocator location, String domain, String key, Object[] arguments, short severity, Exception exception)
     
    void
    setCurrentError(Exception currentError)
     
    protected abstract org.eclipse.lsp4j.Range
    toLSPRange(org.apache.xerces.xni.XMLLocator location, String key, Object[] arguments, String message, org.eclipse.lsp4j.DiagnosticSeverity diagnosticSeverity, boolean fatalError, DOMDocument document)
    Returns the range of the given error information, or {NO_RANGE if diagnostic must not be created and null otherwise.

    Methods inherited from class org.apache.xerces.impl.XMLErrorReporter

    getErrorHandler, getFeature, getFeatureDefault, getLocale, getMessageFormatter, getPropertyDefault, getRecognizedFeatures, getRecognizedProperties, getSAXErrorHandler, putMessageFormatter, removeMessageFormatter, reportError, reportError, reportError, reset, setDocumentLocator, setFeature, setLocale, setProperty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NO_RANGE

      protected static final org.eclipse.lsp4j.Range NO_RANGE
  • Constructor Details

    • AbstractLSPErrorReporter

      public AbstractLSPErrorReporter(String source, DOMDocument xmlDocument, List<org.eclipse.lsp4j.Diagnostic> diagnostics, boolean hasRelatedInfo)
  • Method Details

    • reportError

      public String reportError(org.apache.xerces.xni.XMLLocator location, String domain, String key, Object[] arguments, short severity, Exception exception) throws org.apache.xerces.xni.XNIException
      Overrides:
      reportError in class org.apache.xerces.impl.XMLErrorReporter
      Throws:
      org.apache.xerces.xni.XNIException
    • getSeverity

      protected org.eclipse.lsp4j.DiagnosticSeverity getSeverity(String domain, String key, Object[] arguments, short severity, Exception exception)
    • getMessage

      protected String getMessage(String domain, String key, Object[] arguments, Exception exception)
    • getCode

      protected String getCode(String domain, String key, Object[] arguments, Exception exception)
    • isIgnoreFatalError

      protected boolean isIgnoreFatalError(String key)
    • addDiagnostic

      public org.eclipse.lsp4j.Diagnostic addDiagnostic(org.eclipse.lsp4j.Range adjustedRange, String message, org.eclipse.lsp4j.DiagnosticSeverity severity, String code, List<org.eclipse.lsp4j.DiagnosticRelatedInformation> relatedInformation)
    • createDefaultRange

      protected org.eclipse.lsp4j.Range createDefaultRange(org.apache.xerces.xni.XMLLocator location, DOMDocument document)
    • toLSPRange

      protected abstract org.eclipse.lsp4j.Range toLSPRange(org.apache.xerces.xni.XMLLocator location, String key, Object[] arguments, String message, org.eclipse.lsp4j.DiagnosticSeverity diagnosticSeverity, boolean fatalError, DOMDocument document)
      Returns the range of the given error information, or {NO_RANGE if diagnostic must not be created and null otherwise.
      Parameters:
      location - the Xerces location.
      key - the Xerces error key.
      arguments - the Xerces error arguments.
      message - the Xerces error message.
      diagnosticSeverity - the the Xerces severity.
      fatalError - true if Xerces report the error as fatal and false otherwise.
      document - the DOM document.
      Returns:
    • getDOMDocument

      protected DOMDocument getDOMDocument()
      Returns the DOM document which is validating.
      Returns:
      the DOM document which is validating.
    • initializeReporter

      public static boolean initializeReporter(org.apache.xerces.impl.xs.XMLSchemaValidator schemaValidator, org.apache.xerces.impl.XMLErrorReporter reporter, org.apache.xerces.impl.XMLEntityManager entityManager)
    • initializeReporter

      public static boolean initializeReporter(org.apache.xerces.impl.xs.XMLSchemaLoader schemaLoader, org.apache.xerces.impl.XMLErrorReporter reporter, org.apache.xerces.impl.XMLEntityManager entityManager)
    • setCurrentError

      public void setCurrentError(Exception currentError)