<commit_before>package org.jetbrains.plugins.scala.lang.completion

import com.intellij.codeInsight.completion.{CompletionParameters, CompletionConfidence}
import com.intellij.util.ThreeState
import com.intellij.psi.{PsiFile, PsiElement}
import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes
import com.intellij.psi.tree.IElementType

/**
 * @author <NAME>
 */

class ScalaCompletionConfidence extends CompletionConfidence {
  def shouldFocusLookup(parameters: CompletionParameters): ThreeState = {
    if (parameters.getOriginalPosition.getText == "_") return ThreeState.NO //SCL-3290 _ <space> =>
    ThreeState.YES
  }

  override def shouldSkipAutopopup(contextElement: PsiElement, psiFile: PsiFile, offset: Int): ThreeState = {
    if (offset != 0) {
      val elementType: IElementType = psiFile.findElementAt(offset - 1).getNode.getElementType
      elementType match {
        case ScalaTokenTypes.tINTEGER | ScalaTokenTypes.tFLOAT => return ThreeState.YES
        case _ =>
      }
    }
    super.shouldSkipAutopopup(contextElement, psiFile, offset)
  }
}<commit_msg>Hided possible strange completion like: SCL-3271, SCL-3428<commit_after>package org.jetbrains.plugins.scala.lang.completion

import com.intellij.codeInsight.completion.{CompletionParameters, CompletionConfidence}
import com.intellij.util.ThreeState
import com.intellij.psi.{PsiFile, PsiElement}
import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes
import com.intellij.psi.tree.IElementType
import org.jetbrains.plugins.scala.lang.psi.api.base.ScReferenceElement

/**
 * @author <NAME>
 */

class ScalaCompletionConfidence extends CompletionConfidence {
  def shouldFocusLookup(parameters: CompletionParameters): ThreeState = {
    if (parameters.getOriginalPosition.getText == "_") return ThreeState.NO //SCL-3290 _ <space> =>
    parameters.getPosition.getParent match {
      case ref: ScReferenceElement => ThreeState.YES
      case _ => ThreeState.NO //keyword completion can be here in case of broken tree
    }
  }

  override def shouldSkipAutopopup(contextElement: PsiElement, psiFile: PsiFile, offset: Int): ThreeState = {
    if (offset != 0) {
      val elementType: IElementType = psiFile.findElementAt(offset - 1).getNode.getElementType
      elementType match {
        case ScalaTokenTypes.tINTEGER | ScalaTokenTypes.tFLOAT => return ThreeState.YES
        case _ =>
      }
    }
    super.shouldSkipAutopopup(contextElement, psiFile, offset)
  }
}
{'fraction_non_alphanumeric': 0.0984540276647681, 'fraction_numerical': 0.008136696501220505, 'mean_word_length': 4.464444444444444, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '536838', 'n_tokens_mistral': 769, 'n_tokens_neox': 737, 'n_words': 143}