Add else entry for when quick fix
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.LocalTimeCounter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -82,6 +83,10 @@ public class JetPsiFactory {
|
||||
return property.findElementAt(3);
|
||||
}
|
||||
|
||||
public static PsiElement createNewLineWhiteSpace(Project project) {
|
||||
return createWhiteSpace(project, "\n");
|
||||
}
|
||||
|
||||
public static JetClass createClass(Project project, String text) {
|
||||
return createDeclaration(project, text, JetClass.class);
|
||||
}
|
||||
@@ -147,6 +152,11 @@ public class JetPsiFactory {
|
||||
return function.getValueParameters().get(0);
|
||||
}
|
||||
|
||||
public static JetWhenEntry createElseWhenEntry(Project project) {
|
||||
JetNamedFunction function = createFunction(project, "fun foo() { when(12) { else -> { } } }");
|
||||
return PsiTreeUtil.findChildOfType(function, JetWhenEntry.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetImportDirective createImportDirective(Project project, @NotNull String path) {
|
||||
return createImportDirective(project, new ImportPath(path));
|
||||
|
||||
@@ -57,4 +57,10 @@ public class JetWhenExpression extends JetExpressionImpl {
|
||||
public PsiElement getWhenKeywordElement() {
|
||||
return findChildByType(JetTokens.WHEN_KEYWORD);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getCloseBraceNode() {
|
||||
ASTNode openBraceNode = getNode().findChildByType(JetTokens.RBRACE);
|
||||
return openBraceNode != null ? openBraceNode.getPsi() : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user