Skip to content

Commit

Permalink
Use space
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Dec 28, 2024
1 parent 9c03c55 commit 3c023e8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static com.google.common.collect.ImmutableSet.toImmutableSet;

import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
Expand All @@ -38,7 +37,6 @@
import com.google.devtools.build.lib.skyframe.BzlLoadFunction;
import com.google.devtools.build.lib.skyframe.BzlLoadValue;
import com.google.devtools.build.skyframe.SkyFunction.Environment;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Optional;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -104,18 +102,20 @@ static InnateRunnableExtension load(
RepositoryMapping repoMapping = usagesValue.getRepoMappings().get(moduleKey);
Label.RepoContext repoContext = Label.RepoContext.of(repoMapping.ownerRepo(), repoMapping);

// The name of the extension is of the form "<bzl_file_label>+<rule_name>".
Iterator<String> parts = Splitter.on('+').split(extensionId.extensionName()).iterator();
// The name of the extension is of the form "<bzl_file_label> <rule_name>". Rule names cannot
// contain spaces, so we can split on the last space.
int lastSpace = extensionId.extensionName().lastIndexOf(' ');
String rawLabel = extensionId.extensionName().substring(0, lastSpace);
String ruleName = extensionId.extensionName().substring(lastSpace + 1);
Location location = tags.getFirst().getLocation();
Label bzlLabel;
try {
bzlLabel = Label.parseWithRepoContext(parts.next(), repoContext);
bzlLabel = Label.parseWithRepoContext(rawLabel, repoContext);
BzlLoadFunction.checkValidLoadLabel(bzlLabel, starlarkSemantics);
} catch (LabelSyntaxException e) {
throw ExternalDepsException.withCauseAndMessage(
Code.BAD_MODULE, e, "bad repo rule .bzl file label at %s", location);
}
String ruleName = parts.next();

// Load the .bzl file.
BzlLoadValue loadedBzl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static ModuleExtensionId create(
}

public boolean isInnate() {
return extensionName().contains("+");
return extensionName().contains(" ");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ private static void injectRepos(
new ModuleThreadContext.ModuleExtensionUsageBuilder(
context,
"//:MODULE.bazel",
"@bazel_tools//tools/build_defs/repo:local.bzl+local_repository",
"@bazel_tools//tools/build_defs/repo:local.bzl local_repository",
/* isolate= */ false);
ModuleFileGlobals.ModuleExtensionProxy extensionProxy =
new ModuleFileGlobals.ModuleExtensionProxy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ public RepoRuleProxy useRepoRule(String bzlFile, String ruleName, StarlarkThread
ModuleThreadContext context = ModuleThreadContext.fromOrFail(thread, "use_repo_rule()");
context.setNonModuleCalled();
// Not a valid Starlark identifier so that it can't collide with a real extension.
String extensionName = bzlFile + '+' + ruleName;
String extensionName = bzlFile + ' ' + ruleName;
// Find or create the builder for the singular "innate" extension of this repo rule for this
// module.
for (ModuleExtensionUsageBuilder usageBuilder : context.getExtensionUsageBuilders()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ public void testModuleExtensions_innate() throws Exception {
.addExtensionUsage(
ModuleExtensionUsage.builder()
.setExtensionBzlFile("//:MODULE.bazel")
.setExtensionName("//:repo.bzl+repo")
.setExtensionName("//:repo.bzl repo")
.setIsolationKey(Optional.empty())
.setRepoOverrides(ImmutableMap.of())
.addProxy(
Expand Down Expand Up @@ -1234,7 +1234,7 @@ public void testModuleExtensions_innate() throws Exception {
.addExtensionUsage(
ModuleExtensionUsage.builder()
.setExtensionBzlFile("//:MODULE.bazel")
.setExtensionName("@bazel_tools//:http.bzl+http_archive")
.setExtensionName("@bazel_tools//:http.bzl http_archive")
.setIsolationKey(Optional.empty())
.setRepoOverrides(ImmutableMap.of())
.addProxy(
Expand Down

0 comments on commit 3c023e8

Please sign in to comment.