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.XMLErrorReporterThe SAXErrorHandlergives 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.RangeNO_RANGE
-
Constructor Summary
Constructors Constructor Description AbstractLSPErrorReporter(String source, DOMDocument xmlDocument, List<org.eclipse.lsp4j.Diagnostic> diagnostics, boolean hasRelatedInfo)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description org.eclipse.lsp4j.DiagnosticaddDiagnostic(org.eclipse.lsp4j.Range adjustedRange, String message, org.eclipse.lsp4j.DiagnosticSeverity severity, String code, List<org.eclipse.lsp4j.DiagnosticRelatedInformation> relatedInformation)protected org.eclipse.lsp4j.RangecreateDefaultRange(org.apache.xerces.xni.XMLLocator location, DOMDocument document)protected StringgetCode(String domain, String key, Object[] arguments, Exception exception)protected DOMDocumentgetDOMDocument()Returns the DOM document which is validating.protected StringgetMessage(String domain, String key, Object[] arguments, Exception exception)protected org.eclipse.lsp4j.DiagnosticSeveritygetSeverity(String domain, String key, Object[] arguments, short severity, Exception exception)static booleaninitializeReporter(org.apache.xerces.impl.xs.XMLSchemaLoader schemaLoader, org.apache.xerces.impl.XMLErrorReporter reporter, org.apache.xerces.impl.XMLEntityManager entityManager)static booleaninitializeReporter(org.apache.xerces.impl.xs.XMLSchemaValidator schemaValidator, org.apache.xerces.impl.XMLErrorReporter reporter, org.apache.xerces.impl.XMLEntityManager entityManager)protected booleanisIgnoreFatalError(String key)StringreportError(org.apache.xerces.xni.XMLLocator location, String domain, String key, Object[] arguments, short severity, Exception exception)voidsetCurrentError(Exception currentError)protected abstract org.eclipse.lsp4j.RangetoLSPRange(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_RANGEif 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
-
-
-
-
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:
reportErrorin classorg.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_RANGEif 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)
-
-