use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class DomStubTest method prepareFile.
protected XmlFile prepareFile(String path) {
VirtualFile virtualFile = myFixture.copyFileToProject(path);
assertNotNull(virtualFile);
XmlFile file = (XmlFile) ((PsiManagerEx) getPsiManager()).getFileManager().findFile(virtualFile);
assertFalse(file.getNode().isParsed());
ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), virtualFile, file);
assertNotNull("Can't build stubs for " + path, tree);
((PsiManagerImpl) getPsiManager()).cleanupForNextTest();
file = (XmlFile) getPsiManager().findFile(virtualFile);
assertNotNull(file);
return file;
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class DomStubUsingTest method testFileLoading.
public void testFileLoading() {
XmlFile file = prepareFile("foo.xml");
((PsiManagerEx) getPsiManager()).setAssertOnFileLoadingFilter(VirtualFileFilter.ALL, myFixture.getTestRootDisposable());
DomFileElement<Foo> element = DomManager.getDomManager(getProject()).getFileElement(file, Foo.class);
assertNotNull(element);
GenericDomValue<String> id = element.getRootElement().getId();
assertEquals("foo", id.getValue());
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class DomTestCase method createElement.
public static <T extends DomElement> T createElement(final DomManager domManager, final String xml, final Class<T> aClass) throws IncorrectOperationException {
final String name = "a.xml";
final XmlFile file = (XmlFile) PsiFileFactory.getInstance(domManager.getProject()).createFileFromText(name, xml);
final XmlTag tag = file.getDocument().getRootTag();
final String rootTagName = tag != null ? tag.getName() : "root";
final T element = domManager.getFileElement(file, aClass, rootTagName).getRootElement();
assertNotNull(element);
assertSame(tag, element.getXmlTag());
return element;
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class TreeIncrementalUpdateTest method createPhysicalElement.
private MyElement createPhysicalElement(final String text) throws IncorrectOperationException {
final XmlFile file = (XmlFile) createFile("file.xml", text);
final DomFileElementImpl<MyElement> fileElement = getDomManager().getFileElement(file, MyElement.class, "a");
final MyElement rootElement = fileElement.getRootElement();
return rootElement;
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class DomNamespacesTest method testSpringUtilLike.
public void testSpringUtilLike() throws Throwable {
getDomManager().registerFileDescription(new DomFileDescription<MyBeans>(MyBeans.class, "beans", "beans", "util") {
@Override
protected void initializeFileDescription() {
super.initializeFileDescription();
registerNamespacePolicy("beans", "beans");
registerNamespacePolicy("util", "util");
}
}, getTestRootDisposable());
final XmlFile psiFile = createXmlFile("<beans xmlns=\"beans\" xmlns:util=\"util\">" + "<util:list>" + "<ref>aaa</ref>" + "<util:child>bbb</util:child>" + "</util:list></beans>");
final MyList listOrSet = assertInstanceOf(getDomManager().getFileElement(psiFile, MyBeans.class).getRootElement().getList(), MyList.class);
assertNotNull(listOrSet.getXmlTag());
final XmlTag listTag = psiFile.getDocument().getRootTag().findFirstSubTag("util:list");
assertNotNull(getDomManager().getDomElement(listTag.findFirstSubTag("ref")));
assertNotNull(getDomManager().getDomElement(listTag.findFirstSubTag("util:child")));
assertEquals("aaa", listOrSet.getRef().getValue());
assertEquals("bbb", listOrSet.getChild().getValue());
}
Aggregations