Skip to content

Commit 745ca28

Browse files
fmeumcopybara-github
authored andcommitted
Suggest alternatives for typoed rule attribute names
Closes bazelbuild#17847. PiperOrigin-RevId: 518664847 Change-Id: I99d09be093e785c7d1ad437d40866423638be118
1 parent 187f3e4 commit 745ca28

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

+11-1
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
/**
@@ -2080,7 +2081,16 @@ private <T> BitSet populateDefinedRuleAttributeValues(
20802081
if (attrIndex == null) {
20812082
rule.reportError(
20822083
String.format(
2083-
"%s: no such attribute '%s' in '%s' rule", rule.getLabel(), attributeName, name),
2084+
"%s: no such attribute '%s' in '%s' rule%s",
2085+
rule.getLabel(),
2086+
attributeName,
2087+
name,
2088+
SpellChecker.didYouMean(
2089+
attributeName,
2090+
rule.getAttributes().stream()
2091+
.filter(Attribute::isDocumented)
2092+
.map(Attribute::getName)
2093+
.collect(ImmutableList.toImmutableList()))),
20842094
eventHandler);
20852095
continue;
20862096
}

0 commit comments

Comments
 (0)