mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-06 16:08:05 +00:00
Java formatting comes from jdtls' Eclipse formatter, whose defaults differ from the IntelliJ IDEA code style. Settings › Editor › Code Style › Java now offers a formatting profile: Default (unchanged), IntelliJ IDEA, or a custom Eclipse formatter XML (absolute or project-relative path). The IntelliJ IDEA profile is a bundled Eclipse formatter XML that follows IDEA's default Java code style item by item (indents, aligned multi-line parameters, annotation placement, else/catch/finally on the same line, array initializers, lambdas, blank lines, comments not reflowed). Manual line breaks are kept; lines longer than 120 columns wrap where necessary, which differs from IDEA's default of not wrapping. The profile reaches a running jdtls through didChangeConfiguration without a restart; an unreadable custom file shows a warning and leaves code intelligence running. Code style changes reconfigure language servers without scheduling Kotlin bridge builds. Also drops two catalog entries whose texts are no longer used. Fixes #649
66 lines
2.4 KiB
Java
66 lines
2.4 KiB
Java
package demo;
|
|
|
|
import java.util.List;
|
|
import java.util.function.Function;
|
|
|
|
@Deprecated
|
|
@SuppressWarnings("unused")
|
|
public class FormatterSample {
|
|
@Deprecated
|
|
@SuppressWarnings("unused")
|
|
private String first = "first";
|
|
private String second = "second";
|
|
|
|
/** A description which remains on a very long single line to check whether formatting introduces wrapping when the right margin is exceeded with ordinary words in a JavaDoc comment. */
|
|
@Deprecated
|
|
@SuppressWarnings("unused")
|
|
public String combine(@Deprecated @SuppressWarnings("unused") String firstParameterWithAVeryLongName,
|
|
String secondParameterWithAVeryLongName, String thirdParameterWithAVeryLongName) {
|
|
if (firstParameterWithAVeryLongName == null) {
|
|
return "none";
|
|
} else {
|
|
try {
|
|
return List
|
|
.of(firstParameterWithAVeryLongName, secondParameterWithAVeryLongName,
|
|
thirdParameterWithAVeryLongName)
|
|
.stream().map(value -> value.trim()).filter(value -> !value.isEmpty()).findFirst()
|
|
.orElse("none");
|
|
} catch (RuntimeException problem) {
|
|
throw problem;
|
|
} finally {
|
|
System.out.println("done");
|
|
}
|
|
}
|
|
}
|
|
|
|
public void multiline(String firstParameter,
|
|
String secondParameter,
|
|
String thirdParameter) {
|
|
combine(firstParameter,
|
|
secondParameter,
|
|
thirdParameter);
|
|
List.of(firstParameter, secondParameter)
|
|
.stream()
|
|
.map(value -> value.trim())
|
|
.forEach(System.out::println);
|
|
}
|
|
|
|
public void retained(String firstParameter, // retain declaration break
|
|
String secondParameter) {
|
|
combine(firstParameter, // retain call break
|
|
secondParameter, "third");
|
|
}
|
|
|
|
public void arrays() {
|
|
int[] values = new int[]{1, 2, 3};
|
|
int[] empty = new int[]{};
|
|
Function<String, String> clean = value -> {
|
|
return value.trim();
|
|
};
|
|
Runnable run = () -> {
|
|
System.out.println(values.length);
|
|
};
|
|
}
|
|
// A comment which intentionally exceeds the right margin and should remain unwrapped with the built-in profile even when it contains many ordinary words and spaces to split on.
|
|
}
|