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);
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