Skip to content

Commit

Permalink
removed binary cache in formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
LeFrosch committed Aug 8, 2024
1 parent 70c320c commit 39f5047
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,11 @@ public final class BuildifierFormattingService extends AsyncDocumentFormattingSe
static final FeatureRolloutExperiment useNewBuildifierFormattingService =
new FeatureRolloutExperiment("formatter.api.buildifier");

static final Supplier<Optional<String>> binaryPath = Suppliers.memoize(() -> getBinary());

@Override
@Nullable
protected FormattingTask createFormattingTask(AsyncFormattingRequest request) {
BuildFile buildFile = (BuildFile) request.getContext().getContainingFile();
return binaryPath
.get()
return getBinary()
.map(binary -> BuildFileFormatter.getCommandLineArgs(binary, buildFile))
.map(args -> new BuildifierFormattingTask(request, args))
.orElse(null);
Expand All @@ -75,7 +72,7 @@ public ImmutableSet<Feature> getFeatures() {
public boolean canFormat(PsiFile file) {
return useNewBuildifierFormattingService.isEnabled()
&& file instanceof BuildFile
&& binaryPath.get().isPresent();
&& getBinary().isPresent();
}

private static Optional<String> getBinary() {
Expand Down

0 comments on commit 39f5047

Please sign in to comment.