[PATCH] D21597: clang-format: [JS] recognize more type locations.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 23 03:14:08 PDT 2016
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Basically looks good.
================
Comment at: lib/Format/TokenAnnotator.cpp:155
@@ +154,3 @@
+ } else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous &&
+ Left->Previous->is(TT_JsTypeColon)) {
+ // let x: (SomeType);
----------------
I'd merge this one in with the previous.. And maybe even the one from above so that we end up with:
} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous &&
(Line.First->is(Keywords.kw_type) ||
Left->Previous->isOneOf(Keywords.kw_function, TT_JsTypeColon) ||
(Left->Previous->endsSequence(tok::identifier,
Keywords.kw_function)))) {
(in order for Line.First to be "type", Left->Previous cannot be nullptr, so this should be equivalent)
================
Comment at: lib/Format/TokenAnnotator.cpp:664
@@ -655,2 +663,3 @@
}
+
return true;
----------------
nit: undo
================
Comment at: lib/Format/TokenAnnotator.cpp:926
@@ +925,3 @@
+ // Type aliases use `type X = ...;` in TypeScript.
+ !(Style.Language == FormatStyle::LK_JavaScript &&
+ Line.First->is(Keywords.kw_type)) &&
----------------
I'd move the ! into the parentheses, but doesn't matter much.
http://reviews.llvm.org/D21597
More information about the cfe-commits
mailing list