Java to Kotlin converter: minor code refactoring
This commit is contained in:
@@ -101,7 +101,14 @@ class ConstructorConverter(private val converter: Converter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val bodyConverter = converter.withExpressionVisitor { ExpressionVisitor(it, usageReplacementMap) }
|
val bodyConverter = converter.withExpressionVisitor {
|
||||||
|
object : ExpressionVisitor(it, usageReplacementMap) {
|
||||||
|
override fun visitMethodCallExpression(expression: PsiMethodCallExpression) {
|
||||||
|
if (expression.isSuperConstructorCall()) return // skip it
|
||||||
|
super.visitMethodCallExpression(expression)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
postProcessBody(bodyConverter.convertBlock(body, false, { !statementsToRemove.contains(it) }))
|
postProcessBody(bodyConverter.convertBlock(body, false, { !statementsToRemove.contains(it) }))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -59,9 +59,6 @@ fun PsiClass.getPrimaryConstructor(): PsiMethod? {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun PsiElement.isInsidePrimaryConstructor(): Boolean
|
|
||||||
= getContainingConstructor()?.isPrimaryConstructor() ?: false
|
|
||||||
|
|
||||||
fun PsiElement.getContainingMethod(): PsiMethod? {
|
fun PsiElement.getContainingMethod(): PsiMethod? {
|
||||||
var context = getContext()
|
var context = getContext()
|
||||||
while (context != null) {
|
while (context != null) {
|
||||||
|
|||||||
@@ -163,8 +163,6 @@ open class ExpressionVisitor(private val converter: Converter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitMethodCallExpression(expression: PsiMethodCallExpression) {
|
override fun visitMethodCallExpression(expression: PsiMethodCallExpression) {
|
||||||
if (expression.isSuperConstructorCall() && expression.isInsidePrimaryConstructor()) return // skip it
|
|
||||||
|
|
||||||
val methodExpr = expression.getMethodExpression()
|
val methodExpr = expression.getMethodExpression()
|
||||||
val arguments = expression.getArgumentList().getExpressions()
|
val arguments = expression.getArgumentList().getExpressions()
|
||||||
val target = methodExpr.resolve()
|
val target = methodExpr.resolve()
|
||||||
|
|||||||
Reference in New Issue
Block a user