From 3c1c0c09e68420c813d6258b90ff96641dbd1151 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Mon, 27 Mar 2023 08:30:34 -0700 Subject: [PATCH] Add suggestions to invalid tag class errors Closes #17888. PiperOrigin-RevId: 519729739 Change-Id: I0ae8b18acd1a88de4da40b6883cf24c5ce6586bb --- .../build/lib/bazel/bzlmod/StarlarkBazelModule.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/StarlarkBazelModule.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/StarlarkBazelModule.java index 934314f65b46d7..3f28dbe288bc34 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/StarlarkBazelModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/StarlarkBazelModule.java @@ -34,6 +34,7 @@ import net.starlark.java.eval.StarlarkList; import net.starlark.java.eval.StarlarkValue; import net.starlark.java.eval.Structure; +import net.starlark.java.spelling.SpellChecker; /** A Starlark object representing a Bazel module in the external dependency graph. */ @StarlarkBuiltin( @@ -118,10 +119,11 @@ public static StarlarkBazelModule create( throw ExternalDepsException.withMessage( Code.BAD_MODULE, "The module extension defined at %s does not have a tag class named %s, but its use is" - + " attempted at %s", + + " attempted at %s%s", extension.getLocation(), tag.getTagName(), - tag.getLocation()); + tag.getLocation(), + SpellChecker.didYouMean(tag.getTagName(), extension.getTagClasses().keySet())); } // Now we need to type-check the attribute values and convert them into "build language types"