Skip to content

Commit 53f0eae

Browse files
committed
fmt
1 parent af9ed7a commit 53f0eae

File tree

3 files changed

+71
-73
lines changed

3 files changed

+71
-73
lines changed

engine/runtime-parser-processor/src/main/java/org/enso/runtime/parser/processor/IRProcessor.java

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,15 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
110110
* <p>In this case, {@code A} <emph>depends on</emph> {@code B}, so we need to ensure that {@code
111111
* B} is processed first (a super class is generated for it first).
112112
*
113-
* @return List of classes ordered by their references. The list has the same
114-
* size as the input set.
113+
* @return List of classes ordered by their references. The list has the same size as the input
114+
* set.
115115
*/
116116
private List<TypeElement> orderByReferences(Set<TypeElement> classesToProcess) {
117117
var classesToProcessSimpleNames =
118118
classesToProcess.stream().map(type -> type.getSimpleName().toString()).toList();
119-
var classesToProcessMap = classesToProcess
120-
.stream()
121-
.collect(Collectors.toMap(
122-
tp -> tp.getQualifiedName().toString(),
123-
tp -> tp
124-
));
119+
var classesToProcessMap =
120+
classesToProcess.stream()
121+
.collect(Collectors.toMap(tp -> tp.getQualifiedName().toString(), tp -> tp));
125122
var dependencies = new HashMap<String, Set<String>>();
126123
for (var clazz : classesToProcess) {
127124
var annotatedCtors =
@@ -145,7 +142,8 @@ private List<TypeElement> orderByReferences(Set<TypeElement> classesToProcess) {
145142
var paramType = param.asType();
146143
var paramTypeElem = processingEnv.getTypeUtils().asElement(paramType);
147144
if (paramTypeElem == null) {
148-
throw new IRProcessingException("Cannot find element for type " + paramType, null);
145+
throw new IRProcessingException(
146+
"Cannot find element for type " + paramType, null);
149147
}
150148
return paramTypeElem.getSimpleName().toString();
151149
})
@@ -170,37 +168,40 @@ private List<TypeElement> orderByReferences(Set<TypeElement> classesToProcess) {
170168
}
171169
var sortedDeps = DependencySorter.topologicalSort(dependencies);
172170
// Map class names to their TypeElements
173-
var sortedDepTypes = sortedDeps.stream()
174-
.map(
175-
depName -> {
176-
var depClazz =
177-
classesToProcess.stream()
178-
.filter(clazz -> clazz.getSimpleName().toString().equals(depName))
179-
.findFirst()
180-
.orElseThrow(() -> new IRProcessingException("Class not found: " + depName, null));
181-
return depClazz;
182-
})
183-
.collect(Collectors.toCollection(ArrayList::new));
171+
var sortedDepTypes =
172+
sortedDeps.stream()
173+
.map(
174+
depName -> {
175+
var depClazz =
176+
classesToProcess.stream()
177+
.filter(clazz -> clazz.getSimpleName().toString().equals(depName))
178+
.findFirst()
179+
.orElseThrow(
180+
() -> new IRProcessingException("Class not found: " + depName, null));
181+
return depClazz;
182+
})
183+
.collect(Collectors.toCollection(ArrayList::new));
184184

185185
// Append the rest of the classesToProcess to the sortedDepTypes
186186
for (var entry : classesToProcessMap.entrySet()) {
187187
var fqn = entry.getKey();
188188
var tp = entry.getValue();
189189
// Poor man's solution. Let's hope the number of classes to process is small.
190-
var isInSortedDeps = sortedDepTypes
191-
.stream()
192-
.anyMatch(depTp -> depTp.getQualifiedName().toString().equals(fqn));
190+
var isInSortedDeps =
191+
sortedDepTypes.stream()
192+
.anyMatch(depTp -> depTp.getQualifiedName().toString().equals(fqn));
193193
if (!isInSortedDeps) {
194194
sortedDepTypes.add(tp);
195195
}
196196
}
197197
if (sortedDepTypes.size() != classesToProcess.size()) {
198198
throw new IRProcessingException(
199-
"orderByReferences failure: " +
200-
"sortedDepTypes: " + sortedDepTypes +
201-
", classesToProcess: " + classesToProcessSimpleNames,
202-
null
203-
);
199+
"orderByReferences failure: "
200+
+ "sortedDepTypes: "
201+
+ sortedDepTypes
202+
+ ", classesToProcess: "
203+
+ classesToProcessSimpleNames,
204+
null);
204205
}
205206
return sortedDepTypes;
206207
}

