Skip to content

Commit 12d3f50

Browse files
authored
Bump Google java format version to 1.28.0 (#14038)
#14019 is blocked by this - the current google java format version is failing because it tries to call remove method from JDK - see https://github.com/enso-org/enso/actions/runs/17916525266/job/50940077628?pr=14019#step:5:245 # Important Notes The only notable change is in ff3fec5 . Every thing else is just automatic `sbt javafmtAll` formatting.
1 parent 7c783ca commit 12d3f50

File tree

212 files changed

+6866
-6236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+6866
-6236
lines changed

engine/common/src/main/java/org/enso/common/HostEnsoUtils.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import org.graalvm.polyglot.PolyglotException;
55

66
public final class HostEnsoUtils {
7-
private HostEnsoUtils() {
8-
}
7+
private HostEnsoUtils() {}
98

109
/**
1110
* Extracts a string representation for a polyglot exception.
@@ -14,12 +13,13 @@ private HostEnsoUtils() {
1413
* @return message representing the exception
1514
*/
1615
public static String findExceptionMessage(Throwable ex) {
17-
return ex.getMessage() != null ? ex.getMessage() : switch (ex) {
18-
case PolyglotException exception when exception.isHostException() ->
19-
exception.asHostException().getClass().getName();
20-
default ->
21-
ex.getClass().getName();
22-
};
16+
return ex.getMessage() != null
17+
? ex.getMessage()
18+
: switch (ex) {
19+
case PolyglotException exception when exception.isHostException() ->
20+
exception.asHostException().getClass().getName();
21+
default -> ex.getClass().getName();
22+
};
2323
}
2424

2525
/**

engine/runner/src/main/java/org/enso/runner/Main.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,11 +1018,11 @@ private void runRepl(
10181018
var mainMethodName = "internal_repl_entry_point___";
10191019
var dummySourceToTriggerRepl =
10201020
"""
1021-
from Standard.Base import all
1022-
import Standard.Base.Runtime.Debug
1021+
from Standard.Base import all
1022+
import Standard.Base.Runtime.Debug
10231023
1024-
$mainMethodName = Debug.breakpoint
1025-
"""
1024+
$mainMethodName = Debug.breakpoint
1025+
"""
10261026
.replace("$mainMethodName", mainMethodName);
10271027
var replModuleName = "Internal_Repl_Module___";
10281028
var projectRoot = projectPath != null ? projectPath : "";
@@ -1267,7 +1267,7 @@ private boolean shouldEnableIrCaches(CommandLine line) {
12671267
if (line.hasOption(ENABLE_STATIC_ANALYSIS_OPTION)) {
12681268
if (line.hasOption(IR_CACHES_OPTION)) {
12691269
throw exitFail(
1270-
""
1270+
""
12711271
+ ENABLE_STATIC_ANALYSIS_OPTION
12721272
+ " requires IR caches to be disabled, so --"
12731273
+ IR_CACHES_OPTION
@@ -1602,8 +1602,9 @@ private void launch(String[] args) throws IOException, InterruptedException, URI
16021602
launchJvm(originalCwdOrNull, line, props, component, javaExecutable);
16031603
return;
16041604
} else {
1605-
throw exitFail("Cannot find java executable to run in JVM mode. JVM mode " +
1606-
"was enforced either by `--jvm` option or by project configuration.");
1605+
throw exitFail(
1606+
"Cannot find java executable to run in JVM mode. JVM mode "
1607+
+ "was enforced either by `--jvm` option or by project configuration.");
16071608
}
16081609
}
16091610
}

engine/runner/src/main/java/org/enso/runner/Repl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ final class Repl implements SessionManager {
2323
switch (content) {
2424
case ":list", ":l" -> {
2525
var bindings = executor.listBindings();
26-
bindings.foreachEntry((name, value) -> {
27-
replIO.println(name + " = " + value);
28-
return null;
29-
});
26+
bindings.foreachEntry(
27+
(name, value) -> {
28+
replIO.println(name + " = " + value);
29+
return null;
30+
});
3031
}
3132
case ":quit", "q" -> {
3233
continueRunning = false;

engine/runner/src/test/java/org/enso/runner/UtilsTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public void printStackTrace1() throws Exception {
2525
var f = folder.newFile("p.enso");
2626
var code =
2727
"""
28-
from Standard.Base import all
28+
from Standard.Base import all
2929
30-
a = b
31-
b = c
32-
c = Panic.throw "foo"
30+
a = b
31+
b = c
32+
c = Panic.throw "foo"
3333
34-
main = a
35-
""";
34+
main = a
35+
""";
3636
Files.writeString(f.toPath(), code);
3737

3838
var lines = new ArrayList<String>();
@@ -55,10 +55,11 @@ public void printStackTrace1() throws Exception {
5555

5656
assertEquals(
5757
"""
58-
Execution finished with an error: foo
59-
at <enso> throw(Internal)
60-
at <enso> c(Internal)
61-
at <enso> main(Internal)""",
58+
Execution finished with an error: foo
59+
at <enso> throw(Internal)
60+
at <enso> c(Internal)
61+
at <enso> main(Internal)\
62+
""",
6263
lines.stream().collect(Collectors.joining("\n")));
6364
}
6465

engine/runtime-benchmarks/src/main/java/org/enso/compiler/benchmarks/CodeGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public String createExpression(List<String> identifiers, int size) {
162162

163163
return switch (size) {
164164
case 0 -> nextLiteral();
165-
// Either a single identifier or a method call on the identifier
165+
// Either a single identifier or a method call on the identifier
166166
case 1 -> {
167167
var sb = new StringBuilder();
168168
var ident = chooseIdentifier(identifiers);
@@ -174,7 +174,7 @@ public String createExpression(List<String> identifiers, int size) {
174174
}
175175
yield sb.toString();
176176
}
177-
// Method call or binary operator
177+
// Method call or binary operator
178178
case 2 -> {
179179
var sb = new StringBuilder();
180180
var shouldCallMethod = random.nextBoolean();
@@ -196,7 +196,7 @@ public String createExpression(List<String> identifiers, int size) {
196196
}
197197
yield sb.toString();
198198
}
199-
// Split into two expressions with random size
199+
// Split into two expressions with random size
200200
default -> {
201201
var sb = new StringBuilder();
202202
var shouldCallMethod = random.nextBoolean();

engine/runtime-benchmarks/src/main/java/org/enso/compiler/benchmarks/module/ImportStandardLibrariesBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class ImportStandardLibrariesBenchmark {
6666
"Connection_Options.Connection_Options");
6767

6868
private static final String IMPORTS =
69-
"""
69+
"""
7070
from Standard.Base import all
7171
from Standard.Table import all
7272
from Standard.Database import all

engine/runtime-benchmarks/src/main/java/org/enso/compiler/benchmarks/module/ManyErrorsBenchmark.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@ public void setup(BenchmarkParams params) throws IOException {
7272
for (int i = 0; i < ERRORS_CNT; i++) {
7373
var rndInt = random.nextInt(0, 3);
7474
switch (rndInt) {
75-
// Expression with unknown identifiers
75+
// Expression with unknown identifiers
7676
case 0 -> {
7777
var expr = codeGen.createExpression(UNDEFINED_IDENTIFIERS, EXPR_SIZE);
7878
sb.append(" ").append(expr).append(System.lineSeparator());
7979
}
80-
// Inline type ascription with unknown identifier
80+
// Inline type ascription with unknown identifier
8181
case 1 -> {
8282
var expr = codeGen.createExpression(definedIdentifiers, EXPR_SIZE);
8383
sb.append(" ")
8484
.append(" var : (Type.Constructor.Foo Bar.Baz A B) = ")
8585
.append(expr)
8686
.append(System.lineSeparator());
8787
}
88-
// Put arrows before, after, and between expressions
88+
// Put arrows before, after, and between expressions
8989
case 2 -> {
9090
var expr1 = codeGen.createExpression(definedIdentifiers, EXPR_SIZE);
9191
var expr2 = codeGen.createExpression(definedIdentifiers, EXPR_SIZE);

engine/runtime-benchmarks/src/main/java/org/enso/compiler/benchmarks/module/ManyNestedBlocksBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private void createNestedBlocks(int nestedBlockIdx) {
165165
.append(System.lineSeparator());
166166
createNestedBlocks(nestedBlockIdx + 1);
167167
}
168-
// Create a nested anonymous function
168+
// Create a nested anonymous function
169169
case 3 -> {
170170
var argsCnt = random.nextInt(1, ANONYMOUS_FUNC_MAX_ARGS);
171171
sb.append(spaces);

engine/runtime-benchmarks/src/main/java/org/enso/interpreter/bench/benchmarks/semantic/CallableBenchmarks.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class CallableBenchmarks {
2626
private static final long HUNDRED_MILLION = 100_000_000L;
2727
private static final String SUM_TCO_FROM_CALL_CODE =
28-
"""
28+
"""
2929
from Standard.Base.Data.Numbers import all
3030
3131
type Foo
@@ -40,7 +40,7 @@ public class CallableBenchmarks {
4040
""";
4141

4242
private static final String SUM_TCO_METHOD_CALL_CODE =
43-
"""
43+
"""
4444
summator = acc -> current ->
4545
if current == 0 then acc else @Tail_Call summator (acc + current) (current - 1)
4646
@@ -50,7 +50,7 @@ public class CallableBenchmarks {
5050
""";
5151

5252
private static final String SUM_TCO_METHOD_CALL_WITH_NAMED_ARGUMENTS_CODE =
53-
"""
53+
"""
5454
summator = acc -> current ->
5555
if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)
5656
@@ -60,7 +60,7 @@ public class CallableBenchmarks {
6060
""";
6161

6262
private static final String SUM_TCO_METHOD_CALL_WITH_DEFAULTED_ARGUMENTS_CODE =
63-
"""
63+
"""
6464
summator = (acc = 0) -> current ->
6565
if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)
6666

engine/runtime-benchmarks/src/main/java/org/enso/interpreter/bench/benchmarks/semantic/EqualsBenchmarks.java

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -60,39 +60,39 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
6060
var codeBuilder =
6161
new StringBuilder(
6262
"""
63-
import Standard.Base.Data.Range.Extensions
64-
import Standard.Base.Data.Numbers.Number
65-
import Standard.Base.Data.Ordering.Ordering
66-
import Standard.Base.Data.Ordering.Comparable
67-
68-
type Num
69-
Value n
70-
71-
Num.from (that:Number) = Num.Value that
72-
Comparable.from (_:Number) = Num_Comparator
73-
Comparable.from (_:Num) = Num_Comparator
74-
75-
type Num_Comparator
76-
compare x:Num y:Num = Ordering.compare x.n y.n
77-
hash x:Num = Ordering.hash x.n
78-
79-
type Node
80-
C1 f1
81-
C2 f1 f2
82-
C3 f1 f2 f3
83-
C4 f1 f2 f3 f4
84-
C5 f1 f2 f3 f4 f5
85-
Nil
86-
Value value
87-
88-
eq_vec vec1 vec2 =
89-
(0.up_to vec1.length).map idx->
90-
v1 = vec1.at idx
91-
v2 = vec2.at idx
92-
v1 == v2
93-
94-
eq x y = x == y
95-
""");
63+
import Standard.Base.Data.Range.Extensions
64+
import Standard.Base.Data.Numbers.Number
65+
import Standard.Base.Data.Ordering.Ordering
66+
import Standard.Base.Data.Ordering.Comparable
67+
68+
type Num
69+
Value n
70+
71+
Num.from (that:Number) = Num.Value that
72+
Comparable.from (_:Number) = Num_Comparator
73+
Comparable.from (_:Num) = Num_Comparator
74+
75+
type Num_Comparator
76+
compare x:Num y:Num = Ordering.compare x.n y.n
77+
hash x:Num = Ordering.hash x.n
78+
79+
type Node
80+
C1 f1
81+
C2 f1 f2
82+
C3 f1 f2 f3
83+
C4 f1 f2 f3 f4
84+
C5 f1 f2 f3 f4 f5
85+
Nil
86+
Value value
87+
88+
eq_vec vec1 vec2 =
89+
(0.up_to vec1.length).map idx->
90+
v1 = vec1.at idx
91+
v2 = vec2.at idx
92+
v1 == v2
93+
94+
eq x y = x == y
95+
""");
9696
// Indexes where `True` is expected. Inside the generated vectors, on a predefined indexes,
9797
// we put "constant" values, such that when the elements at these indexes are compared,
9898
// `True` is returned.
@@ -169,7 +169,8 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
169169
default -> throw new IllegalStateException("Unexpected benchmark: " + params.getBenchmark());
170170
}
171171

172-
codeBuilder.append("""
172+
codeBuilder.append(
173+
"""
173174
bench _ = eq_vec vec1 vec2
174175
""");
175176

@@ -418,8 +419,8 @@ public String createSource() {
418419
case 3 -> "(Node.C3 ";
419420
case 4 -> "(Node.C4 ";
420421
case 5 -> "(Node.C5 ";
421-
default -> throw new AssertionError(
422-
"Unexpected number of children: " + children.size());
422+
default ->
423+
throw new AssertionError("Unexpected number of children: " + children.size());
423424
};
424425
var sb = new StringBuilder();
425426
sb.append(ctor);

0 commit comments

Comments
 (0)