[kotlin] Move excluded Java methods to the K2 implementation of NotPropertiesService

KTIJ-31157 Temporarily exclude `isEmpty` from properties that UsePropertyAccessSyntaxInspection processes


(cherry picked from commit 9fda5d9408ea0b2aee4498cf8614426a1dfe7b8c)

IJ-CR-146866

GitOrigin-RevId: 5d290703ee25edf4e3f18824f05b212a95559759
This commit is contained in:
Victoria.Petrakovich
2024-10-16 16:58:31 +02:00
committed by intellij-monorepo-bot
parent 26e2540cc8
commit 58e5dc7d41
2 changed files with 11 additions and 5 deletions

View File

@@ -28,9 +28,6 @@ interface NotPropertiesService {
for (byteBufferMethod in listOf("getChar", "getDouble", "getFloat", "getInt", "getLong", "getShort")) {
add("java.nio.ByteBuffer.$byteBufferMethod")
}
add("java.util.AbstractCollection.isEmpty") // KTIJ-31157
add("java.util.AbstractMap.isEmpty") // KTIJ-31157
}
fun getNotProperties(element: PsiElement): Set<FqNameUnsafe> {

View File

@@ -646,7 +646,10 @@ class UsePropertyAccessSyntaxInspection : LocalInspectionTool(), CleanupLocalIns
) KotlinBundle.message("use.of.setter.method.instead.of.property.access.syntax")
else KotlinBundle.message("use.of.getter.method.instead.of.property.access.syntax")
val propertiesNotToReplace = NotPropertiesService.DEFAULT.map(::FqNameUnsafe).toMutableSet()
val propertiesNotToReplace =
(NotPropertiesService.DEFAULT.map(::FqNameUnsafe)
+ FqNameUnsafe("java.util.AbstractCollection.isEmpty") // KTIJ-31157
+ FqNameUnsafe("java.util.AbstractMap.isEmpty")).toMutableSet() // KTIJ-31157
// Serialized setting
@Suppress("MemberVisibilityCanBePrivate")
@@ -692,7 +695,13 @@ class NotPropertiesServiceImpl(private val project: Project) : NotPropertiesServ
override fun getNotProperties(element: PsiElement): Set<FqNameUnsafe> {
val profile = InspectionProjectProfileManager.getInstance(project).currentProfile
val tool = profile.getUnwrappedTool(USE_PROPERTY_ACCESS_INSPECTION, element)
return (tool?.propertiesNotToReplace ?: NotPropertiesService.DEFAULT.map(::FqNameUnsafe)).toSet()
var propertiesNotToReplace = tool?.propertiesNotToReplace
if (propertiesNotToReplace == null) {
propertiesNotToReplace = NotPropertiesService.DEFAULT.map(::FqNameUnsafe).toMutableSet()
propertiesNotToReplace.add(FqNameUnsafe("java.util.AbstractCollection.isEmpty")) // KTIJ-31157
propertiesNotToReplace.add(FqNameUnsafe("java.util.AbstractMap.isEmpty")) // KTIJ-31157
}
return propertiesNotToReplace
}
companion object {