@Override
  public void invoke(@NotNull final Project project, Editor editor, final PsiFile file) throws IncorrectOperationException {
    if (!myRef.isValid()) return;

    MavenProject mavenProject = MavenDomUtil.findContainingProject(file);
    if (mavenProject == null) return;

    final List<MavenId> ids = MavenArtifactSearchDialog.searchForClass(project, getReferenceText());
    if (ids.isEmpty()) return;

    final MavenDomProjectModel model = MavenDomUtil.getMavenDomProjectModel(project, mavenProject.getFile());
    if (model == null) return;

    WriteCommandAction.writeCommandAction(project, DomUtil.getFile(model)).withName(
      MavenDomBundle.message("maven.dom.quickfix.add.maven.dependency")).run(() -> {
      boolean isTestSource = false;

      VirtualFile virtualFile = file.getOriginalFile().getVirtualFile();
      if (virtualFile != null) {
        isTestSource = ProjectRootManager.getInstance(project).getFileIndex().isInTestSourceContent(virtualFile);
      }

      Map<MavenId, MavenDomDependency> dependencyMap = model.getDependencies().getDependencies().stream().collect(Collectors.toMap(
        it -> new MavenId(it.getGroupId().getStringValue(), it.getArtifactId().getStringValue(), it.getVersion().getStringValue()),
        Function.identity(),
        (dep1, dep2) -> {
          return dep1;
        }
      ));

      for (MavenId each : ids) {
        MavenDomDependency existingDependency = dependencyMap.get(each);
        if (existingDependency == null) {
          MavenDomDependency dependency = MavenDomUtil.createDomDependency(model, null, each);
          if (isTestSource) {
            dependency.getScope().setStringValue("test");
          }
        }
        else {
          if ("test".equals(existingDependency.getScope().getStringValue()) && !isTestSource) {
            existingDependency.getScope().setValue(null);
          }
        }
      }
    });

    FileDocumentManager.getInstance().saveAllDocuments();
    MavenLog.LOG.info("AddMavenDependencyQuickFix forceUpdateAllProjectsOrFindAllAvailablePomFiles");
    MavenProjectsManager.getInstance(project).forceUpdateAllProjectsOrFindAllAvailablePomFiles();
  }
@Override
  public void invoke(@NotNull final Project project, Editor editor, final PsiFile file)