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

import _root_.org.jetbrains.plugins.scala.lang.psi.types.{PhysicalSignature, Signature, ScSubstitutor}
import com.intellij.psi.scope._
import com.intellij.psi._

import _root_.scala.collection.Set
import _root_.scala.collection.mutable.HashSet
import psi.api.base.patterns.ScBindingPattern
class CompletionProcessor(override val kinds: Set[ResolveTargets.Value]) extends BaseProcessor(kinds) {
  private val signatures = new HashSet[Signature]

  def execute(element: PsiElement, state: ResolveState): Boolean = {
    val named = element.asInstanceOf[PsiNamedElement]
    if (kindMatches(element)) {
      element match {
        case method: PsiMethod => {
          val sign = new PhysicalSignature(method, state.get(ScSubstitutor.key))
          if (!signatures.contains(sign)) {
            signatures += sign
            candidatesSet += new ScalaResolveResult(named)
          }
        }
        case patt: ScBindingPattern => {
          import Suspension._
          val sign = new Signature(patt.getName, Seq.empty, 0, Seq.empty.toArray, state.get(ScSubstitutor.key))
          if (!signatures.contains(sign)) {
            signatures += sign
            candidatesSet += new ScalaResolveResult(named)
          }
        }
        case _ => {
          candidatesSet += new ScalaResolveResult(named)
        }
      }
    }
    return true
  }
}<commit_msg>fixed NPE in new Completion filtering (caused by null Substitutor)<commit_after>package org.jetbrains.plugins.scala.lang.resolve

import _root_.org.jetbrains.plugins.scala.lang.psi.types.{PhysicalSignature, Signature, ScSubstitutor}
import com.intellij.psi.scope._
import com.intellij.psi._

import _root_.scala.collection.Set
import _root_.scala.collection.mutable.HashSet
import psi.api.base.patterns.ScBindingPattern
class CompletionProcessor(override val kinds: Set[ResolveTargets.Value]) extends BaseProcessor(kinds) {
  private val signatures = new HashSet[Signature]

  def execute(element: PsiElement, state: ResolveState): Boolean = {
    def substitutor: ScSubstitutor = {
      state.get(ScSubstitutor.key) match {
        case null => ScSubstitutor.empty
        case x => x
      }
    }
    val named = element.asInstanceOf[PsiNamedElement]
    if (kindMatches(element)) {
      element match {
        case method: PsiMethod => {
          val sign = new PhysicalSignature(method, substitutor)
          if (!signatures.contains(sign)) {
            signatures += sign
            candidatesSet += new ScalaResolveResult(named)
          }
        }
        case patt: ScBindingPattern => {
          import Suspension._
          val sign = new Signature(patt.getName, Seq.empty, 0, Seq.empty.toArray, substitutor)
          if (!signatures.contains(sign)) {
            signatures += sign
            candidatesSet += new ScalaResolveResult(named)
          }
        }
        case _ => {
          candidatesSet += new ScalaResolveResult(named)
        }
      }
    }
    return true
  }
}
{'fraction_non_alphanumeric': 0.09631821170282709, 'fraction_numerical': 0.0006574621959237344, 'mean_word_length': 2.7895392278953923, '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': '2773269', 'n_tokens_mistral': 894, 'n_tokens_neox': 870, 'n_words': 184}