|
|
|
@ -45,6 +45,7 @@ import org.jetbrains.annotations.NonNls
|
|
|
|
|
*/
|
|
|
|
|
class AliWrapperTypeEqualityInspection : BaseInspection, AliBaseInspection {
|
|
|
|
|
constructor()
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* For Javassist
|
|
|
|
|
*/
|
|
|
|
@ -86,7 +87,7 @@ class AliWrapperTypeEqualityInspection : BaseInspection, AliBaseInspection {
|
|
|
|
|
}
|
|
|
|
|
val type = infos[0] as PsiArrayType
|
|
|
|
|
val componentType = type.componentType
|
|
|
|
|
val fix = ArrayEqualityFix(componentType is PsiArrayType)
|
|
|
|
|
val fix = ArrayEqualityFix(componentType is PsiArrayType, familyName)
|
|
|
|
|
return DecorateInspectionGadgetsFix(fix, fix.name, familyName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -112,10 +113,9 @@ class AliWrapperTypeEqualityInspection : BaseInspection, AliBaseInspection {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return TypeUtils.expressionHasTypeOrSubtype(expression, CommonClassNames.JAVA_LANG_BOOLEAN)
|
|
|
|
|
|| TypeUtils.expressionHasTypeOrSubtype(expression, CommonClassNames.JAVA_LANG_CHARACTER)
|
|
|
|
|
|| TypeUtils.expressionHasTypeOrSubtype(expression, CommonClassNames.JAVA_LANG_CHARACTER)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun hasNumberType(expression: PsiExpression): Boolean {
|
|
|
|
|
return TypeUtils.expressionHasTypeOrSubtype(expression, CommonClassNames.JAVA_LANG_NUMBER)
|
|
|
|
|
}
|
|
|
|
@ -125,7 +125,8 @@ class AliWrapperTypeEqualityInspection : BaseInspection, AliBaseInspection {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ArrayEqualityFix(private val deepEquals: Boolean) : InspectionGadgetsFix() {
|
|
|
|
|
private class ArrayEqualityFix(private val deepEquals: Boolean, private val familyName: String) :
|
|
|
|
|
InspectionGadgetsFix() {
|
|
|
|
|
|
|
|
|
|
override fun getName(): String {
|
|
|
|
|
if (deepEquals) {
|
|
|
|
@ -144,7 +145,8 @@ class AliWrapperTypeEqualityInspection : BaseInspection, AliBaseInspection {
|
|
|
|
|
val element = descriptor.psiElement
|
|
|
|
|
val parent = element.parent as? PsiBinaryExpression ?: return
|
|
|
|
|
val tokenType = parent.operationTokenType
|
|
|
|
|
@NonNls val newExpressionText = StringBuilder()
|
|
|
|
|
@NonNls
|
|
|
|
|
val newExpressionText = StringBuilder()
|
|
|
|
|
if (JavaTokenType.NE == tokenType) {
|
|
|
|
|
newExpressionText.append('!')
|
|
|
|
|
} else if (JavaTokenType.EQEQ != tokenType) {
|
|
|
|
@ -160,8 +162,10 @@ class AliWrapperTypeEqualityInspection : BaseInspection, AliBaseInspection {
|
|
|
|
|
val rhs = parent.rOperand ?: return
|
|
|
|
|
newExpressionText.append(rhs.text)
|
|
|
|
|
newExpressionText.append(')')
|
|
|
|
|
PsiReplacementUtil.replaceExpressionAndShorten(parent,
|
|
|
|
|
newExpressionText.toString())
|
|
|
|
|
PsiReplacementUtil.replaceExpressionAndShorten(
|
|
|
|
|
parent,
|
|
|
|
|
newExpressionText.toString()
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|