forked from OSchip/llvm-project
clang-format: [JS] "operator" is not a keyword in Java/JavaScript.
llvm-svn: 256245
This commit is contained in:
parent
cfcdbde3ce
commit
72a1b6a5f2
|
@ -1274,11 +1274,13 @@ private:
|
||||||
FormatTok->Tok.setIdentifierInfo(&Info);
|
FormatTok->Tok.setIdentifierInfo(&Info);
|
||||||
FormatTok->Tok.setKind(Info.getTokenID());
|
FormatTok->Tok.setKind(Info.getTokenID());
|
||||||
if (Style.Language == FormatStyle::LK_Java &&
|
if (Style.Language == FormatStyle::LK_Java &&
|
||||||
FormatTok->isOneOf(tok::kw_struct, tok::kw_union, tok::kw_delete)) {
|
FormatTok->isOneOf(tok::kw_struct, tok::kw_union, tok::kw_delete,
|
||||||
|
tok::kw_operator)) {
|
||||||
FormatTok->Tok.setKind(tok::identifier);
|
FormatTok->Tok.setKind(tok::identifier);
|
||||||
FormatTok->Tok.setIdentifierInfo(nullptr);
|
FormatTok->Tok.setIdentifierInfo(nullptr);
|
||||||
} else if (Style.Language == FormatStyle::LK_JavaScript &&
|
} else if (Style.Language == FormatStyle::LK_JavaScript &&
|
||||||
FormatTok->isOneOf(tok::kw_struct, tok::kw_union)) {
|
FormatTok->isOneOf(tok::kw_struct, tok::kw_union,
|
||||||
|
tok::kw_operator)) {
|
||||||
FormatTok->Tok.setKind(tok::identifier);
|
FormatTok->Tok.setKind(tok::identifier);
|
||||||
FormatTok->Tok.setIdentifierInfo(nullptr);
|
FormatTok->Tok.setIdentifierInfo(nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,11 @@ TEST_F(FormatTestJS, ReservedWords) {
|
||||||
verifyFormat("var union = 2;");
|
verifyFormat("var union = 2;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(FormatTestJS, CppKeywords) {
|
||||||
|
// Make sure we don't mess stuff up because of C++ keywords.
|
||||||
|
verifyFormat("return operator && (aa);");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(FormatTestJS, ES6DestructuringAssignment) {
|
TEST_F(FormatTestJS, ES6DestructuringAssignment) {
|
||||||
verifyFormat("var [a, b, c] = [1, 2, 3];");
|
verifyFormat("var [a, b, c] = [1, 2, 3];");
|
||||||
verifyFormat("let [a, b, c] = [1, 2, 3];");
|
verifyFormat("let [a, b, c] = [1, 2, 3];");
|
||||||
|
|
|
@ -426,6 +426,7 @@ TEST_F(FormatTestJava, CppKeywords) {
|
||||||
verifyFormat("public void union(Type a, Type b);");
|
verifyFormat("public void union(Type a, Type b);");
|
||||||
verifyFormat("public void struct(Object o);");
|
verifyFormat("public void struct(Object o);");
|
||||||
verifyFormat("public void delete(Object o);");
|
verifyFormat("public void delete(Object o);");
|
||||||
|
verifyFormat("return operator && (aa);");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FormatTestJava, NeverAlignAfterReturn) {
|
TEST_F(FormatTestJava, NeverAlignAfterReturn) {
|
||||||
|
|
Loading…
Reference in New Issue