Skip to content

Commit

Permalink
Remove usages of parentOfType (unavailable in Java-agnostic IDEs, suc…
Browse files Browse the repository at this point in the history
…h as WS)
  • Loading branch information
reeFridge committed Mar 6, 2019
1 parent 3f02c6a commit bcee0e0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/kotlin/com/interfaced/brs/lang/psi/BrsUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import com.intellij.psi.search.GlobalSearchScope
import com.intellij.util.indexing.FileBasedIndex
import com.interfaced.brs.lang.BrsFileType
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.parentOfType

class BrsUtil {
companion object {
private inline fun <reified T : PsiElement> getChildrenFromFiles(files: List<PsiFile>): List<Array<T>> {
return files.mapNotNull { PsiTreeUtil.getChildrenOfType(it, T::class.java) }
}

private inline fun <reified T : PsiElement> PsiElement.ancestorOfType(): T? =
PsiTreeUtil.getParentOfType(this, T::class.java, /* strict */ false)

fun isPropertyIdentifier(element: PsiElement): Boolean {
val prevSibling = element.prevSibling

Expand Down Expand Up @@ -51,11 +53,11 @@ class BrsUtil {
}

fun getOwnedFunction(element: PsiElement): BrsFunctionStmt? {
return element.parentOfType()
return element.ancestorOfType()
}

fun getOwnedSub(element: PsiElement): BrsSubStmt? {
return element.parentOfType()
return element.ancestorOfType()
}
}
}

0 comments on commit bcee0e0

Please sign in to comment.