================
@@ -3767,12 +3767,26 @@ tooling::Replacements sortJavaImports(const FormatStyle
&Style, StringRef Code,
Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
StringRef Trimmed = Line.trim();
- if (isClangFormatOff(Trimmed))
+ if (Trimmed.empty()) {
+ // Skip empty lines.
+ } else if (isClangFormatOff(Trimmed)) {
FormattingOff = true;
- else if (isClangFormatOn(Trimmed))
+ } else if (isClangFormatOn(Trimmed)) {
FormattingOff = false;
-
- if (ImportRegex.match(Line, &Matches)) {
+ } else if (Trimmed.starts_with("//")) {
+ if (!ImportsInBlock.empty())
----------------
owenca wrote:
```suggestion
// Associating comments within the imports with the nearest import below.
if (HasImport)
```
Keep the original comment.
https://github.com/llvm/llvm-project/pull/177326
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits