File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
main/java/com/google/googlejavaformat/java
test/java/com/google/googlejavaformat/java Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,11 @@ private List<String> wrapLineComments(
117117 int length = matcher .group (1 ).length ();
118118 line = Strings .repeat ("/" , length ) + " " + line .substring (length );
119119 }
120+ if (line .startsWith ("// MOE:" )) {
121+ // don't wrap comments for https://github.com/google/MOE
122+ result .add (line );
123+ continue ;
124+ }
120125 while (line .length () + column0 > options .maxLineLength ()) {
121126 int idx = options .maxLineLength () - column0 ;
122127 // only break on whitespace characters, and ignore the leading `// `
Original file line number Diff line number Diff line change @@ -453,4 +453,22 @@ public void blankLinesImportComment() throws FormatterException {
453453 assertThat (RemoveUnusedImports .removeUnusedImports (withoutBlank )).isEqualTo (withoutBlank );
454454 assertThat (ImportOrderer .reorderImports (withoutBlank )).isEqualTo (withoutBlank );
455455 }
456+
457+ @ Test
458+ public void dontWrapMoeLineComments () throws Exception {
459+ assertThat (
460+ new Formatter ()
461+ .formatSource (
462+ "class T {\n "
463+ + " // MOE: one long incredibly"
464+ + " unbroken sentence moving from topic to topic so that no-one had a"
465+ + " chance to interrupt;\n "
466+ + "}\n " ))
467+ .isEqualTo (
468+ "class T {\n "
469+ + " // MOE: one long incredibly"
470+ + " unbroken sentence moving from topic to topic so that no-one had a"
471+ + " chance to interrupt;\n "
472+ + "}\n " );
473+ }
456474}
You can’t perform that action at this time.
0 commit comments