Skip to content
Snippets Groups Projects
Commit a1290a65 authored by Daniel Jasper's avatar Daniel Jasper
Browse files

clang-format: [JS] JavaScript does not have the */&/&& madness.

Before:
  e&& e.SomeFunction();

After:
  e && e.SomeFunction();

Yeah, this might be useful for C++, too, but it is not such a frequent
pattern there (plus the fix is much harder).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217237 91177308-0d34-0410-b5e6-96231b3b80d8
parent b69f76c2
No related branches found
No related tags found
No related merge requests found
...@@ -917,6 +917,9 @@ private: ...@@ -917,6 +917,9 @@ private:
/// \brief Return the type of the given token assuming it is * or &. /// \brief Return the type of the given token assuming it is * or &.
TokenType determineStarAmpUsage(const FormatToken &Tok, bool IsExpression, TokenType determineStarAmpUsage(const FormatToken &Tok, bool IsExpression,
bool InTemplateArgument) { bool InTemplateArgument) {
if (Style.Language == FormatStyle::LK_JavaScript)
return TT_BinaryOperator;
const FormatToken *PrevToken = Tok.getPreviousNonComment(); const FormatToken *PrevToken = Tok.getPreviousNonComment();
if (!PrevToken) if (!PrevToken)
return TT_UnaryOperator; return TT_UnaryOperator;
......
...@@ -83,6 +83,10 @@ TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) { ...@@ -83,6 +83,10 @@ TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) {
verifyFormat("var b = a.map((x) => x + 1);"); verifyFormat("var b = a.map((x) => x + 1);");
} }
TEST_F(FormatTestJS, UnderstandsAmpAmp) {
verifyFormat("e && e.SomeFunction();");
}
TEST_F(FormatTestJS, LiteralOperatorsCanBeKeywords) { TEST_F(FormatTestJS, LiteralOperatorsCanBeKeywords) {
verifyFormat("not.and.or.not_eq = 1;"); verifyFormat("not.and.or.not_eq = 1;");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment