public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { GenericDomValue el = (GenericDomValue) myContext.getInvocationElement(); MavenId id = MavenArtifactCoordinatesHelper.getId(myContext); MavenProjectsManager manager = MavenProjectsManager.getInstance(project); MavenProject parentFile = manager.findProject(id); if (parentFile != null) { VirtualFile currentFile = myContext.getFile().getVirtualFile(); el.setStringValue( MavenDomUtil.calcRelativePath(currentFile.getParent(), parentFile.getFile())); } }
@Nullable public static XmlElement getValueElement(GenericDomValue domValue) { if (domValue instanceof GenericAttributeValue) { final GenericAttributeValue value = (GenericAttributeValue) domValue; final XmlAttributeValue attributeValue = value.getXmlAttributeValue(); return attributeValue == null ? value.getXmlAttribute() : attributeValue; } else { return domValue.getXmlTag(); } }
public static List<? extends DomElement> getIdentitySiblings(DomElement element) { final GenericDomValue nameDomElement = element.getGenericInfo().getNameDomElement(element); if (nameDomElement == null) return Collections.emptyList(); final NameValue nameValue = nameDomElement.getAnnotation(NameValue.class); if (nameValue == null || !nameValue.unique()) return Collections.emptyList(); final String stringValue = ElementPresentationManager.getElementName(element); if (stringValue == null) return Collections.emptyList(); final DomElement scope = element.getManager().getIdentityScope(element); if (scope == null) return Collections.emptyList(); final DomGenericInfo domGenericInfo = scope.getGenericInfo(); final String tagName = element.getXmlElementName(); final DomCollectionChildDescription childDescription = domGenericInfo.getCollectionChildDescription(tagName, element.getXmlElementNamespaceKey()); if (childDescription != null) { final ArrayList<DomElement> list = new ArrayList<>(childDescription.getValues(scope)); list.remove(element); return list; } return Collections.emptyList(); }