override fun visitStringLiteralExpression()

in psi/src/com/intellij/r/psi/annotator/RAnnotatorVisitor.kt [108:131]


  override fun visitStringLiteralExpression(o: RStringLiteralExpression) {
    val call = PsiTreeUtil.skipParentsOfType(o, RNamedArgument::class.java, RArgumentList::class.java)
    if (call !is RCallExpression) return

    // To avoid IndexNotReadyException
    if (DumbService.isDumb(o.project)) return
    if (!call.isFunctionFromLibrary("source", "base")) return
    if (RArgumentInfo.getArgumentByName(call, "file") != o) return

    val reference = o.references.filterIsInstance<FileReference>().singleOrNull() ?: return
    val range = reference.rangeInElement
    if (range.isEmpty) return

    var message = annotationSession.getUserData(sourceTooltipMessageKey)
    if (message == null) {
      message = sourceTooltipMessage
      annotationSession.putUserData(sourceTooltipMessageKey, message)
    }
    val info = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(range.shiftRight(o.textOffset)).descriptionAndTooltip(
      message).textAttributes(CodeInsightColors.INACTIVE_HYPERLINK_ATTRIBUTES).create()
    if (info != null) {
      holder.add(info)
    }
  }