Skip to content

Commit

Permalink
Merge #4971
Browse files Browse the repository at this point in the history
4971: REPL: Fix macro completion inside Rust Console r=vlad20012 a=dima74

Fix #4752

Co-authored-by: Dmitry Murzin <diralik@yandex.ru>
  • Loading branch information
bors[bot] and dima74 committed Feb 19, 2020
2 parents 1072264 + 816edbd commit 4ef1ac8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/kotlin/org/rust/lang/core/psi/ext/PsiElement.kt
Expand Up @@ -17,6 +17,7 @@ import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.PsiUtilCore
import com.intellij.util.SmartList
import org.rust.lang.core.psi.RsFile
import org.rust.lang.core.psi.RsReplCodeFragment
import org.rust.lang.core.stubs.RsFileStub
import org.rust.openapiext.findDescendantsWithMacrosOfAnyType

Expand Down Expand Up @@ -207,7 +208,14 @@ inline fun <reified T : PsiElement> PsiElement.descendantsWithMacrosOfType(): Co
* Same as [PsiElement.getContainingFile], but return a "fake" file. See [org.rust.lang.core.macros.RsExpandedElement].
*/
val PsiElement.contextualFile: PsiFile
get() = contextOrSelf() ?: error("Element outside of file: $text")
get() {
val file = contextOrSelf<PsiFile>() ?: error("Element outside of file: $text")
return if (file is RsReplCodeFragment) {
file.context.contextualFile
} else {
file
}
}

/**
* Finds first sibling that is neither comment, nor whitespace before given element.
Expand Down

0 comments on commit 4ef1ac8

Please sign in to comment.