Skip to content

Commit

Permalink
Suggest alternatives for typoed rule attribute names
Browse files Browse the repository at this point in the history
Closes bazelbuild#17847.

PiperOrigin-RevId: 518664847
Change-Id: I99d09be093e785c7d1ad437d40866423638be118
  • Loading branch information
fmeum authored and Copybara-Service committed Mar 22, 2023
1 parent 187f3e4 commit 745ca28
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import net.starlark.java.eval.Starlark;
import net.starlark.java.eval.StarlarkCallable;
import net.starlark.java.eval.StarlarkThread;
import net.starlark.java.spelling.SpellChecker;
import net.starlark.java.syntax.Location;

/**
Expand Down Expand Up @@ -2080,7 +2081,16 @@ private <T> BitSet populateDefinedRuleAttributeValues(
if (attrIndex == null) {
rule.reportError(
String.format(
"%s: no such attribute '%s' in '%s' rule", rule.getLabel(), attributeName, name),
"%s: no such attribute '%s' in '%s' rule%s",
rule.getLabel(),
attributeName,
name,
SpellChecker.didYouMean(
attributeName,
rule.getAttributes().stream()
.filter(Attribute::isDocumented)
.map(Attribute::getName)
.collect(ImmutableList.toImmutableList()))),
eventHandler);
continue;
}
Expand Down

0 comments on commit 745ca28

Please sign in to comment.