Improve AddInitKeyword quickfix
- Extract quickfix method - Delete redundant semicolon - Do not replace initializer PSI element
This commit is contained in:
@@ -58,6 +58,11 @@ public class JetClassInitializer extends JetDeclarationStub<KotlinPlaceHolderStu
|
||||
}
|
||||
|
||||
public boolean hasInitKeyword() {
|
||||
return findChildByType(JetTokens.INIT_KEYWORD) != null;
|
||||
return getInitKeyword() != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getInitKeyword() {
|
||||
return findChildByType(JetTokens.INIT_KEYWORD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,9 +230,11 @@ public class JetPsiFactory(private val project: Project) {
|
||||
}
|
||||
|
||||
public fun createAnonymousInitializer(): JetClassInitializer {
|
||||
return createClass("class A { {} }").getAnonymousInitializers().first()
|
||||
return createClass("class A { init {} }").getAnonymousInitializers().first()
|
||||
}
|
||||
|
||||
public fun createInitKeyword(): PsiElement = createAnonymousInitializer().getInitKeyword()!!
|
||||
|
||||
public fun createEmptyClassBody(): JetClassBody {
|
||||
return createClass("class A(){}").getBody()!!
|
||||
}
|
||||
|
||||
@@ -408,6 +408,14 @@ public fun PsiElement.prevLeafSkipWhitespacesAndComments(): PsiElement? {
|
||||
return leaf
|
||||
}
|
||||
|
||||
public fun PsiElement.prevLeafSkipWhitespaces(): PsiElement? {
|
||||
var leaf = prevLeaf()
|
||||
while (leaf is PsiWhiteSpace) {
|
||||
leaf = leaf!!.prevLeaf()
|
||||
}
|
||||
return leaf
|
||||
}
|
||||
|
||||
public fun PsiElement.nextLeafSkipWhitespacesAndComments(): PsiElement? {
|
||||
var leaf = nextLeaf()
|
||||
while (leaf is PsiWhiteSpace || leaf is PsiComment) {
|
||||
|
||||
Reference in New Issue
Block a user