Create from Usage: Support "Create member/extension" corresponding to the extension receiver of enclosing function
#KT-10668 Fixed (cherry picked from commit bc4c013)
This commit is contained in:
@@ -156,10 +156,18 @@ fun <T : PsiElement> T.getIfChildIsInBranch(element: PsiElement, branch: T.() ->
|
||||
return if (branch().isAncestor(element)) this else null
|
||||
}
|
||||
|
||||
fun <T : PsiElement> T.getIfChildIsInBranches(element: PsiElement, branches: T.() -> Iterable<PsiElement?>): T? {
|
||||
return if (branches().any { it.isAncestor(element) }) this else null
|
||||
}
|
||||
|
||||
inline fun <reified T : PsiElement> PsiElement.getParentOfTypeAndBranch(strict: Boolean = false, noinline branch: T.() -> PsiElement?): T? {
|
||||
return getParentOfType<T>(strict)?.getIfChildIsInBranch(this, branch)
|
||||
}
|
||||
|
||||
inline fun <reified T : PsiElement> PsiElement.getParentOfTypeAndBranches(strict: Boolean = false, noinline branches: T.() -> Iterable<PsiElement?>): T? {
|
||||
return getParentOfType<T>(strict)?.getIfChildIsInBranches(this, branches)
|
||||
}
|
||||
|
||||
tailrec fun PsiElement.getOutermostParentContainedIn(container: PsiElement): PsiElement? {
|
||||
val parent = parent
|
||||
return if (parent == container) this else parent?.getOutermostParentContainedIn(container)
|
||||
|
||||
Reference in New Issue
Block a user