[analysis_server] Fix a test that's failing on Windows
This code uses `Element.documentationComment` in the generated code and assumes it has the correct line endings. However, `documentationComment` is always normalized to `\n` so that's what we need to replace when building the new code.
Change-Id: I83c73bfeccbce7ec8621da2759f042f736fbe4d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337724
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_enum.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_enum.dart
index 77cf8f4..70a1847 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_enum.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_enum.dart
@@ -205,8 +205,11 @@
constantsBuffer.write(indent);
}
if (documentationComment != null) {
- constantsBuffer
- .write(documentationComment.replaceAll(eol, '$eol$indent'));
+ constantsBuffer.write(
+ // Always replace '\n' because documentationComment is normalized to
+ // always '\n' (in `getCommentNodeRawText`).
+ documentationComment.replaceAll('\n', '$eol$indent'),
+ );
constantsBuffer.write('$eol$indent');
}
constantsBuffer.write(field.name);