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

import api.statements.ScDeclaredElementsHolder
import api.toplevel.ScNamedElement
import com.intellij.psi._
import psi.impl.ScalaFileImpl
import scope._
import com.intellij.psi.stubs.StubElement

trait ScDeclarationSequenceHolder extends ScalaPsiElement {
  override def processDeclarations(processor: PsiScopeProcessor,
      state : ResolveState,
      lastParent: PsiElement,
      place: PsiElement): Boolean = {
    import org.jetbrains.plugins.scala.lang.resolve._

    if (lastParent != null) {
      var run = lastParent
      while (run != null) {
        if (!processElement(run, processor, state)) return false
        run = ScalaPsiUtil.getPrevStubOrPsiElement(run)
      }

      //forward references are allowed (e.g. 2 local methods see each other), with highlighting errors in case of var/vals
      run = ScalaPsiUtil.getNextStubOrPsiElement(lastParent)
      while (run != null) {
        if (!processElement(run, processor, state)) return false
        run = ScalaPsiUtil.getNextStubOrPsiElement(run)
      }
    }
    true
  }

  private def processElement(e : PsiElement, processor: PsiScopeProcessor, state : ResolveState) : Boolean = e match {
    case named: ScNamedElement => processor.execute(named, state)
    case holder: ScDeclaredElementsHolder => {
      for (declared <- holder.declaredElements) {
        if (!processor.execute(declared, state)) return false<commit_msg>resolve fixed for qualifiers inside package objects<commit_after>package org.jetbrains.plugins.scala.lang.psi

import api.base.ScStableCodeReferenceElement
import api.statements.ScDeclaredElementsHolder
import api.toplevel.ScNamedElement
import api.toplevel.typedef.ScObject
import com.intellij.psi._
import psi.impl.ScalaFileImpl
import scope._
import com.intellij.psi.stubs.StubElement

trait ScDeclarationSequenceHolder extends ScalaPsiElement {
  override def processDeclarations(processor: PsiScopeProcessor,
      state : ResolveState,
      lastParent: PsiElement,
      place: PsiElement): Boolean = {
    import org.jetbrains.plugins.scala.lang.resolve._

    if (lastParent != null) {
      var run = lastParent
      while (run != null) {
        place match {
          case id: ScStableCodeReferenceElement => run match {
            case po: ScObject if po.isPackageObject && id.qualName == po.getQualifiedName => // do nothing
            case _ => if (!processElement(run, processor, state)) return false
          }
          case _ => if (!processElement(run, processor, state)) return false
        }
        run = ScalaPsiUtil.getPrevStubOrPsiElement(run)
      }

      //forward references are allowed (e.g. 2 local methods see each other), with highlighting errors in case of var/vals
      run = ScalaPsiUtil.getNextStubOrPsiElement(lastParent)
      while (run != null) {
        if (!processElement(run, processor, state)) return false
        run = ScalaPsiUtil.getNextStubOrPsiElement(run)
      }
    }
    true
  }

  private def processElement(e : PsiElement, processor: PsiScopeProcessor, state : ResolveState) : Boolean = e match {
    case named: ScNamedElement => processor.execute(named, state)
    case holder: ScDeclaredElementsHolder => {
      for (declared <- holder.declaredElements) {
        if (!processor.execute(declared, state)) return false
{'fraction_non_alphanumeric': 0.08738443185207277, 'fraction_numerical': 0.0005964807634953773, 'mean_word_length': 3.5080645161290325, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5109266', 'n_tokens_mistral': 952, 'n_tokens_neox': 937, 'n_words': 247}