Skip to content

Commit c7a41c5

Browse files
authored
Painless: Simplify Naming in Lookup Package (#32177)
This removes some extraneous naming syntax and makes clear the meaning of certain naming conventions without ambiguities (stricter) within the lookup package. Purely mechanical change. Note this does not cover a large portion of the PainlessLookupBuilder and PainlessLookup yet as there are several more follow up PRs for these incoming.
1 parent 4c68dfe commit c7a41c5

28 files changed

+443
-406
lines changed

modules/lang-painless/src/main/java/org/elasticsearch/painless/AnalyzerCaster.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ public static PainlessCast getLegalCast(Location location, Class<?> actual, Clas
466466
return PainlessCast.standard(actual, expected, explicit);
467467
} else {
468468
throw location.createError(new ClassCastException("Cannot cast from " +
469-
"[" + PainlessLookupUtility.anyTypeToPainlessTypeName(actual) + "] to " +
470-
"[" + PainlessLookupUtility.anyTypeToPainlessTypeName(expected) + "]."));
469+
"[" + PainlessLookupUtility.typeToCanonicalTypeName(actual) + "] to " +
470+
"[" + PainlessLookupUtility.typeToCanonicalTypeName(expected) + "]."));
471471
}
472472
}
473473

modules/lang-painless/src/main/java/org/elasticsearch/painless/Def.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static MethodHandle lookupMethod(PainlessLookup painlessLookup, MethodHandles.Lo
302302
nestedType,
303303
0,
304304
DefBootstrap.REFERENCE,
305-
PainlessLookupUtility.anyTypeToPainlessTypeName(interfaceType));
305+
PainlessLookupUtility.typeToCanonicalTypeName(interfaceType));
306306
filter = nested.dynamicInvoker();
307307
} else {
308308
throw new AssertionError();
@@ -334,7 +334,7 @@ static MethodHandle lookupReference(PainlessLookup painlessLookup, MethodHandles
334334
int arity = interfaceMethod.arguments.size();
335335
PainlessMethod implMethod = lookupMethodInternal(painlessLookup, receiverClass, name, arity);
336336
return lookupReferenceInternal(painlessLookup, methodHandlesLookup, interfaceType,
337-
PainlessLookupUtility.anyTypeToPainlessTypeName(implMethod.target), implMethod.name, receiverClass);
337+
PainlessLookupUtility.typeToCanonicalTypeName(implMethod.target), implMethod.name, receiverClass);
338338
}
339339

340340
/** Returns a method handle to an implementation of clazz, given method reference signature. */
@@ -347,7 +347,7 @@ private static MethodHandle lookupReferenceInternal(PainlessLookup painlessLooku
347347
PainlessMethod interfaceMethod = painlessLookup.getPainlessStructFromJavaClass(clazz).functionalMethod;
348348
if (interfaceMethod == null) {
349349
throw new IllegalArgumentException("Cannot convert function reference [" + type + "::" + call + "] " +
350-
"to [" + PainlessLookupUtility.anyTypeToPainlessTypeName(clazz) + "], not a functional interface");
350+
"to [" + PainlessLookupUtility.typeToCanonicalTypeName(clazz) + "], not a functional interface");
351351
}
352352
int arity = interfaceMethod.arguments.size() + captures.length;
353353
final MethodHandle handle;

modules/lang-painless/src/main/java/org/elasticsearch/painless/FunctionRef.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private static PainlessMethod lookup(PainlessLookup painlessLookup, Class<?> exp
168168
PainlessMethod method = painlessLookup.getPainlessStructFromJavaClass(expected).functionalMethod;
169169
if (method == null) {
170170
throw new IllegalArgumentException("Cannot convert function reference [" + type + "::" + call + "] " +
171-
"to [" + PainlessLookupUtility.anyTypeToPainlessTypeName(expected) + "], not a functional interface");
171+
"to [" + PainlessLookupUtility.typeToCanonicalTypeName(expected) + "], not a functional interface");
172172
}
173173

174174
// lookup requested method

modules/lang-painless/src/main/java/org/elasticsearch/painless/Locals.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public int getSlot() {
292292
@Override
293293
public String toString() {
294294
StringBuilder b = new StringBuilder();
295-
b.append("Variable[type=").append(PainlessLookupUtility.anyTypeToPainlessTypeName(clazz));
295+
b.append("Variable[type=").append(PainlessLookupUtility.typeToCanonicalTypeName(clazz));
296296
b.append(",name=").append(name);
297297
b.append(",slot=").append(slot);
298298
if (readonly) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/ScriptClassInfo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private MethodArgument methodArgument(PainlessLookup painlessLookup, Class<?> cl
183183

184184
private static Class<?> definitionTypeForClass(PainlessLookup painlessLookup, Class<?> type,
185185
Function<Class<?>, String> unknownErrorMessageSource) {
186-
type = PainlessLookupUtility.javaObjectTypeToPainlessDefType(type);
186+
type = PainlessLookupUtility.javaTypeToType(type);
187187
Class<?> componentType = type;
188188

189189
while (componentType.isArray()) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/lookup/PainlessLookup.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ public PainlessClass getPainlessStructFromJavaClass(Class<?> clazz) {
5454
}
5555

5656
public Class<?> getJavaClassFromPainlessType(String painlessType) {
57-
return PainlessLookupUtility.painlessTypeNameToPainlessType(painlessType, painlessTypesToJavaClasses);
57+
return PainlessLookupUtility.canonicalTypeNameToType(painlessType, painlessTypesToJavaClasses);
5858
}
5959
}

0 commit comments

Comments
 (0)