private static void doAddCompletions(CompletionParameters parameters, GroovyCompletionConsumer consumer) {

    GroovyCompletionData.addGroovyDocKeywords(parameters, consumer);

    PsiElement position = parameters.getPosition();
    if (PlatformPatterns.psiElement().inside(false, PlatformPatterns.psiElement(PsiComment.class)).accepts(position)) {
      return;
    }

    GroovyCompletionData.addGroovyKeywords(parameters, consumer);

    addUnfinishedMethodTypeParameters(position, consumer);

    suggestVariableNames(position, consumer);

    GrReferenceElement<?> reference = findGroovyReference(position);
    if (reference == null) {
      if (parameters.getInvocationCount() >= 2) {
        consumer.interrupt();
        addAllClasses(parameters, consumer.transform(crs -> crs.withPrefixMatcher(CompletionUtil.findJavaIdentifierPrefix(parameters))), new JavaCompletionSession(consumer.getCompletionResultSet()));
      }
      return;
    }

    if (reference.getParent() instanceof GrImportStatement && reference.getQualifier() != null) {
      consumer.consume(LookupElementBuilder.create("*"));
    }

    JavaCompletionSession inheritors = new JavaCompletionSession(consumer.getCompletionResultSet());
    if (GroovySmartCompletionContributor.AFTER_NEW.accepts(position)) {
      GroovySmartCompletionContributor.generateInheritorVariants(parameters, consumer.getCompletionResultSet().getPrefixMatcher(), inheritors::addClassItem);
    }

    Runnable addSlowVariants = completeReference(
      parameters, reference, inheritors, consumer.getCompletionResultSet().getPrefixMatcher(), consumer.getCompletionResultSet(),
      lookupElement -> consumer.consume(lookupElement)
    );

    if (reference.getQualifier() == null) {
      if (!GroovySmartCompletionContributor.AFTER_NEW.accepts(position)) {
        GroovySmartCompletionContributor.addExpectedClassMembers(parameters, consumer);
      }

      if (isClassNamePossible(position) && JavaCompletionContributor.mayStartClassName(consumer.getCompletionResultSet())) {
        //consumer.interrupt();
        if (parameters.getInvocationCount() >= 2) {
          addAllClasses(parameters, consumer, inheritors);
        } else {
          JavaCompletionContributor.advertiseSecondCompletion(position.getProject(), consumer.getCompletionResultSet());
        }
      }
    }
    consumer.fastElementsProcessed(parameters);
    if (GroovyCompletionUtil.isSlowCompletionEnabled()) {
      addSlowVariants.run();
    }
  }
private static void doAddCompletions(CompletionParameters parameters, GroovyCompletionConsumer consumer)