use of org.apache.xerces.xs.XSModel in project intellij-community by JetBrains.
the class XmlConstraintsTest method testXercesGrammar.
public void testXercesGrammar() throws Exception {
XSModel xsModel = getXSModel("test.xml", "test.xsd");
XSElementDeclaration elementDeclaration = xsModel.getElementDeclaration("a", "");
XSComplexTypeDefinition typeDefinition = (XSComplexTypeDefinition) elementDeclaration.getTypeDefinition();
CMBuilder cmBuilder = new CMBuilder(new CMNodeFactory());
XSCMValidator validator = cmBuilder.getContentModel((XSComplexTypeDecl) typeDefinition, true);
int[] ints = validator.startContentModel();
Vector vector = validator.whatCanGoHere(ints);
XSElementDecl o = (XSElementDecl) vector.get(0);
assertEquals("b", o.getName());
}
use of org.apache.xerces.xs.XSModel in project intellij-community by JetBrains.
the class XmlConstraintsTest method testXercesForCompletion.
public void testXercesForCompletion() throws Exception {
XSModel xsModel = getXSModel("testCompletion.xml", "test.xsd");
PsiElement element = myFixture.getFile().findElementAt(getEditor().getCaretModel().getOffset());
XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
assert tag != null;
XSElementDeclaration elementDeclaration = xsModel.getElementDeclaration(tag.getLocalName(), tag.getNamespace());
XSComplexTypeDefinition typeDefinition = (XSComplexTypeDefinition) elementDeclaration.getTypeDefinition();
CMBuilder cmBuilder = new CMBuilder(new CMNodeFactory());
XSCMValidator validator = cmBuilder.getContentModel((XSComplexTypeDecl) typeDefinition, true);
int[] ints = validator.startContentModel();
Vector vector = validator.whatCanGoHere(ints);
XSElementDecl o = (XSElementDecl) vector.get(0);
assertEquals("b", o.getName());
}
use of org.apache.xerces.xs.XSModel in project intellij-community by JetBrains.
the class XsContentDFA method createContentDFA.
@Nullable
public static XmlContentDFA createContentDFA(@NotNull XmlTag parentTag) {
final PsiFile file = parentTag.getContainingFile().getOriginalFile();
if (!(file instanceof XmlFile))
return null;
XSModel xsModel = ApplicationManager.getApplication().runReadAction(new NullableComputable<XSModel>() {
@Override
public XSModel compute() {
return getXSModel((XmlFile) file);
}
});
if (xsModel == null) {
return null;
}
XSElementDeclaration decl = getElementDeclaration(parentTag, xsModel);
if (decl == null) {
return null;
}
return new XsContentDFA(decl, parentTag);
}
use of org.apache.xerces.xs.XSModel in project intellij-community by JetBrains.
the class XmlConstraintsTest method testXercesIncomplete.
public void testXercesIncomplete() throws Exception {
XSModel xsModel = getXSModel("testIncomplete.xml", "test.xsd");
XSElementDeclaration elementDeclaration = xsModel.getElementDeclaration("a", "");
XSComplexTypeDefinition typeDefinition = (XSComplexTypeDefinition) elementDeclaration.getTypeDefinition();
CMBuilder cmBuilder = new CMBuilder(new CMNodeFactory());
XSCMValidator validator = cmBuilder.getContentModel((XSComplexTypeDecl) typeDefinition, true);
int[] ints = validator.startContentModel();
Vector vector = validator.whatCanGoHere(ints);
XSElementDecl o = (XSElementDecl) vector.get(0);
assertEquals("b", o.getName());
}
Aggregations