[PATCH] D24155: clang-format: [JS] merge requoting replacements.

Martin Probst via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 2 07:33:27 PDT 2016


mprobst marked an inline comment as done.

================
Comment at: lib/Format/Format.cpp:806
@@ -805,2 +805,3 @@
           FormatTokenLexer &Tokens, tooling::Replacements &Result) override {
+    tooling::Replacements RunResult;
     deriveLocalStyle(AnnotatedLines);
----------------
djasper wrote:
> Call this "RequoteChanges".
Done, went with `RequoteReplaces` (which is what we use in other places for the `tooling::Replacements` variable).

================
Comment at: lib/Format/Format.cpp:831
@@ -830,1 +830,3 @@
+    RunResult = RunResult.merge(Whitespaces.generateReplacements());
+    return RunResult;
   }
----------------
djasper wrote:
> Just
> 
>   return RequoteChanges.merge(Whitespaces.generateReplacements());
Done.

Somewhat related, this API was very surprising – it passes down a Replacements object, but then the caller takes every item of the returned result and adds it back into the object, causing conflicts. So the only way to correctly use the API is to ignore the parameter, or return an empty dummy object. I've changed the API to not pass down the parameter to make this a bit less misleading.


https://reviews.llvm.org/D24155





More information about the cfe-commits mailing list