forked from OSchip/llvm-project
clang-format: [Java] Fix breaking after annotations.
Before: @Annotation1 // comment @Annotation2 class C {} After: @Annotation1 // comment @Annotation2 class C {} llvm-svn: 222825
This commit is contained in:
parent
2db4107a36
commit
07013a42d2
|
@ -864,7 +864,8 @@ private:
|
|||
Current.Previous->is(tok::at) &&
|
||||
Current.isNot(Keywords.kw_interface)) {
|
||||
const FormatToken &AtToken = *Current.Previous;
|
||||
if (!AtToken.Previous || AtToken.Previous->is(TT_LeadingJavaAnnotation))
|
||||
const FormatToken *Previous = AtToken.getPreviousNonComment();
|
||||
if (!Previous || Previous->is(TT_LeadingJavaAnnotation))
|
||||
Current.Type = TT_LeadingJavaAnnotation;
|
||||
else
|
||||
Current.Type = TT_JavaAnnotation;
|
||||
|
|
|
@ -206,6 +206,9 @@ TEST_F(FormatTestJava, Annotations) {
|
|||
verifyFormat("@Override\n"
|
||||
"@Nullable\n"
|
||||
"public String getNameIfPresent() {}");
|
||||
verifyFormat("@Override // comment\n"
|
||||
"@Nullable\n"
|
||||
"public String getNameIfPresent() {}");
|
||||
|
||||
verifyFormat("@SuppressWarnings(value = \"unchecked\")\n"
|
||||
"public void doSomething() {}");
|
||||
|
|
Loading…
Reference in New Issue