Added new options to ClangFormat VSIX package:
- fallback-style
- assume-filename
- sort-includes.
Changed version to 1.1 (otherwise one couldn't update).
Fixed clang-format escaping of XML reserved characters.
Differential D13549
Added new options to ClangFormat VSIX package. curdeius on Oct 8 2015, 3:28 AM. Authored by
Details Added new options to ClangFormat VSIX package:
Changed version to 1.1 (otherwise one couldn't update). Fixed clang-format escaping of XML reserved characters.
Diff Detail Event TimelineComment Actions Please always add cfe-commits as "subscriber" so that the email also goes to the list.
Comment Actions Add option converters for filenames (prohibiting quotes) and styles (giving a list of predefined styles). Comment Actions +aaron, as token Windows Wizard +rnk, as I was told you might know people who are in a good position to review MS specific stuff (perhaps engineers from MS might be able to help here? :) Comment Actions Generally looks good to me, with a few small nits.
Comment Actions We're waiting for Reid to find somebody who is good at reviewing this in detail. Comment Actions While we are waiting, submitted the changes to ClangFormat.cpp in r250440. Thank you! Comment Actions Oops, I didn't know that. Zach knows C#, but I don't think any of us are VSIX experts. Comment Actions No obvious problems, mostly just style issues. Feel free to consider them optional.
Comment Actions Hi Zachary, just to answer your comments. I have done it on purpose not to use enum, because clang-format style can be actually a JSON string, e.g. {BasedOnStyle: "LLVM", IndentWidth: 4}, so it wouldn't translate into an enum (to my knowledge at least). Besides, I would like to have the possibility not to add a new enum value if there is a new style in clang-format.
Comment Actions Where is the code in the CL that handles extracting that value from a JSON string? Because it looks like you're just building an array list of the trivial non-JSON style names, so why couldn't that be an enum? I don't know mucha bout clang-format, but looking at the comments it seems like the JSON only comes into play when you're reading a .clang-format file, and in that case the value of the enum would be Style.File (until you finish reading that, at which case you set it to Style.LLVM etc). I'm also not sure what advantage you get by not having to add an enum if there is a new style? You have to change the code either way, and by not using an enum you are likely to miss some of the places in the code that manipulate or process the style since you're bypassing the type system. Comment Actions
The Style option is actually passed to clang-format -style parameter and it's clang-format that parses it. It can be a predefined type (one of: 'none', 'file', 'LLVM', etc.) or a JSON (or JSON-like?) string.
I wanted to say that it would be better if the user didn't have to wait until the VSIX plugins gets updated after a new style is added to clang-format. Comment Actions This is now part of the latest snapshot at http://llvm.org/builds/ I had to dig around a bit to figure out where these settings are actually exposed. Should we mention that in the documentation somewhere? Actually, do we even have any documentation for this plugin? |
How about an enum instead?
Then change the StyleConverter to just convert the enum value to its corresponding string representation?