Add 'did you mean' suggestion when accessing a struct field
--
PiperOrigin-RevId: 143380643
MOS_MIGRATED_REVID=143380643
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java
index 30b9417..e3468da 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java
@@ -279,15 +279,14 @@
}
/**
- * Returns the list of Skylark callable Methods of objClass with the given name
- * and argument number.
+ * Returns the list of Skylark callable Methods of objClass with the given name and argument
+ * number.
*/
- public static List<MethodDescriptor> getMethods(Class<?> objClass, String methodName,
- Location loc) throws EvalException {
+ public static List<MethodDescriptor> getMethods(Class<?> objClass, String methodName) {
try {
return methodCache.get(objClass).get(methodName);
} catch (ExecutionException e) {
- throw new EvalException(loc, "method invocation failed: " + e);
+ throw new IllegalStateException("method invocation failed: " + e);
}
}
@@ -295,8 +294,12 @@
* Returns a set of the Skylark name of all Skylark callable methods for object of type {@code
* objClass}.
*/
- public static Set<String> getMethodNames(Class<?> objClass) throws ExecutionException {
- return methodCache.get(objClass).keySet();
+ public static Set<String> getMethodNames(Class<?> objClass) {
+ try {
+ return methodCache.get(objClass).keySet();
+ } catch (ExecutionException e) {
+ throw new IllegalStateException("method invocation failed: " + e);
+ }
}
static Object callMethod(MethodDescriptor methodDescriptor, String methodName, Object obj,
@@ -357,7 +360,7 @@
Class<?> objClass, String methodName, List<Object> args, Map<String, Object> kwargs)
throws EvalException {
Pair<MethodDescriptor, List<Object>> matchingMethod = null;
- List<MethodDescriptor> methods = getMethods(objClass, methodName, getLocation());
+ List<MethodDescriptor> methods = getMethods(objClass, methodName);
ArgumentListConversionResult argumentListConversionResult = null;
if (methods != null) {
for (MethodDescriptor method : methods) {