Search in sources :

Example 11 with MavenDomDependency

use of org.jetbrains.idea.maven.dom.model.MavenDomDependency in project intellij-community by JetBrains.

the class MavenNavigationUtil method findDependency.

@Nullable
public static MavenDomDependency findDependency(@NotNull MavenDomProjectModel projectDom, final String groupId, final String artifactId) {
    MavenDomProjectProcessorUtils.SearchProcessor<MavenDomDependency, MavenDomDependencies> processor = new MavenDomProjectProcessorUtils.SearchProcessor<MavenDomDependency, MavenDomDependencies>() {

        @Nullable
        @Override
        protected MavenDomDependency find(MavenDomDependencies element) {
            for (MavenDomDependency dependency : element.getDependencies()) {
                if (Comparing.equal(groupId, dependency.getGroupId().getStringValue()) && Comparing.equal(artifactId, dependency.getArtifactId().getStringValue())) {
                    return dependency;
                }
            }
            return null;
        }
    };
    MavenDomProjectProcessorUtils.processDependencies(projectDom, processor);
    return processor.getResult();
}
Also used : MavenDomProjectProcessorUtils(org.jetbrains.idea.maven.dom.MavenDomProjectProcessorUtils) MavenDomDependencies(org.jetbrains.idea.maven.dom.model.MavenDomDependencies) MavenDomDependency(org.jetbrains.idea.maven.dom.model.MavenDomDependency) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with MavenDomDependency

use of org.jetbrains.idea.maven.dom.model.MavenDomDependency in project intellij-community by JetBrains.

the class MavenArtifactSearchDialog method setManagedDependencies.

public void setManagedDependencies(Collection<MavenDomDependency> managedDependencies) {
    myManagedDependenciesMap.clear();
    for (MavenDomDependency dependency : managedDependencies) {
        String groupId = dependency.getGroupId().getStringValue();
        String artifactId = dependency.getArtifactId().getStringValue();
        String version = dependency.getVersion().getStringValue();
        if (StringUtil.isNotEmpty(groupId) && StringUtil.isNotEmpty(artifactId) && StringUtil.isNotEmpty(version)) {
            myManagedDependenciesMap.put(Pair.create(groupId, artifactId), version);
        }
    }
}
Also used : MavenDomDependency(org.jetbrains.idea.maven.dom.model.MavenDomDependency)

Aggregations

MavenDomDependency (org.jetbrains.idea.maven.dom.model.MavenDomDependency)12 MavenDomProjectModel (org.jetbrains.idea.maven.dom.model.MavenDomProjectModel)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 XmlTag (com.intellij.psi.xml.XmlTag)3 LookupElement (com.intellij.codeInsight.lookup.LookupElement)2 Result (com.intellij.openapi.application.Result)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 PsiElement (com.intellij.psi.PsiElement)2 PsiFile (com.intellij.psi.PsiFile)2 DomElement (com.intellij.util.xml.DomElement)2 Nullable (org.jetbrains.annotations.Nullable)2 DependencyConflictId (org.jetbrains.idea.maven.dom.DependencyConflictId)2 ReformatCodeProcessor (com.intellij.codeInsight.actions.ReformatCodeProcessor)1 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 LookupElementDecorator (com.intellij.codeInsight.lookup.LookupElementDecorator)1 CaretModel (com.intellij.openapi.editor.CaretModel)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 Project (com.intellij.openapi.project.Project)1 NavigatableAdapter (com.intellij.pom.NavigatableAdapter)1 XmlCodeStyleSettings (com.intellij.psi.formatter.xml.XmlCodeStyleSettings)1