use of org.jetbrains.idea.maven.dom.model.MavenDomProjectModel in project intellij-community by JetBrains.
the class MavenSourceDirectoryConverter method isSoft.
@Override
public boolean isSoft(@NotNull DomElement element) {
DomElement buildElement = element.getParent();
if (!(buildElement instanceof MavenDomBuild)) {
return false;
}
DomElement mavenProject = buildElement.getParent();
if (!(mavenProject instanceof MavenDomProjectModel)) {
return false;
}
return "pom".equals(((MavenDomProjectModel) mavenProject).getPackaging().getStringValue());
}
use of org.jetbrains.idea.maven.dom.model.MavenDomProjectModel in project intellij-community by JetBrains.
the class MavenDuplicatePluginInspection method checkFileElement.
@Override
public void checkFileElement(DomFileElement<MavenDomProjectModel> domFileElement, DomElementAnnotationHolder holder) {
MavenDomProjectModel projectModel = domFileElement.getRootElement();
MultiMap<Pair<String, String>, MavenDomPlugin> duplicates = MultiMap.createSet();
for (MavenDomPlugin plugin : projectModel.getBuild().getPlugins().getPlugins()) {
String groupId = plugin.getGroupId().getStringValue();
String artifactId = plugin.getArtifactId().getStringValue();
if (StringUtil.isEmptyOrSpaces(artifactId))
continue;
if ("".equals(groupId) || "org.apache.maven.plugins".equals(groupId) || "org.codehaus.mojo".equals(groupId)) {
groupId = null;
}
duplicates.putValue(Pair.create(groupId, artifactId), plugin);
}
for (Map.Entry<Pair<String, String>, Collection<MavenDomPlugin>> entry : duplicates.entrySet()) {
Collection<MavenDomPlugin> set = entry.getValue();
if (set.size() <= 1)
continue;
for (MavenDomPlugin dependency : set) {
holder.createProblem(dependency, HighlightSeverity.WARNING, "Duplicated plugin declaration");
}
}
}
use of org.jetbrains.idea.maven.dom.model.MavenDomProjectModel 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;
}
use of org.jetbrains.idea.maven.dom.model.MavenDomProjectModel in project intellij-community by JetBrains.
the class ExtractManagedDependenciesAction method findDependencyAndParent.
private static Pair<MavenDomDependency, Set<MavenDomProjectModel>> findDependencyAndParent(PsiFile file, Editor editor) {
final MavenDomDependency dependency = DomUtil.findDomElement(file.findElementAt(editor.getCaretModel().getOffset()), MavenDomDependency.class);
if (dependency == null || isManagedDependency(dependency))
return null;
Set<MavenDomProjectModel> parents = getParentProjects(file);
if (parents.isEmpty())
return null;
return Pair.create(dependency, parents);
}
use of org.jetbrains.idea.maven.dom.model.MavenDomProjectModel in project intellij-community by JetBrains.
the class SelectMavenProjectDialog method updateControls.
private void updateControls() {
MavenDomProjectModel project = getSelectedProject();
Integer count = myOccurrencesCountFunction.fun(project).size();
myReplaceAllCheckBox.setText(RefactoringBundle.message("replace.all.occurences", count));
myReplaceAllCheckBox.setEnabled(count != 0);
}
Aggregations