<commit_before>// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInspection.apiUsage

import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil
import com.intellij.psi.*
import com.intellij.psi.infos.MethodCandidateInfo

/**
 * Non-recursive PSI visitor that detects usages of APIs and reports them via [ApiUsageDetector] interface.
 * This visitor is mainly designed for Java, but may basically work with any language, including Kotlin.
 * Inheritors should provide at least implementation of [processReference].
 */
abstract class ApiUsageVisitorBase : PsiElementVisitor(), ApiUsageDetector {

  final override fun visitElement(element: PsiElement) {
    super.visitElement(element)
    if (element is PsiLanguageInjectionHost) {
      //Better performance.
      return
    }

    when (element) {
      is PsiClass -> visitClass(element)
      is PsiMethod -> visitMethod(element)
      is PsiNewExpression -> visitNewExpression(element)
      else -> processReferences(element)<commit_msg>ApiUsageVisitorBase: replay LeafPsiElement optimization that got missed during rebase.<commit_after>// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInspection.apiUsage

import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil
import com.intellij.psi.*
import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.psi.infos.MethodCandidateInfo

/**
 * Non-recursive PSI visitor that detects usages of APIs and reports them via [ApiUsageDetector] interface.
 * This visitor is mainly designed for Java, but may basically work with any language, including Kotlin.
 * Inheritors should provide at least implementation of [processReference].
 */
abstract class ApiUsageVisitorBase : PsiElementVisitor(), ApiUsageDetector {

  final override fun visitElement(element: PsiElement) {
    super.visitElement(element)
    if (element is PsiLanguageInjectionHost || element is LeafPsiElement) {
      //Better performance.
      return
    }

    when (element) {
      is PsiClass -> visitClass(element)
      is PsiMethod -> visitMethod(element)
      is PsiNewExpression -> visitNewExpression(element)
      else -> processReferences(element)
{'fraction_non_alphanumeric': 0.0740432612312812, 'fraction_numerical': 0.008319467554076539, 'mean_word_length': 4.297356828193832, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5531932', 'n_tokens_mistral': 679, 'n_tokens_neox': 646, 'n_words': 216}