Skip to content
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

Disable test generation for Kotlin getters/setters #911 #1003

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 @@ -7,15 +7,27 @@ import com.intellij.psi.SyntheticElement
import com.intellij.refactoring.classMembers.MemberInfoBase
import com.intellij.refactoring.util.classMembers.MemberInfo
import com.intellij.testIntegration.TestIntegrationUtils
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
import org.jetbrains.kotlin.asJava.elements.isGetter
import org.jetbrains.kotlin.asJava.elements.isSetter
import org.utbot.common.filterWhen
import org.utbot.framework.UtSettings

private val MemberInfoBase<out PsiModifierListOwner>.isAbstract: Boolean
get() = this.member.modifierList?.hasModifierProperty(PsiModifier.ABSTRACT)?: false


private val MemberInfo.isKotlinGetterOrSetter: Boolean
get() {
if (this !is KtLightMethod)
return false
return this.isGetter || this.isSetter
}

private fun Iterable<MemberInfo>.filterTestableMethods(): List<MemberInfo> = this
.filterWhen(UtSettings.skipTestGenerationForSyntheticMethods) { it.member !is SyntheticElement }
.filterNot { it.isAbstract }
.filterNot { it.isKotlinGetterOrSetter }

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