<commit_before>package org.rust.lang.core.resolve.ref

import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiReferenceBase
import org.rust.lang.core.psi.RustCompositeElement
import org.rust.lang.core.psi.RustNamedElement
import org.rust.lang.core.psi.util.parentRelativeRange
import org.rust.lang.core.resolve.RustResolveEngine

abstract class RustReferenceBase<T : RustCompositeElement>(
    element: T,
    refAnchorTextRange: TextRange
) : PsiReferenceBase<T>(element, refAnchorTextRange)
  , RustReference {

    constructor(element: T, refAnchor: PsiElement) : this(element, refAnchor.parentRelativeRange) {
        check(refAnchor.parent == element)
    }

    abstract fun resolveVerbose(): RustResolveEngine.ResolveResult

    final override fun resolve(): RustNamedElement? =
        resolveVerbose().let {
            when (it) {
                is RustResolveEngine.ResolveResult.Resolved -> it.element
                else -> null
            }
        }
<commit_msg>(REF): Revisited `RustReferenceBase` to allow anchoring upon not only children        of the reference-element, but also the node itself<commit_after>package org.rust.lang.core.resolve.ref

import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiReferenceBase
import org.rust.lang.core.psi.RustCompositeElement
import org.rust.lang.core.psi.RustNamedElement
import org.rust.lang.core.psi.util.parentRelativeRange
import org.rust.lang.core.resolve.RustResolveEngine

abstract class RustReferenceBase<T : RustCompositeElement>(
    element: T,
    refAnchorTextRange: TextRange
) : PsiReferenceBase<T>(element, refAnchorTextRange)
  , RustReference {

    constructor(element: T, refAnchor: PsiElement) : this(element, refAnchor.parentRelativeRange) {
        check(refAnchor == element || refAnchor.parent == element)
    }

    abstract fun resolveVerbose(): RustResolveEngine.ResolveResult

    final override fun resolve(): RustNamedElement? =
        resolveVerbose().let {
            when (it) {
                is RustResolveEngine.ResolveResult.Resolved -> it.element
                else -> null
            }
        }

{'fraction_non_alphanumeric': 0.09288627095604894, 'fraction_numerical': 0.0, 'mean_word_length': 3.6192468619246863, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5629381', 'n_tokens_mistral': 644, 'n_tokens_neox': 631, 'n_words': 123}