Minor, move isEmpty, isCallToThis to JetConstructorDelegationCall

This commit is contained in:
Denis Zharkov
2015-03-23 12:05:36 +03:00
parent 023e1a13a9
commit 555f9e7c06
6 changed files with 17 additions and 14 deletions
@@ -1441,9 +1441,7 @@ public class JetControlFlowProcessor {
processParameters(constructor.getValueParameters());
generateCallOrMarkUnresolved(constructor.getDelegationCall());
if (constructor.getDelegationCall() != null &&
constructor.getDelegationCall().getCalleeExpression() != null &&
!constructor.getDelegationCall().getCalleeExpression().isThis()
if (constructor.getDelegationCall() != null && !constructor.getDelegationCall().isCallToThis()
) {
generateClassOrObjectInitializers(classOrObject);
}
@@ -418,7 +418,7 @@ public object PositioningStrategies {
public val SECONDARY_CONSTRUCTOR_DELEGATION_CALL: PositioningStrategy<JetConstructorDelegationCall> =
object : PositioningStrategy<JetConstructorDelegationCall>() {
override fun mark(element: JetConstructorDelegationCall): List<TextRange> {
if (element.getCalleeExpression()?.isEmpty() ?: false) {
if (element.isEmpty()) {
val constructor = element.getStrictParentOfType<JetSecondaryConstructor>()!!
return markElement(constructor.getConstructorKeyword())
}
@@ -64,4 +64,14 @@ public class JetConstructorDelegationCall extends JetElementImpl implements JetC
public JetConstructorDelegationReferenceExpression getCalleeExpression() {
return findChildByClass(JetConstructorDelegationReferenceExpression.class);
}
public boolean isEmpty() {
JetConstructorDelegationReferenceExpression callee = getCalleeExpression();
return callee != null && callee.getFirstChild() == null;
}
public boolean isCallToThis() {
JetConstructorDelegationReferenceExpression callee = getCalleeExpression();
return callee != null && callee.isThis();
}
}
@@ -28,8 +28,4 @@ public class JetConstructorDelegationReferenceExpression extends JetExpressionIm
public boolean isThis() {
return findChildByType(JetTokens.THIS_KEYWORD) != null;
}
public boolean isEmpty() {
return getFirstChild() == null;
}
}
@@ -316,8 +316,7 @@ public class CallResolver {
if (call.getCalleeExpression() == null) return checkArgumentTypesAndFail(context);
if (constructorDescriptor.getContainingDeclaration().getKind() == ClassKind.ENUM_CLASS &&
call.getCalleeExpression().isEmpty()) {
if (constructorDescriptor.getContainingDeclaration().getKind() == ClassKind.ENUM_CLASS && call.isEmpty()) {
return null;
}
@@ -376,7 +375,7 @@ public class CallResolver {
knownTypeParametersSubstitutor));
}
TracingStrategy tracing = calleeExpression.isEmpty() ?
TracingStrategy tracing = call.isEmpty() ?
new TracingStrategyForEmptyConstructorDelegationCall(call, context.call) :
TracingStrategyImpl.create(calleeExpression, context.call);