java postfix templates: add braces for while loop IDEA-153730

This commit is contained in:
Andrey Starovoyt
2016-05-13 19:29:39 +03:00
parent a3d2b8f1d0
commit 134c9f30e6
3 changed files with 10 additions and 6 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,19 +24,19 @@ import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplate
public class WhileStatementPostfixTemplate extends StringBasedPostfixTemplate {
public WhileStatementPostfixTemplate() {
super("while", "while (expr)", selectorTopmost(IS_BOOLEAN));
super("while", "while (expr) {}", selectorTopmost(IS_BOOLEAN));
}
@Nullable
@Override
public String getTemplateString(@NotNull PsiElement element) {
return "while ($expr$)$END$";
return "while ($expr$) {\n$END$\n}";
}
@Override
protected boolean shouldReformat() {
return false;
return true;
}
}
@@ -1,6 +1,8 @@
public class Foo {
void m(boolean x) {
while (x)<caret>
while (x) {
<caret>
}
return;
}
}
@@ -1,6 +1,8 @@
public class Foo {
void m(Boolean x) {
while (x)<caret>
while (x) {
<caret>
}
return;
}
}