IO.enumCase(Value, "All", FormatStyle::SFS_All);
IO.enumCase(Value, "true", FormatStyle::SFS_All);
IO.enumCase(Value, "Inline", FormatStyle::SFS_Inline);
+ IO.enumCase(Value, "Empty", FormatStyle::SFS_Empty);
}
};
if (Language == FormatStyle::LK_Java) {
GoogleStyle.AlignAfterOpenBracket = false;
- GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+ GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
GoogleStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
GoogleStyle.ColumnLimit = 100;
GoogleStyle.SpaceAfterCStyleCast = true;
// If necessary, change to something smarter.
bool MergeShortFunctions =
Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_All ||
+ (Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Empty &&
+ I[1]->First->is(tok::r_brace)) ||
(Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Inline &&
TheLine->Level != 0);
AnnotatedLine &Line = **I;
// Don't merge ObjC @ keywords and methods.
- if (Line.First->isOneOf(tok::at, tok::minus, tok::plus))
+ if (Style.Language != FormatStyle::LK_Java &&
+ Line.First->isOneOf(tok::at, tok::minus, tok::plus))
return 0;
// Check that the current line allows merging. This depends on whether we
getStyleWithColumns(60));
verifyFormat("@SomeAnnotation()\n"
"abstract class aaaaaaaaaaaa\n"
- " extends bbbbbbbbbbbbbbb implements cccccccccccc {\n"
- "}",
+ " extends bbbbbbbbbbbbbbb implements cccccccccccc {}",
getStyleWithColumns(76));
verifyFormat("@SomeAnnotation()\n"
"abstract class aaaaaaaaa<a>\n"
- " extends bbbbbbbbbbbb<b> implements cccccccccccc {\n"
- "}",
+ " extends bbbbbbbbbbbb<b> implements cccccccccccc {}",
getStyleWithColumns(76));
verifyFormat("interface SomeInterface<A> extends Foo, Bar {\n"
" void doStuff(int theStuff);\n"
"}");
verifyFormat("public class SomeClass {\n"
" enum SomeThing { ABC, CDE }\n"
- " void f() {\n"
- " }\n"
+ " void f() {}\n"
"}");
verifyFormat("public class SomeClass implements SomeInterface {\n"
" enum SomeThing { ABC, CDE }\n"
- " void f() {\n"
- " }\n"
+ " void f() {}\n"
"}");
verifyFormat("enum SomeThing {\n"
" ABC,\n"
" CDE;\n"
- " void f() {\n"
- " }\n"
+ " void f() {}\n"
"}");
verifyFormat("enum SomeThing {\n"
" ABC(1, \"ABC\"),\n"
" CDE(2, \"CDE\");\n"
- " Something(int i, String s) {\n"
- " }\n"
+ " Something(int i, String s) {}\n"
"}");
verifyFormat("enum SomeThing {\n"
" ABC(new int[] {1, 2}),\n"
" CDE(new int[] {2, 3});\n"
- " Something(int[] i) {\n"
- " }\n"
+ " Something(int[] i) {}\n"
"}");
verifyFormat("public enum SomeThing {\n"
" ABC {\n"
" return \"CDE\";\n"
" }\n"
" };\n"
- " public void f() {\n"
- " }\n"
+ " public void f() {}\n"
"}");
verifyFormat("private enum SomeEnum implements Foo<?, B> {\n"
" ABC {\n"
TEST_F(FormatTestJava, ThrowsDeclarations) {
verifyFormat("public void doSooooooooooooooooooooooooooomething()\n"
- " throws LooooooooooooooooooooooooooooongException {\n}");
+ " throws LooooooooooooooooooooooooooooongException {}");
}
TEST_F(FormatTestJava, Annotations) {
verifyFormat("@Override\n"
- "public String toString() {\n}");
+ "public String toString() {}");
verifyFormat("@Override\n"
"@Nullable\n"
- "public String getNameIfPresent() {\n}");
+ "public String getNameIfPresent() {}");
verifyFormat("@SuppressWarnings(value = \"unchecked\")\n"
- "public void doSomething() {\n}");
+ "public void doSomething() {}");
verifyFormat("@SuppressWarnings(value = \"unchecked\")\n"
"@Author(name = \"abc\")\n"
- "public void doSomething() {\n}");
+ "public void doSomething() {}");
verifyFormat("DoSomething(new A() {\n"
" @Override\n"
- " public String toString() {\n"
- " }\n"
+ " public String toString() {}\n"
"});");
- verifyFormat("void SomeFunction(@Nullable String something) {\n"
- "}");
+ verifyFormat("void SomeFunction(@Nullable String something) {}");
verifyFormat("@Partial @Mock DataLoader loader;");
verifyFormat("@SuppressWarnings(value = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")\n"
verifyFormat("A.<B>doSomething();");
verifyFormat("@Override\n"
- "public Map<String, ?> getAll() {\n}");
+ "public Map<String, ?> getAll() {}");
- verifyFormat("public <R> ArrayList<R> get() {\n}");
- verifyFormat("protected <R> ArrayList<R> get() {\n}");
- verifyFormat("private <R> ArrayList<R> get() {\n}");
- verifyFormat("public static <R> ArrayList<R> get() {\n}");
- verifyFormat("public final <X> Foo foo() {\n}");
+ verifyFormat("public <R> ArrayList<R> get() {}");
+ verifyFormat("protected <R> ArrayList<R> get() {}");
+ verifyFormat("private <R> ArrayList<R> get() {}");
+ verifyFormat("public static <R> ArrayList<R> get() {}");
+ verifyFormat("public final <X> Foo foo() {}");
verifyFormat("public abstract <X> Foo foo();");
verifyFormat("<T extends B> T getInstance(Class<T> type);");
verifyFormat("Function<F, ? extends T> function;");
TEST_F(FormatTestJava, MethodDeclarations) {
verifyFormat("void methodName(Object arg1,\n"
- " Object arg2, Object arg3) {\n"
- "}",
+ " Object arg2, Object arg3) {}",
getStyleWithColumns(40));
verifyFormat("void methodName(\n"
- " Object arg1, Object arg2) {\n"
- "}",
+ " Object arg1, Object arg2) {}",
getStyleWithColumns(40));
}