This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] avoid indent after ambient function declarations.
ClosedPublic

Authored by mprobst on Jan 3 2017, 11:45 AM.

Details

Summary

Before:

declare function foo();
  let x = 1;

After:

declare function foo();
let x = 1;

The problem was that clang-format would unconditionally try to parse a child block, even though ambient function declarations do not have a body (similar to forward declarations).

Diff Detail

Repository
rL LLVM

Event Timeline

mprobst updated this revision to Diff 82923.Jan 3 2017, 11:45 AM
mprobst retitled this revision from to clang-format: [JS] avoid indent after ambient function declarations..
mprobst updated this object.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
mprobst updated this revision to Diff 83028.Jan 4 2017, 3:41 AM
  • Handle type declarations.
sammccall accepted this revision.Jan 4 2017, 5:36 AM
sammccall added a reviewer: sammccall.
sammccall added a subscriber: sammccall.
sammccall added inline comments.
unittests/Format/FormatTestJS.cpp
382 ↗(On Diff #83028)

Maybe include an inline object return type for completeness?

This revision is now accepted and ready to land.Jan 4 2017, 5:36 AM
mprobst updated this revision to Diff 83038.Jan 4 2017, 5:46 AM
mprobst edited edge metadata.
  • Handle type declarations.
  • test for object literal return types
This revision was automatically updated to reflect the committed changes.
mprobst marked an inline comment as done.Jan 4 2017, 5:48 AM
mprobst added inline comments.
unittests/Format/FormatTestJS.cpp
382 ↗(On Diff #83028)

Done. There are still a lot of corner cases (e.g. union type with curlies in a latter type). We'd need to parse more or less the entire type grammar for that though :-/