Move caret into generated else branch

This commit is contained in:
Nikolay Krasko
2012-10-25 18:04:48 +04:00
parent 6a6282b038
commit b62fe5f5fb
4 changed files with 31 additions and 11 deletions
@@ -152,9 +152,15 @@ 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 JetWhenEntry createWhenEntry(@NotNull Project project, @NotNull String entryText) {
JetNamedFunction function = createFunction(project, "fun foo() { when(12) { " + entryText + " } }");
JetWhenEntry whenEntry = PsiTreeUtil.findChildOfType(function, JetWhenEntry.class);
assert whenEntry != null : "Couldn't generate when entry";
assert entryText.equals(whenEntry.getText()) : "Generate when entry text differs from the given text";
return whenEntry;
}
@NotNull