Add quickfixes inserting explicit delegation calls
#KT-6963 Fixed
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user