use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class MavenDomGutterAnnotator method annotateMavenDomPlugin.
private static void annotateMavenDomPlugin(@NotNull MavenDomPlugin plugin, @NotNull AnnotationHolder holder) {
XmlTag xmlTag = plugin.getArtifactId().getXmlTag();
if (xmlTag == null)
return;
DomElement plugins = plugin.getParent();
if (plugins == null)
return;
DomElement parent = plugins.getParent();
if (parent instanceof MavenDomPluginManagement) {
annotateMavenDomPluginInManagement(plugin, holder);
return;
}
MavenDomPlugin managingPlugin = MavenDomProjectProcessorUtils.searchManagingPlugin(plugin);
if (managingPlugin != null) {
NavigationGutterIconBuilder<MavenDomPlugin> iconBuilder = NavigationGutterIconBuilder.create(AllIcons.General.OverridingMethod, PluginConverter.INSTANCE);
iconBuilder.setTargets(Collections.singletonList(managingPlugin)).setTooltipText(MavenDomBundle.message("overriden.plugin.title")).install(holder, xmlTag);
}
}
use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class DomElementsGroupNode method hasErrors.
private boolean hasErrors() {
if (!myParentElement.isValid())
return false;
for (DomElement domElement : myChildDescription.getStableValues(myParentElement)) {
final DomElementAnnotationsManager annotationsManager = DomElementAnnotationsManager.getInstance(getProject());
final DomElementsProblemsHolder holder = annotationsManager.getCachedProblemHolder(domElement);
final List<DomElementProblemDescriptor> problems = holder.getProblems(domElement, true, HighlightSeverity.ERROR);
if (problems.size() > 0)
return true;
}
return false;
}
use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class RemoveDomElementQuickFix method applyFix.
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
if (myIsTag) {
final XmlTag tag = (XmlTag) descriptor.getPsiElement();
final XmlTag parentTag = tag.getParentTag();
final DomElement domElement = DomManager.getDomManager(project).getDomElement(tag);
assert domElement != null;
domElement.undefine();
if (parentTag != null && parentTag.isValid()) {
parentTag.collapseIfEmpty();
}
} else {
final DomElement domElement = DomManager.getDomManager(project).getDomElement((XmlAttribute) descriptor.getPsiElement());
assert domElement != null;
domElement.undefine();
}
}
use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class AbstractDomChildrenDescriptor method getElementDescriptor.
@Override
@Nullable
public XmlElementDescriptor getElementDescriptor(@NotNull final XmlTag childTag, @Nullable XmlTag contextTag) {
DomElement domElement = myManager.getDomElement(childTag);
if (domElement == null) {
domElement = myManager.getDomElement(contextTag);
if (domElement != null) {
AbstractDomChildrenDescription description = myManager.findChildrenDescription(childTag, domElement);
if (description instanceof DomChildrenDescription) {
return new DomElementXmlDescriptor((DomChildrenDescription) description, myManager);
}
}
return null;
}
final DomElement parent = domElement.getParent();
if (parent == null)
return new DomElementXmlDescriptor(domElement);
final AbstractDomChildrenDescription description = domElement.getChildDescription();
if (description instanceof CustomDomChildrenDescription) {
final DomElement finalDomElement = domElement;
return new AbstractDomChildrenDescriptor(myManager) {
@Override
public String getDefaultName() {
return finalDomElement.getXmlElementName();
}
@Override
@Nullable
public PsiElement getDeclaration() {
final PomTarget target = ((CustomDomChildrenDescription) description).getTagNameDescriptor().findDeclaration(finalDomElement);
if (target == description) {
return childTag;
}
return target == null ? null : PomService.convertToPsi(childTag.getProject(), target);
}
};
}
if (!(description instanceof DomChildrenDescription))
return null;
return new DomElementXmlDescriptor((DomChildrenDescription) description, myManager);
}
use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class AbstractDomChildrenDescriptor method getElementsDescriptors.
@Override
public XmlElementDescriptor[] getElementsDescriptors(final XmlTag context) {
final DomElement domElement = myManager.getDomElement(context);
if (domElement == null)
return EMPTY_ARRAY;
List<XmlElementDescriptor> xmlElementDescriptors = new ArrayList<>();
for (DomCollectionChildDescription childrenDescription : domElement.getGenericInfo().getCollectionChildrenDescriptions()) {
xmlElementDescriptors.add(new DomElementXmlDescriptor(childrenDescription, myManager));
}
for (DomFixedChildDescription childrenDescription : domElement.getGenericInfo().getFixedChildrenDescriptions()) {
xmlElementDescriptors.add(new DomElementXmlDescriptor(childrenDescription, myManager));
}
final List<? extends CustomDomChildrenDescription> customs = domElement.getGenericInfo().getCustomNameChildrenDescription();
for (final CustomDomChildrenDescription custom : customs) {
final CustomDomChildrenDescription.TagNameDescriptor tagNameDescriptor = custom.getTagNameDescriptor();
if (tagNameDescriptor == null)
continue;
final XmlTag xmlTag = domElement.getXmlTag();
for (final EvaluatedXmlName name : tagNameDescriptor.getCompletionVariants(domElement)) {
AbstractDomChildrenDescriptor descriptor = new AbstractDomChildrenDescriptor(myManager) {
@Override
public String getDefaultName() {
final String ns = xmlTag != null ? name.getNamespace(xmlTag, (XmlFile) xmlTag.getContainingFile()) : null;
if (ns != null) {
final String prefix = xmlTag.getPrefixByNamespace(ns);
if (prefix != null) {
return prefix + ":" + name.getXmlName().getLocalName();
}
}
return name.getXmlName().getLocalName();
}
@Override
@Nullable
public PsiElement getDeclaration() {
final PomTarget target = tagNameDescriptor.findDeclaration(domElement, name);
return target == null ? null : PomService.convertToPsi(context.getProject(), target);
}
};
xmlElementDescriptors.add(descriptor);
}
xmlElementDescriptors.add(new AnyXmlElementDescriptor(this, getNSDescriptor()));
}
return xmlElementDescriptors.toArray(new XmlElementDescriptor[xmlElementDescriptors.size()]);
}
Aggregations