mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 23:49:22 +08:00
clang-format: [Java] Ignore C++-specific keywords
Before: public void union (Object o); public void struct (Object o); public void delete (Object o); After: public void union(Object o); public void struct(Object o); public void delete(Object o); Patch by Harry Terkelsen, thank you! llvm-svn: 222357
This commit is contained in:
@@ -1688,6 +1688,11 @@ private:
|
||||
IdentifierInfo &Info = IdentTable.get(FormatTok->TokenText);
|
||||
FormatTok->Tok.setIdentifierInfo(&Info);
|
||||
FormatTok->Tok.setKind(Info.getTokenID());
|
||||
if (Style.Language == FormatStyle::LK_Java &&
|
||||
FormatTok->isOneOf(tok::kw_struct, tok::kw_union, tok::kw_delete)) {
|
||||
FormatTok->Tok.setKind(tok::identifier);
|
||||
FormatTok->Tok.setIdentifierInfo(nullptr);
|
||||
}
|
||||
} else if (FormatTok->Tok.is(tok::greatergreater)) {
|
||||
FormatTok->Tok.setKind(tok::greater);
|
||||
FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
|
||||
|
||||
@@ -275,5 +275,11 @@ TEST_F(FormatTestJava, MethodDeclarations) {
|
||||
getStyleWithColumns(40));
|
||||
}
|
||||
|
||||
TEST_F(FormatTestJava, CppKeywords) {
|
||||
verifyFormat("public void union(Type a, Type b);");
|
||||
verifyFormat("public void struct(Object o);");
|
||||
verifyFormat("public void delete(Object o);");
|
||||
}
|
||||
|
||||
} // end namespace tooling
|
||||
} // end namespace clang
|
||||
|
||||
Reference in New Issue
Block a user