use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.
the class DomAnchorImpl method diagnoseNegativeIndex2.
private static <T extends DomElement> void diagnoseNegativeIndex2(T t, DomElement parent, AbstractDomChildrenDescription description, List<? extends DomElement> values) {
final XmlTag parentTag = parent.getXmlTag();
StringBuilder diag = new StringBuilder("Index<0: description=" + description + "\nparent=" + parent + "\nt=" + t + "\nvalues=" + values + "\n");
for (int i = 0, size = values.size(); i < size; i++) {
DomElement value = values.get(i);
if (value.toString().equals(t.toString())) {
final XmlElement tElement = t.getXmlElement();
final XmlElement valElement = value.getXmlElement();
diag.append(" hasSame, i=" + i + "; same=" + (value == t) + ", equal=" + value.equals(t) + ", equal2=" + t.equals(value) + ", t.physical=" + (tElement == null ? "null" : String.valueOf(tElement.isPhysical())) + ", value.physical=" + (valElement == null ? "null" : String.valueOf(valElement.isPhysical())) + ", sameElements=" + (tElement == value.getXmlElement()) + "\n");
if (tElement != null && valElement != null) {
diag.append(" sameFile=" + (tElement.getContainingFile() == valElement.getContainingFile()) + ", sameParent=" + (tElement.getParent() == valElement.getParent()) + "\n");
}
}
}
if (parentTag != null) {
diag.append("Parent tag: ").append(parentTag.getName()).append("\n");
if (t instanceof GenericAttributeValue) {
for (XmlAttribute attribute : parentTag.getAttributes()) {
diag.append(", attr: ").append(attribute.getName());
}
diag.append("\n");
} else {
for (XmlTag tag : parentTag.getSubTags()) {
diag.append("\n subtag: ").append(tag.getName());
}
diag.append("\n");
}
}
diag.append("Child name: ").append(t.getXmlElementName()).append(";").append(t.getXmlElementNamespaceKey());
LOG.error(diag);
}
use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.
the class DomElementAnnotationHolderImpl method createAnnotation.
@Override
@NotNull
public Annotation createAnnotation(@NotNull DomElement element, HighlightSeverity severity, @Nullable String message) {
final XmlElement xmlElement = element.getXmlElement();
LOG.assertTrue(xmlElement != null, "No XML element for " + element);
final TextRange range = xmlElement.getTextRange();
final int startOffset = range.getStartOffset();
final int endOffset = message == null ? startOffset : range.getEndOffset();
final Annotation annotation = new Annotation(startOffset, endOffset, severity, message, null);
myAnnotations.add(annotation);
return annotation;
}
use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.
the class GoToSymbolProvider method createNavigationItem.
@Nullable
protected static NavigationItem createNavigationItem(final DomElement domElement) {
final GenericDomValue name = domElement.getGenericInfo().getNameDomElement(domElement);
assert name != null;
final XmlElement psiElement = name.getXmlElement();
final String value = name.getStringValue();
if (psiElement == null || value == null) {
return null;
}
final Icon icon = ElementPresentationManager.getIcon(domElement);
return createNavigationItem(psiElement, value, icon);
}
use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.
the class DomInvocationHandler method getXmlElementNamespace.
@Override
@NotNull
public String getXmlElementNamespace() {
final DomInvocationHandler parent = getParentHandler();
assert parent != null : "this operation should be performed on the DOM having a physical parent, your DOM may be not very fresh";
final XmlElement element = parent.getXmlElement();
assert element != null;
return getXmlName().getNamespace(element, getFile());
}
use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.
the class DomInvocationHandler method checkValidity.
@Nullable
protected String checkValidity() {
ProgressManager.checkCanceled();
final DomParentStrategy parentStrategy = getParentStrategy();
String error = parentStrategy.checkValidity();
if (error != null) {
return "Strategy: " + error;
}
final long modCount = myManager.getPsiModificationCount();
if (myLastModCount == modCount) {
return null;
}
final XmlElement xmlElement = parentStrategy.getXmlElement();
if (xmlElement != null) {
final DomInvocationHandler actual = myManager.getDomHandler(xmlElement);
if (!equals(actual)) {
return "element changed: " + this.toStringEx() + "!=" + (actual == null ? null : actual.toStringEx());
}
myLastModCount = modCount;
return null;
}
final DomInvocationHandler parent = getParentHandler();
if (parent == null) {
return "no parent: " + getDomElementType();
}
error = parent.checkValidity();
if (error != null) {
return "parent: " + error;
}
myLastModCount = modCount;
return null;
}
Aggregations