Add quickfixes inserting explicit delegation calls

#KT-6963 Fixed
This commit is contained in:
Denis Zharkov
2015-03-23 15:17:26 +03:00
parent d0c72c2c3d
commit b1de2066c7
21 changed files with 283 additions and 6 deletions
@@ -177,11 +177,32 @@ public class JetSecondaryConstructor extends JetDeclarationStub<KotlinPlaceHolde
return findChildByClass(JetConstructorDelegationCall.class);
}
public boolean hasEmptyDelegationCall() {
JetConstructorDelegationCall call = getDelegationCall();
return call != null && call.isEmpty();
}
@NotNull
public JetClassOrObject getClassOrObject() {
return (JetClassOrObject) getParent().getParent();
}
@NotNull
public JetConstructorDelegationCall replaceEmptyDelegationCallWithExplicit(boolean isThis) {
JetPsiFactory psiFactory = new JetPsiFactory(getProject());
JetConstructorDelegationCall current = getDelegationCall();
assert current != null && current.isEmpty()
: "Method should not be called with non-existing or non-empty delegation call: " + getText();
current.delete();
PsiElement colon = addAfter(psiFactory.createColon(), getValueParameterList());
String delegationName = isThis ? "this" : "super";
return (JetConstructorDelegationCall) addAfter(psiFactory.createConstructorDelegationCall(delegationName + "()"), colon);
}
@NotNull
public PsiElement getConstructorKeyword() {
return findNotNullChildByType(JetTokens.CONSTRUCTOR_KEYWORD);
@@ -45,4 +45,8 @@ public class JetValueArgumentList extends JetElementImpl {
return findChildByType(JetTokens.RPAR);
}
@Nullable
public PsiElement getLeftParenthesis() {
return findChildByType(JetTokens.LPAR);
}
}