Skip to content

Commit

Permalink
Include name in repr of exported rules
Browse files Browse the repository at this point in the history
For an exported rule `foo_library`, `repr(foo_library)` now evaluates to `<rule foo_library>`, not `<rule>`, matching the behavior of native rules more closely.

Fixes #17483

Closes #18392.

PiperOrigin-RevId: 538458291
Change-Id: I331955655756a3c235be0a93f1394716ddf9849d
  • Loading branch information
fmeum authored and copybara-github committed Jun 7, 2023
1 parent 699f3e8 commit 002490b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,11 @@ public boolean isExported() {

@Override
public void repr(Printer printer) {
printer.append("<rule>");
if (isExported()) {
printer.append("<rule ").append(getRuleClass().getName()).append(">");
} else {
printer.append("<rule>");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void testStringRepresentations_functions() throws Exception {
@Test
public void testStringRepresentations_rules() throws Exception {
setBuildLanguageOptions("--experimental_builtins_injection_override=+cc_library");
assertStringRepresentation("native.cc_library", "<rule>");
assertStringRepresentation("native.cc_library", "<rule cc_library>");
assertStringRepresentation("def f(): pass", "rule(implementation=f)", "<rule>");
}

Expand Down

0 comments on commit 002490b

Please sign in to comment.