[clang] [clang-format] java import sorting should ignore imports in comments and text blocks (PR #177326)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 8 00:22:37 PST 2026
================
@@ -3786,9 +3800,8 @@ tooling::Replacements sortJavaImports(const FormatStyle &Style, StringRef Code,
ImportsInBlock.push_back(
{Identifier, Line, Prev, AssociatedCommentLines, IsStatic});
AssociatedCommentLines.clear();
- } else if (!Trimmed.empty() && !ImportsInBlock.empty()) {
- // Associating comments within the imports with the nearest import below
- AssociatedCommentLines.push_back(Line);
+ } else {
+ break;
----------------
owenca wrote:
```suggestion
// `Trimmed` is neither empty, nor a comment or a package/import
// statement.
break;
```
https://github.com/llvm/llvm-project/pull/177326
More information about the cfe-commits
mailing list