use of org.jetbrains.idea.maven.dom.model.MavenDomParent in project intellij-community by JetBrains.
the class MavenRedundantGroupIdInspection method checkFile.
@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (file instanceof XmlFile && (file.isPhysical() || ApplicationManager.getApplication().isUnitTestMode())) {
DomFileElement<MavenDomProjectModel> model = DomManager.getDomManager(file.getProject()).getFileElement((XmlFile) file, MavenDomProjectModel.class);
if (model != null) {
MavenDomProjectModel projectModel = model.getRootElement();
String groupId = projectModel.getGroupId().getStringValue();
if (groupId != null && groupId.length() > 0) {
MavenDomParent parent = projectModel.getMavenParent();
String parentGroupId = parent.getGroupId().getStringValue();
if (groupId.equals(parentGroupId)) {
XmlTag xmlTag = projectModel.getGroupId().getXmlTag();
LocalQuickFix fix = new LocalQuickFixBase("Remove unnecessary <groupId>") {
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
descriptor.getPsiElement().delete();
}
};
return new ProblemDescriptor[] { manager.createProblemDescriptor(xmlTag, "Definition of groupId is redundant, because it's inherited from the parent", fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly) };
}
}
}
}
return null;
}
Aggregations