Skip to content

Exclude protected kotlin methods from generate window #1373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.intellij.psi.PsiModifier
import com.intellij.psi.SyntheticElement
import com.intellij.refactoring.util.classMembers.MemberInfo
import com.intellij.testIntegration.TestIntegrationUtils
import org.jetbrains.kotlin.asJava.elements.KtLightMember
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
import org.jetbrains.kotlin.asJava.elements.isGetter
import org.jetbrains.kotlin.asJava.elements.isSetter
Expand All @@ -23,6 +24,9 @@ private val PsiMember.isKotlinGetterOrSetter: Boolean
return isGetter || isSetter
}

private val PsiMember.isKotlinAndProtected: Boolean
get() = this is KtLightMember<*> && this.hasModifierProperty(PsiModifier.PROTECTED)

// By now, we think that method in Kotlin is autogenerated iff navigation to its declaration leads to its declaring class
// rather than the method itself (because such methods don't have bodies that we can navigate to)
private val PsiMember.isKotlinAutogeneratedMethod: Boolean
Expand All @@ -34,6 +38,7 @@ fun Iterable<MemberInfo>.filterTestableMethods(): List<MemberInfo> = this
}
.filterNot { it.member.isAbstract }
.filterNot { it.member.isKotlinGetterOrSetter }
.filterNot { it.member.isKotlinAndProtected }

private val PsiClass.isPrivateOrProtected: Boolean
get() = this.modifierList?.let {
Expand Down