Class 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 org.eclipse.lsp4j.Range NO_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
    • Field Detail

      • NO_RANGE

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

      • AbstractLSPErrorReporter

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

      • 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)
      • 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)