private void exclude() {
    final MavenArtifact artifactToExclude = mavenArtifactNode.getArtifact();
    final MavenArtifactNode oldestParent = getOldestParentMavenArtifact();

    DomFileElement domFileElement = getDomFileElement(oldestParent);

    if (domFileElement != null) {
      final MavenDomProjectModel rootElement =
          (MavenDomProjectModel) domFileElement.getRootElement();
      final MavenDomDependencies dependencies = rootElement.getDependencies();
      boolean found = false;

      for (MavenDomDependency mavenDomDependency : dependencies.getDependencies()) {
        if (isSameDependency(oldestParent.getArtifact(), mavenDomDependency)) {
          found = true;
          final MavenDomExclusions exclusions = mavenDomDependency.getExclusions();
          for (MavenDomExclusion mavenDomExclusion : exclusions.getExclusions()) {
            if (isSameDependency(artifactToExclude, mavenDomExclusion)) {
              return;
            }
          }
          createExclusion(artifactToExclude, exclusions);
          dependencyExcluded();
        }
      }
      if (!found) {
        final Notification notification =
            new Notification(
                MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION,
                "",
                "Parent dependency not found, it is probably in parent pom",
                NotificationType.WARNING);
        ApplicationManager.getApplication()
            .invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    Notifications.Bus.notify(notification, project);
                  }
                });
      }
    } else {
      final Notification notification =
          new Notification(
              MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION,
              "",
              "Pom file not found",
              NotificationType.WARNING);
      ApplicationManager.getApplication()
          .invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  Notifications.Bus.notify(notification, project);
                }
              });
    }
  }
  @NotNull
  public static MavenDomDependency createDomDependency(
      MavenDomDependencies dependencies, @Nullable Editor editor, @NotNull final MavenId id) {
    MavenDomDependency dep = createDomDependency(dependencies, editor);

    dep.getGroupId().setStringValue(id.getGroupId());
    dep.getArtifactId().setStringValue(id.getArtifactId());
    dep.getVersion().setStringValue(id.getVersion());

    return dep;
  }
    @NotNull
    @Override
    public String getText() {
      StringBuffer sb = new StringBuffer();

      append(sb, myDependency.getGroupId().getStringValue());
      append(sb, myDependency.getArtifactId().getStringValue());
      append(sb, myDependency.getVersion().getStringValue());

      return sb.toString();
    }
  @Nullable
  private static String createId(MavenDomDependency coordinates) {
    String groupId = coordinates.getGroupId().getStringValue();
    String artifactId = coordinates.getArtifactId().getStringValue();

    if (StringUtil.isEmptyOrSpaces(groupId) || StringUtil.isEmptyOrSpaces(artifactId)) return null;

    String version = coordinates.getVersion().getStringValue();
    String type = coordinates.getType().getStringValue();
    String classifier = coordinates.getClassifier().getStringValue();

    return groupId + ":" + artifactId + ":" + version + ":" + type + ":" + classifier;
  }
  public static boolean processDependenciesInDependencyManagement(
      @NotNull MavenDomProjectModel projectDom,
      @NotNull final Processor<MavenDomDependency> processor,
      @NotNull final Project project) {

    Processor<MavenDomDependencies> managedDependenciesListProcessor =
        dependencies -> {
          SmartList<MavenDomDependency> importDependencies = null;

          for (MavenDomDependency domDependency : dependencies.getDependencies()) {
            if ("import".equals(domDependency.getScope().getRawText())) {
              if (importDependencies == null) {
                importDependencies = new SmartList<MavenDomDependency>();
              }

              importDependencies.add(domDependency);
            } else {
              if (processor.process(domDependency)) return true;
            }
          }

          if (importDependencies != null) {
            for (MavenDomDependency domDependency : importDependencies) {
              GenericDomValue<String> version = domDependency.getVersion();
              if (version.getXmlElement() != null) {
                GenericDomValueReference reference = new GenericDomValueReference(version);
                PsiElement resolve = reference.resolve();

                if (resolve instanceof XmlFile) {
                  MavenDomProjectModel dependModel =
                      MavenDomUtil.getMavenDomModel((PsiFile) resolve, MavenDomProjectModel.class);
                  if (dependModel != null) {
                    for (MavenDomDependency dep :
                        dependModel.getDependencyManagement().getDependencies().getDependencies()) {
                      if (processor.process(dep)) return true;
                    }
                  }
                }
              }
            }
          }

          return false;
        };

    Function<MavenDomProjectModelBase, MavenDomDependencies> domFunction =
        mavenDomProfile -> mavenDomProfile.getDependencyManagement().getDependencies();

    return process(projectDom, managedDependenciesListProcessor, project, domFunction, domFunction);
  }
  @Nullable
  public static MavenDomDependency searchManagingDependency(
      @NotNull final MavenDomDependency dependency, @NotNull final Project project) {
    final DependencyConflictId depId = DependencyConflictId.create(dependency);
    if (depId == null) return null;

    final MavenDomProjectModel model =
        dependency.getParentOfType(MavenDomProjectModel.class, false);
    if (model == null) return null;

    final Ref<MavenDomDependency> res = new Ref<MavenDomDependency>();

    Processor<MavenDomDependency> processor =
        dependency1 -> {
          if (depId.equals(DependencyConflictId.create(dependency1))) {
            res.set(dependency1);
            return true;
          }

          return false;
        };

    processDependenciesInDependencyManagement(model, processor, project);

    return res.get();
  }
  public static int getCollectionIndex(
      @NotNull final MavenDomDependencies dependencies, @Nullable final Editor editor) {
    if (editor != null) {
      int offset = editor.getCaretModel().getOffset();

      List<MavenDomDependency> dependencyList = dependencies.getDependencies();

      for (int i = 0; i < dependencyList.size(); i++) {
        MavenDomDependency dependency = dependencyList.get(i);
        XmlElement xmlElement = dependency.getXmlElement();

        if (xmlElement != null && xmlElement.getTextRange().getStartOffset() >= offset) {
          return i;
        }
      }
    }
    return -1;
  }
 @Nullable
 private static String getProjectName(@Nullable MavenDomDependency dependency) {
   if (dependency != null) {
     MavenDomProjectModel model = dependency.getParentOfType(MavenDomProjectModel.class, false);
     if (model != null) {
       String name = model.getName().getStringValue();
       return StringUtil.isEmptyOrSpaces(name) ? model.getArtifactId().getStringValue() : name;
     }
   }
   return null;
 }
 @NotNull
 public static Set<MavenDomDependency> searchDependencyUsages(
     @NotNull final MavenDomDependency dependency) {
   final MavenDomProjectModel model =
       dependency.getParentOfType(MavenDomProjectModel.class, false);
   if (model != null) {
     DependencyConflictId dependencyId = DependencyConflictId.create(dependency);
     if (dependencyId != null) {
       return searchDependencyUsages(model, dependencyId, Collections.singleton(dependency));
     }
   }
   return Collections.emptySet();
 }
  private static void addProblem(
      @NotNull MavenDomDependency dependency,
      @NotNull Set<MavenDomDependency> dependencies,
      @NotNull DomElementAnnotationHolder holder) {
    StringBuffer sb = new StringBuffer();
    Set<MavenDomProjectModel> processed = new HashSet<MavenDomProjectModel>();
    for (MavenDomDependency domDependency : dependencies) {
      if (dependency.equals(domDependency)) continue;
      MavenDomProjectModel model = domDependency.getParentOfType(MavenDomProjectModel.class, false);
      if (model != null && !processed.contains(model)) {
        if (processed.size() > 0) sb.append(", ");
        sb.append(createLinkText(model, domDependency));

        processed.add(model);
      }
    }
    holder.createProblem(
        dependency,
        HighlightSeverity.WARNING,
        MavenDomBundle.message(
            "MavenDuplicateDependenciesInspection.has.duplicates", sb.toString()));
  }
  private static String createLinkText(
      @NotNull MavenDomProjectModel model, @NotNull MavenDomDependency dependency) {
    StringBuffer sb = new StringBuffer();

    XmlTag tag = dependency.getXmlTag();
    if (tag == null) return getProjectName(model);
    VirtualFile file = tag.getContainingFile().getVirtualFile();
    if (file == null) return getProjectName(model);

    sb.append("<a href ='#navigation/");
    sb.append(file.getPath());
    sb.append(":");
    sb.append(tag.getTextRange().getStartOffset());
    sb.append("'>");
    sb.append(getProjectName(model));
    sb.append("</a>");

    return sb.toString();
  }
  public static void addTypeAndClassifierAndVersion(
      @NotNull InsertionContext context,
      @NotNull MavenDomDependency dependency,
      @NotNull String groupId,
      @NotNull String artifactId) {
    if (!StringUtil.isEmpty(dependency.getVersion().getStringValue())) return;

    Project project = context.getProject();

    if (!isInsideManagedDependency(dependency)) {
      MavenDomProjectModel model =
          DomUtil.<MavenDomProjectModel>getFileElement(dependency).getRootElement();
      MavenDomDependency managedDependency =
          findManagedDependency(model, project, groupId, artifactId);
      if (managedDependency != null) {
        if (dependency.getClassifier().getXmlTag() == null
            && dependency.getType().getXmlTag() == null) {
          String classifier = managedDependency.getClassifier().getRawText();
          if (StringUtil.isNotEmpty(classifier)) {
            dependency.getClassifier().setStringValue(classifier);
          }
          String type = managedDependency.getType().getRawText();
          if (StringUtil.isNotEmpty(type)) {
            dependency.getType().setStringValue(type);
          }
        }
        return;
      }
    }

    MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(project);

    Set<String> versions = manager.getVersions(groupId, artifactId);
    if (versions.size() == 1) {
      dependency.getVersion().setStringValue(ContainerUtil.getFirstItem(versions));
      return;
    }

    dependency.getVersion().setStringValue("");

    int versionPosition =
        dependency.getVersion().getXmlTag().getValue().getTextRange().getStartOffset();

    context.getEditor().getCaretModel().moveToOffset(versionPosition);

    if (versions.size() > 0) {
      invokeCompletion(context, CompletionType.BASIC);
    }
  }
 @Nullable
 public static MavenDomDependency searchManagingDependency(
     @NotNull final MavenDomDependency dependency) {
   return searchManagingDependency(dependency, dependency.getManager().getProject());
 }
 public MavenDomProjectModelMember(final MavenDomDependency dependency) {
   super(dependency.toString(), AllIcons.Nodes.PpLib);
   myDependency = dependency;
 }
    public MemberChooserObject getParentNodeDelegate() {
      MavenDomDependency dependency = getDependency();

      return new MavenDomProjectModelFileMemberChooserObjectBase(
          dependency.getXmlTag().getContainingFile(), getProjectName(dependency));
    }