mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline superclass: skip constructors without body, e.g. kotlin default constructors (IDEA-152476)
This commit is contained in:
+15
-14
@@ -171,25 +171,26 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
|
||||
final PsiMethod[] superConstructors = mySuperClass.getConstructors();
|
||||
for (PsiMethod constructor : targetClass.getConstructors()) {
|
||||
final PsiCodeBlock constrBody = constructor.getBody();
|
||||
LOG.assertTrue(constrBody != null);
|
||||
final PsiStatement[] statements = constrBody.getStatements();
|
||||
if (statements.length > 0) {
|
||||
final PsiStatement firstConstrStatement = statements[0];
|
||||
if (firstConstrStatement instanceof PsiExpressionStatement) {
|
||||
final PsiExpression expression = ((PsiExpressionStatement)firstConstrStatement).getExpression();
|
||||
if (expression instanceof PsiMethodCallExpression) {
|
||||
final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)expression).getMethodExpression();
|
||||
if (methodExpression.getText().equals(PsiKeyword.SUPER)) {
|
||||
final PsiMethod superConstructor = ((PsiMethodCallExpression)expression).resolveMethod();
|
||||
if (superConstructor != null && superConstructor.getBody() != null) {
|
||||
usages.add(new InlineSuperCallUsageInfo((PsiMethodCallExpression)expression));
|
||||
continue;
|
||||
if (constrBody != null) {
|
||||
final PsiStatement[] statements = constrBody.getStatements();
|
||||
if (statements.length > 0) {
|
||||
final PsiStatement firstConstrStatement = statements[0];
|
||||
if (firstConstrStatement instanceof PsiExpressionStatement) {
|
||||
final PsiExpression expression = ((PsiExpressionStatement)firstConstrStatement).getExpression();
|
||||
if (expression instanceof PsiMethodCallExpression) {
|
||||
final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)expression).getMethodExpression();
|
||||
if (methodExpression.getText().equals(PsiKeyword.SUPER)) {
|
||||
final PsiMethod superConstructor = ((PsiMethodCallExpression)expression).resolveMethod();
|
||||
if (superConstructor != null && superConstructor.getBody() != null) {
|
||||
usages.add(new InlineSuperCallUsageInfo((PsiMethodCallExpression)expression));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//insert implicit call to super
|
||||
for (PsiMethod superConstructor : superConstructors) {
|
||||
if (superConstructor.getParameterList().getParametersCount() == 0) {
|
||||
|
||||
Reference in New Issue
Block a user