protected void setDependency(@NotNull InsertionContext context,
                               MavenRepositoryArtifactInfo completionItem,
                               XmlFile contextFile, MavenDomShortArtifactCoordinates domCoordinates) {
    domCoordinates.getGroupId().setStringValue(completionItem.getGroupId());

    domCoordinates.getArtifactId().setStringValue(completionItem.getArtifactId());

    if (domCoordinates instanceof MavenDomDependency) {
      String scope = MavenScopeTable.getUsualScope(completionItem);
      if (scope != null) {
        ((MavenDomDependency)domCoordinates).getScope().setStringValue(scope);
      }
    }

    DomFileElement<MavenDomProjectModel> domModel =
      DomManager.getDomManager(context.getProject()).getFileElement(contextFile, MavenDomProjectModel.class);


    if (!MavenDependencyCompletionUtil.isInsideManagedDependency(domCoordinates)) {
      MavenDomDependency declarationOfDependency =
        MavenDependencyCompletionUtil.findManagedDependency(domModel.getRootElement(), context.getProject(), completionItem.getGroupId(),
                                                            completionItem.getArtifactId());
      if (declarationOfDependency != null) {
        if (domCoordinates instanceof MavenDomDependency) {
          if (declarationOfDependency.getType().getRawText() != null) {
            ((MavenDomDependency)domCoordinates).getType().setStringValue(declarationOfDependency.getType().getRawText());
          }
          if (declarationOfDependency.getClassifier().getRawText() != null) {
            ((MavenDomDependency)domCoordinates).getClassifier().setStringValue(declarationOfDependency.getClassifier().getRawText());
          }
        }
        return;
      }
    }

    if (domCoordinates instanceof MavenDomArtifactCoordinates) {
      insertVersion(context, completionItem, (MavenDomArtifactCoordinates)domCoordinates);
    }
  }
protected void setDependency(@NotNull InsertionContext context,
                               MavenRepositoryArtifactInfo completionItem,
                               XmlFile contextFile, MavenDomShortArtifactCoordinates domCoordinates)