Skip to content

Commit eccf509

Browse files
committed
Suggest alternatives for typoed rule attribute names
1 parent f8a59d9 commit eccf509

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/com/google/devtools/build/lib/packages/RuleClass.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
import net.starlark.java.eval.Starlark;
7979
import net.starlark.java.eval.StarlarkCallable;
8080
import net.starlark.java.eval.StarlarkThread;
81+
import net.starlark.java.spelling.SpellChecker;
8182
import net.starlark.java.syntax.Location;
8283

8384
/**
@@ -2079,8 +2080,12 @@ private <T> BitSet populateDefinedRuleAttributeValues(
20792080
Integer attrIndex = getAttributeIndex(attributeName);
20802081
if (attrIndex == null) {
20812082
rule.reportError(
2082-
String.format(
2083-
"%s: no such attribute '%s' in '%s' rule", rule.getLabel(), attributeName, name),
2083+
String.format("%s: no such attribute '%s' in '%s' rule%s", rule.getLabel(),
2084+
attributeName, name, SpellChecker.didYouMean(attributeName,
2085+
rule.getAttributes().stream()
2086+
.filter(Attribute::isDocumented)
2087+
.map(Attribute::getName)
2088+
.collect(ImmutableList.toImmutableList()))),
20842089
eventHandler);
20852090
continue;
20862091
}

0 commit comments

Comments
 (0)