use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class DomHighlightingLiteTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myInspectionProfile = new MockInspectionProfile();
myAnnotationsManager = new DomElementAnnotationsManagerImpl(getProject()) {
@Override
protected InspectionProfile getInspectionProfile(final DomFileElement fileElement) {
return myInspectionProfile;
}
};
final XmlFile file = createXmlFile("<a/>");
final MockDomElement rootElement = new MockDomElement() {
@Override
@Nullable
public XmlElement getXmlElement() {
return getXmlTag();
}
@Override
public XmlTag getXmlTag() {
return file.getRootTag();
}
@NotNull
@Override
public Type getDomElementType() {
return DomElement.class;
}
};
myElement = new MockDomFileElement() {
@Override
@Nullable
public XmlElement getXmlElement() {
return file;
}
@Override
@NotNull
public XmlFile getFile() {
return file;
}
@Override
public DomElement getParent() {
return null;
}
@Override
@NotNull
public DomElement getRootElement() {
return rootElement;
}
@NotNull
@Override
public Class getRootElementClass() {
return DomElement.class;
}
@Override
public boolean isValid() {
return true;
}
};
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class DomIncludesTest method testNavigationToIncluded.
public void testNavigationToIncluded() throws Throwable {
final MyElement rootElement = createDomFile("a.xml", "<root xmlns:xi=\"http://www.w3.org/2001/XInclude\">" + "<xi:include href=\"b.xml\" xpointer=\"xpointer(/xxx/*)\"/>" + "<child ref=\"b\"/>" + "</root>");
final XmlFile includedFile = (XmlFile) createFile("b.xml", "<xxx><child xxx=\"b\"/></xxx>");
final List<Child> children = rootElement.getChildren();
final MyElement domTarget = children.get(0);
final GenericAttributeValue<Child> ref = children.get(1).getRef();
final MyElement value = ref.getValue();
assertEquals(domTarget, value);
myFixture.configureFromTempProjectFile("a.xml");
final int offset = ref.getXmlAttributeValue().getTextRange().getStartOffset() + 1;
myFixture.getEditor().getCaretModel().moveToOffset(offset);
final PsiElement target = GotoDeclarationAction.findTargetElement(getProject(), myFixture.getEditor(), offset);
PsiElement element = ((DomTarget) ((PomTargetPsiElement) target).getTarget()).getNavigationElement();
// assertSame(PomService.convertToPsi(DomTarget.getTarget(domTarget)), target);
assertSame(includedFile.getDocument().getRootTag().getSubTags()[0].getAttributes()[0].getValueElement(), element);
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class DomAnnotationsTest method createElement.
@Override
protected <T extends DomElement> T createElement(final String xml, final Class<T> aClass) {
final String name = "a.xml";
final XmlFile file = (XmlFile) PsiFileFactory.getInstance(getProject()).createFileFromText(name, StdFileTypes.XML, xml, 0, true);
final XmlTag tag = file.getDocument().getRootTag();
final String rootTagName = tag != null ? tag.getName() : "root";
final T element = getDomManager().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 DomConcurrencyStressTest method testInternalDomLocksReadConsistency.
public void testInternalDomLocksReadConsistency() throws Throwable {
getDomManager().registerFileDescription(new DomFileDescription(MyElement.class, "a"), getTestRootDisposable());
registerExtender(MyElement.class, MyExtender.class);
final XmlFile file = createXmlFile("<a attr=\"1\" attr2=\"2\">" + "<foo-child><foo-child/><custom-foo/></foo-child>" + "<bar-child><foo-child/></bar-child>" + "<foo-element>" + " <foo-child/>" + " <foo-child><foo-child attr=\"\"/></foo-child>" + " <custom-foo/>" + " <custom-bar/>" + "</foo-element>" + "<custom-bar/>" + "<custom-bar>" + " <foo-child/>" + " <foo-element/>" + " <foo-element/>" + " <custom-bar/>" + "</custom-bar>" + "<custom-bar attr=\"\">" + " <foo-child/>" + " <some-child/>" + " <custom-bar/>" + "</custom-bar>" + "<child/>" + "<child/>" + "<bool/>" + "</a>");
System.out.println("ITERATIONS =" + ITERATIONS);
runThreads(42, new Runnable() {
@Override
public void run() {
for (int i = 0; i < ITERATIONS; i++) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
final DomFileElementImpl<DomElement> element = getDomManager().getFileElement(file);
assertNotNull(element);
element.getRootElement().accept(new DomElementVisitor() {
@Override
public void visitDomElement(final DomElement element) {
if (DomUtil.hasXml(element)) {
element.acceptChildren(this);
}
}
});
}
});
SemService.getSemService(getProject()).clearCache();
}
}
});
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class DomFileDescriptionTest method testDependantFileDescriptionCauseStackOverflow.
public void testDependantFileDescriptionCauseStackOverflow() throws Throwable {
final XmlFile interestingFile = (XmlFile) createFile("a.xml", "<b>42</b>");
getDomManager().registerFileDescription(new MockDomFileDescription<>(MyElement.class, "b", (XmlFile) null), myDisposable);
for (int i = 0; i < 239; i++) {
getDomManager().registerFileDescription(new MockDomFileDescription<AbstractElement>(AbstractElement.class, "b", (XmlFile) null) {
@Override
@NotNull
public Set getDependencyItems(final XmlFile file) {
getDomManager().isDomFile(interestingFile);
return super.getDependencyItems(file);
}
}, myDisposable);
}
getDomManager().isDomFile(interestingFile);
}
Aggregations