engine/runtime-parser-processor/src/main/java/org/enso/runtime/parser/processor/utils/Utils.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,45 @@ public static boolean isIRInterface(TypeMirror type, ProcessingEnvironment proce
8585

8686
public static TypeElement irTypeElement(ProcessingEnvironment procEnv) {
8787
var ret = procEnv.getElementUtils().getTypeElement(IR_INTERFACE_FQN);
88-
hardAssert(ret != null,
88+
hardAssert(
89+
ret != null,
8990
"Cannot resolve " + IR_INTERFACE_FQN + " from proc environment. Maybe missing import?");
9091
return ret;
9192
}
9293

9394
public static TypeElement diagnosticStorageTypeElement(ProcessingEnvironment procEnv) {
9495
var ret = procEnv.getElementUtils().getTypeElement(DIAGNOSTIC_STORAGE_FQN);
95-
hardAssert(ret != null, "Cannot resolve " + DIAGNOSTIC_STORAGE_FQN + " from proc environment. Maybe missing import?");
96+
hardAssert(
97+
ret != null,
98+
"Cannot resolve "
99+
+ DIAGNOSTIC_STORAGE_FQN
100+
+ " from proc environment. Maybe missing import?");
96101
return ret;
97102
}
98103

99104
public static TypeElement identifiedLocationTypeElement(ProcessingEnvironment procEnv) {
100105
var ret = procEnv.getElementUtils().getTypeElement(IDENTIFIED_LOCATION_FQN);
101-
hardAssert(ret != null, "Cannot resolve " + IDENTIFIED_LOCATION_FQN + " from proc environment. Maybe missing import?");
106+
hardAssert(
107+
ret != null,
108+
"Cannot resolve "
109+
+ IDENTIFIED_LOCATION_FQN
110+
+ " from proc environment. Maybe missing import?");
102111
return ret;
103112
}
104113

105114
public static TypeElement metadataStorageTypeElement(ProcessingEnvironment procEnv) {
106115
var ret = procEnv.getElementUtils().getTypeElement(METADATA_STORAGE_FQN);
107-
hardAssert(ret != null, "Cannot resolve " + METADATA_STORAGE_FQN + " from proc environment. Maybe missing import?");
116+
hardAssert(
117+
ret != null,
118+
"Cannot resolve " + METADATA_STORAGE_FQN + " from proc environment. Maybe missing import?");
108119
return ret;
109120
}
110121

111122
public static TypeElement uuidTypeElement(ProcessingEnvironment procEnv) {
112123
var ret = procEnv.getElementUtils().getTypeElement(UUID_FQN);
113-
hardAssert(ret != null, "Cannot resolve " + UUID_FQN + " from proc environment. Maybe missing import?");
124+
hardAssert(
125+
ret != null,
126+
"Cannot resolve " + UUID_FQN + " from proc environment. Maybe missing import?");
114127
return ret;
115128
}
116129

engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/JName.java

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
public interface JName extends Expression, IRKind.Primitive {
1414
String name();
1515

16-
/** Checks whether a name is a call-site method name.
16+
/**
17+
* Checks whether a name is a call-site method name.
1718
*
1819
* @return `true` if the name was created through a method call
1920
*/
@@ -28,10 +29,12 @@ default boolean isMethod() {
2829
JName setLocation(Option<IdentifiedLocation> location);
2930

3031
@Override
31-
JName duplicate(boolean keepLocations, boolean keepMetadata, boolean keepDiagnostics,
32+
JName duplicate(
33+
boolean keepLocations,
34+
boolean keepMetadata,
35+
boolean keepDiagnostics,
3236
boolean keepIdentifiers);
3337

34-
3538
@GenerateIR(interfaces = {JName.class, IRKind.Sugar.class})
3639
final class MethodReference extends NameMethodReferenceGen {
3740
@GenerateFields
@@ -40,15 +43,13 @@ public MethodReference(
4043
@IRChild JName methodName,
4144
IdentifiedLocation identifiedLocation,
4245
MetadataStorage passData,
43-
DiagnosticStorage diagnostics
44-
) {
46+
DiagnosticStorage diagnostics) {
4547
super(typePointer, methodName, identifiedLocation, passData, diagnostics);
4648
}
4749

4850
@Override
4951
public String showCode(int indent) {
50-
var tPointer = typePointer().map(tp -> tp.showCode(indent) + ".")
51-
.getOrElse(() -> "");
52+
var tPointer = typePointer().map(tp -> tp.showCode(indent) + ".").getOrElse(() -> "");
5253
return tPointer + methodName().showCode(indent);
5354
}
5455

@@ -67,9 +68,7 @@ public boolean isSameReferenceAs(MethodReference that) {
6768
}
6869
}
6970

70-
/**
71-
* A representation of a qualified (multi-part) name.
72-
*/
71+
/** A representation of a qualified (multi-part) name. */
7372
@GenerateIR(interfaces = {JName.class, IRKind.Primitive.class})
7473
final class Qualified extends NameQualifiedGen {
7574

@@ -83,8 +82,7 @@ public Qualified(
8382
@IRChild List<JName> parts,
8483
IdentifiedLocation identifiedLocation,
8584
MetadataStorage passData,
86-
DiagnosticStorage diagnostics
87-
) {
85+
DiagnosticStorage diagnostics) {
8886
super(parts, identifiedLocation, passData, diagnostics);
8987
}
9088

@@ -99,17 +97,14 @@ public String showCode(int indent) {
9997
}
10098
}
10199

102-
/**
103-
* Represents occurrences of blank (`_`) expressions.
104-
*/
100+
/** Represents occurrences of blank (`_`) expressions. */
105101
@GenerateIR(interfaces = {JName.class, IRKind.Sugar.class})
106102
final class Blank extends NameBlankGen {
107103
@GenerateFields
108104
public Blank(
109105
IdentifiedLocation identifiedLocation,
110106
MetadataStorage passData,
111-
DiagnosticStorage diagnostics
112-
) {
107+
DiagnosticStorage diagnostics) {
113108
super(identifiedLocation, passData, diagnostics);
114109
}
115110

@@ -138,8 +133,7 @@ enum Ident {
138133
public Special(
139134
@IRField Ident specialName,
140135
IdentifiedLocation identifiedLocation,
141-
MetadataStorage passData
142-
) {
136+
MetadataStorage passData) {
143137
super(specialName, identifiedLocation, passData);
144138
}
145139

@@ -163,8 +157,7 @@ public Literal(
163157
@IRField JName origName,
164158
IdentifiedLocation identifiedLocation,
165159
MetadataStorage passData,
166-
DiagnosticStorage diagnosticStorage
167-
) {
160+
DiagnosticStorage diagnosticStorage) {
168161
super(name, isMethod, origName, identifiedLocation, passData, diagnosticStorage);
169162
}
170163

@@ -182,7 +175,10 @@ interface Annotation extends JName, Definition {
182175
Annotation setLocation(Option<IdentifiedLocation> location);
183176

184177
@Override
185-
Annotation duplicate(boolean keepLocations, boolean keepMetadata, boolean keepDiagnostics,
178+
Annotation duplicate(
179+
boolean keepLocations,
180+
boolean keepMetadata,
181+
boolean keepDiagnostics,
186182
boolean keepIdentifiers);
187183

188184
/**
@@ -213,10 +209,7 @@ Annotation duplicate(boolean keepLocations, boolean keepMetadata, boolean keepDi
213209
final class BuiltinAnnotation extends NameBuiltinAnnotationGen {
214210
@GenerateFields
215211
public BuiltinAnnotation(
216-
@IRField String name,
217-
IdentifiedLocation identifiedLocation,
218-
MetadataStorage passData
219-
) {
212+
@IRField String name, IdentifiedLocation identifiedLocation, MetadataStorage passData) {
220213
super(name, identifiedLocation, passData);
221214
}
222215

@@ -226,9 +219,7 @@ public String showCode(int indent) {
226219
}
227220
}
228221

229-
/**
230-
* Common annotations of form {@code @name expression}
231-
*/
222+
/** Common annotations of form {@code @name expression} */
232223
@GenerateIR(interfaces = {Annotation.class})
233224
final class GenericAnnotation extends NameGenericAnnotationGen {
234225

@@ -241,8 +232,7 @@ public GenericAnnotation(
241232
@IRField String name,
242233
@IRChild Expression expression,
243234
IdentifiedLocation identifiedLocation,
244-
MetadataStorage passData
245-
) {
235+
MetadataStorage passData) {
246236
super(name, expression, identifiedLocation, passData);
247237
}
248238

@@ -258,8 +248,7 @@ final class Self extends NameSelfGen {
258248
public Self(
259249
@IRField boolean synthetic,
260250
IdentifiedLocation identifiedLocation,
261-
MetadataStorage passData
262-
) {
251+
MetadataStorage passData) {
263252
super(synthetic, identifiedLocation, passData);
264253
}
265254

@@ -274,16 +263,11 @@ public String showCode(int indent) {
274263
}
275264
}
276265

277-
/**
278-
* A representation of the name `Self`, used to refer to the current type.
279-
*/
266+
/** A representation of the name `Self`, used to refer to the current type. */
280267
@GenerateIR(interfaces = {JName.class})
281268
final class SelfType extends NameSelfTypeGen {
282269
@GenerateFields
283-
public SelfType(
284-
IdentifiedLocation identifiedLocation,
285-
MetadataStorage passData
286-
) {
270+
public SelfType(IdentifiedLocation identifiedLocation, MetadataStorage passData) {
287271
super(identifiedLocation, passData);
288272
}
289273

0 commit comments

Comments
 (0)