override fun completeArgumentValue()

in src/org/jetbrains/r/codeInsight/libraries/Ggplot2SupportProvider.kt [21:33]


  override fun completeArgumentValue(position: PsiElement, call: RCallExpression, completionConsumer: CompletionResultSet) {
    val parent = position.parent
    if ((call.isFunctionFromLibrarySoft("qplot", "ggplot2") || call.isFunctionFromLibrarySoft("stat_.*", "ggplot2")) &&
        (position is RStringLiteralExpression || position is RIdentifierExpression && position.name == DUMMY_IDENTIFIER_TRIMMED)
        && parent is RNamedArgument && parent.assignedValue == position && parent.name == "geom") {

      for (geom in GEOM_TYPES) {
        val lookupString = if (position is RIdentifierExpression) "\"" + geom + "\"" else geom
        val lookupElement = PrioritizedLookupElement.withPriority(RLookupElement(lookupString, true), ARGUMENT_VALUE_PRIORITY)
        completionConsumer.addElement(lookupElement)
      }
    }
  }