This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] Introduce WrapJavaScriptImports option.
ClosedPublic

Authored by mprobst on Jun 12 2016, 6:58 PM.

Details

Summary

When turned on, clang-format wraps JavaScript imports (and importing exports),
instead of forcing the entire import statement onto one line.

Diff Detail

Event Timeline

mprobst updated this revision to Diff 60484.Jun 12 2016, 6:58 PM
mprobst retitled this revision from to clang-format: [JS] Introduce WrapJavaScriptImports option..
mprobst updated this object.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
djasper added inline comments.Jun 13 2016, 12:37 AM
include/clang/Format/Format.h
634

Wondering whether we should call this JavaScriptWrapImports so that the JS-specific options stay together. What do you think?

mprobst updated this revision to Diff 60519.Jun 13 2016, 7:25 AM
  • rename to JavaScriptWrapImports
  • re-alphabetize options list
djasper added inline comments.Jun 13 2016, 7:33 AM
lib/Format/TokenAnnotator.cpp
789

I think it is a bit dodgy to not mark the line as import statement based on this style option. Would it be a lot of work to pull the decision of whether or not to format this out a level higher?

mprobst updated this revision to Diff 60532.Jun 13 2016, 8:24 AM
  • classify as LT_ImportStatement, re-enable wrapping later
  • no early exist in TokenAnnotator: while loop is required for consumeToken().
djasper accepted this revision.Jun 13 2016, 8:50 AM
djasper edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Jun 13 2016, 8:50 AM
This revision was automatically updated to reflect the committed changes.