Skip to content

Commit 4c04af3

Browse files
inuyasha82jjohnstn
andauthored
Add support for text block newline formatter settings (#2936)
* Add option for new formatter in ui * Add sample text block to preview for newlines --------- Co-authored-by: Jeff Johnston <jjohnstn@redhat.com>
1 parent 785d362 commit 4c04af3

4 files changed

Lines changed: 6 additions & 1 deletion

File tree

org.eclipse.jdt.ui/preview/formatter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,8 @@ public class Empty {}
666666
{
667667
@SuppressWarnings("unused") final @Positive int k;
668668
}
669+
String s = "123" + """
670+
abcdef""" + "789";
669671
void foo() { ;; }
670672
void empty(@SuppressWarnings("unused") final int i) { }}
671673
enum MyEnum { @Deprecated UNDEFINED(0) { }}

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ private FormatterMessages() {
233233
public static String FormatterModifyDialog_newLines_pref_before_finally_statements;
234234
public static String FormatterModifyDialog_newLines_pref_before_while_in_do_statements;
235235
public static String FormatterModifyDialog_newLines_pref_empty_statement;
236+
public static String FormatterModifyDialog_newLines_pref_textblock_statement;
236237
public static String FormatterModifyDialog_newLines_pref_end_of_file;
237238
public static String FormatterModifyDialog_newLines_pref_enum_constants;
238239
public static String FormatterModifyDialog_newLines_pref_fields;

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ FormatterModifyDialog_newLines_pref_keep_type_declaration_on_one_line=Class decl
460460
FormatterModifyDialog_newLines_pref_end_of_file=At end of file
461461
FormatterModifyDialog_newLines_pref_after_labels=After labels
462462
FormatterModifyDialog_newLines_pref_empty_statement=Before empty statement
463+
FormatterModifyDialog_newLines_pref_textblock_statement=After and before opening and closing quotes of text block
463464

464465
FormatterModifyDialog_newLines_pref_after_opening_brace_of_array_initializer=After opening brace of array initializer
465466
FormatterModifyDialog_newLines_pref_before_closing_brace_of_array_initializer=Before closing brace of array initializer

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterModifyDialog.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,7 @@ private void createNewLinesTree() {
13361336
Consumer<Section> modAll= s -> CheckboxPreference.addModifyAll(s, fImages);
13371337
fTree.builder(FormatterMessages.FormatterModifyDialog_newLines_tree_new_lines, "section-newlines") //$NON-NLS-1$
13381338
.pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_statement, DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE)
1339+
.pref(FormatterMessages.FormatterModifyDialog_newLines_pref_textblock_statement, DefaultCodeFormatterConstants.FORMATTER_PUT_TEXT_BLOCK_QUOTES_ON_NEW_LINE)
13391340
.gap()
13401341
.pref(FormatterMessages.FormatterModifyDialog_newLines_pref_after_opening_brace_of_array_initializer,
13411342
DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER)
@@ -1374,7 +1375,7 @@ private void createNewLinesTree() {
13741375
.build(null, (parent, label, key) -> {
13751376
String[] values= CheckboxPreference.DO_NOT_INSERT_INSERT;
13761377
if (parent.getKey().endsWith("-ifelse") || parent.getKey().endsWith("-simpleloops") //$NON-NLS-1$ //$NON-NLS-2$
1377-
|| DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE.equals(key)) {
1378+
|| DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE.equals(key) || DefaultCodeFormatterConstants.FORMATTER_PUT_TEXT_BLOCK_QUOTES_ON_NEW_LINE.equals(key) ) {
13781379
values= CheckboxPreference.FALSE_TRUE;
13791380
}
13801381
return fTree.addCheckbox(parent, label, key, values);

0 commit comments

Comments
 (0)