Search in sources :

Example 1 with TestErrorReporter

use of com.intellij.xml.actions.validate.TestErrorReporter in project intellij-community by JetBrains.

the class XmlConstraintsTest method getXSModel.

private XSModel getXSModel(String... files) {
    myFixture.configureByFiles(files);
    XmlFile file = (XmlFile) myFixture.getFile();
    ValidateXmlActionHandler handler = new ValidateXmlActionHandler(false) {

        @Override
        protected SAXParser createParser() throws SAXException, ParserConfigurationException {
            SAXParser parser = super.createParser();
            parser.getXMLReader().setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE, true);
            return parser;
        }
    };
    handler.setErrorReporter(new TestErrorReporter(handler));
    handler.doValidate(file);
    XMLGrammarPool grammarPool = ValidateXmlActionHandler.getGrammarPool(file);
    assert grammarPool != null;
    Grammar[] grammars = grammarPool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
    XSGrammar grammar = (XSGrammar) grammars[0];
    return grammar.toXSModel();
}
Also used : XMLGrammarPool(org.apache.xerces.xni.grammars.XMLGrammarPool) TestErrorReporter(com.intellij.xml.actions.validate.TestErrorReporter) XmlFile(com.intellij.psi.xml.XmlFile) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar) SAXParser(javax.xml.parsers.SAXParser) ValidateXmlActionHandler(com.intellij.xml.actions.validate.ValidateXmlActionHandler) Grammar(org.apache.xerces.xni.grammars.Grammar) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar)

Aggregations

XmlFile (com.intellij.psi.xml.XmlFile)1 TestErrorReporter (com.intellij.xml.actions.validate.TestErrorReporter)1 ValidateXmlActionHandler (com.intellij.xml.actions.validate.ValidateXmlActionHandler)1 SAXParser (javax.xml.parsers.SAXParser)1 Grammar (org.apache.xerces.xni.grammars.Grammar)1 XMLGrammarPool (org.apache.xerces.xni.grammars.XMLGrammarPool)1 XSGrammar (org.apache.xerces.xni.grammars.XSGrammar)1