This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] Fix enum handling.
ClosedPublic

Authored by mprobst on Jun 16 2015, 3:08 PM.

Details

Reviewers
djasper
Summary

clang-format: [JS] Consistently format top level enums.

Object literal style enums are forced onto multiple lines for JS enums.
This change produces the same formatting for enums using the actual
TypeScript enum syntax:

enum Color {
  Blue,
  Red,
  Tuna
}

clang-format: use clang-format on clang-format.

clang-format: [JS] put enums on separate lines.

This change identifies enums in JS as complete declarations so that
trailing statements are formatted on a separate line.

enum Color { Blue, Green }
var x;

clang-format: AnnotatedLine.StartsWith.

This supports checking for an arbitrary line
prefix, which is useful for e.g. JavaScript
export class vs class.

Diff Detail

Event Timeline

mprobst updated this revision to Diff 27784.Jun 16 2015, 3:08 PM
mprobst retitled this revision from to clang-format: AnnotatedLine.StartsWith..
mprobst updated this object.
mprobst added a reviewer: djasper.
mprobst added subscribers: klimek, Unknown Object (MLST).
mprobst retitled this revision from clang-format: AnnotatedLine.StartsWith. to clang-format: [JS] Fix enum handling..Jun 16 2015, 3:18 PM
mprobst updated this object.
djasper accepted this revision.Jun 17 2015, 2:49 AM
djasper edited edge metadata.

Comments mainly FYI. I have addressed them and submitted this as r239892-r239894. Thank you.

lib/Format/TokenAnnotator.h
83

I think now that we are writing such a fancy function, we should make it ignore comments. Otherwise, we would need to handle them everywhere.

84

In LLVM style, functions should use lowerCamelCase, variables on the other hand are UpperCamelCase (yeah, we should change that, but that's the way it is).

118

If anything, use nullptr, but in LLVM style, we actually just use the bool conversion.

lib/Format/UnwrappedLineParser.cpp
776–778

Lets just use the same comment I have used for parseRecord.

1515

I think this comment should remain here. It explains why there is no call to addUnwrappedLine() here (maybe the comment should actually say so).

This revision is now accepted and ready to land.Jun 17 2015, 2:49 AM
djasper closed this revision.Jun 17 2015, 2:49 AM