This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] correcly format object literal methods.
ClosedPublic

Authored by mprobst on Feb 7 2017, 8:31 AM.

Details

Summary

In JavaScript, object literals can contain methods:

var x = {
  a() { return 1; },
};

Previously, clang-format always parsed nested {} inside a braced list as
further braced lists. Special case this logic for JavaScript to try
parsing as a braced list, but fall back to parsing as a child block.

Event Timeline

mprobst created this revision.Feb 7 2017, 8:31 AM
djasper accepted this revision.Feb 7 2017, 8:32 AM
djasper added inline comments.
lib/Format/UnwrappedLineParser.cpp
1306

nit: remove braces ;)

This revision is now accepted and ready to land.Feb 7 2017, 8:32 AM
This revision was automatically updated to reflect the committed changes.