Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Pasternak committed Nov 13, 2024
1 parent 9645774 commit d2dec72
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy;
import com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy.OutputGroup;
import com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategyBazel;
import com.google.idea.blaze.base.sync.aspects.strategy.AspectRepositoryProvider;
import com.google.idea.blaze.base.sync.aspects.strategy.OverrideFlags;
import java.io.File;
import java.nio.file.Paths;
import java.util.Collection;
Expand Down Expand Up @@ -55,12 +55,12 @@ public static void main(String[] a) throws Exception {
aspectStrategyBazel.getAspectFlag().get(),
String.format(
"%s=%s/%s/aspect",
AspectRepositoryProvider.overrideRepositoryFlag(false),
OverrideFlags.overrideRepositoryFlag(false),
System.getenv("TEST_SRCDIR"),
System.getenv("TEST_WORKSPACE")),
String.format(
"%s=%s/%s/aspect_template",
AspectRepositoryProvider.overrideRepositoryTemplateFlag(false),
OverrideFlags.overrideRepositoryTemplateFlag(false),
System.getenv("TEST_SRCDIR"),
System.getenv("TEST_WORKSPACE"))
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.google.idea.blaze.base.sync.aspects.strategy;

import com.google.idea.blaze.base.model.BlazeProjectData;
import com.google.idea.blaze.base.model.BlazeVersionData;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
Expand All @@ -14,20 +13,6 @@ public interface AspectRepositoryProvider {
ExtensionPointName<AspectRepositoryProvider> EP_NAME =
ExtensionPointName.create("com.google.idea.blaze.AspectRepositoryProvider");

static String newRepositoryFlag(boolean useInjectedRepository) {
if (useInjectedRepository) {
return "--inject_repository";
} else {
return "--override_repository";
}
}

static String overrideRepositoryFlag(boolean useInjectedRepository) {
return String.format("%s=intellij_aspect", newRepositoryFlag(useInjectedRepository));
}
static String overrideRepositoryTemplateFlag(boolean useInjectedRepository) {
return String.format("%s=intellij_aspect_template", newRepositoryFlag(useInjectedRepository));
}

Optional<File> aspectDirectory();

Expand Down Expand Up @@ -70,10 +55,10 @@ static Optional<String>[] getOverrideFlags(Project project) {
}

private static Optional<String> getOverrideFlagForAspectDirectory(boolean useInjectedRepository) {
return findAspectDirectory().map(it -> overrideRepositoryFlag(useInjectedRepository) + "=" + it.getPath());
return findAspectDirectory().map(it -> OverrideFlags.overrideRepositoryFlag(useInjectedRepository) + "=" + it.getPath());
}

private static Optional<String> getOverrideFlagForProjectAspectDirectory(Project project, boolean useInjectedRepository) {
return getProjectAspectDirectory(project).map(it -> overrideRepositoryTemplateFlag(useInjectedRepository) + "=" + it.getPath());
return getProjectAspectDirectory(project).map(it -> OverrideFlags.overrideRepositoryTemplateFlag(useInjectedRepository) + "=" + it.getPath());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.google.idea.blaze.base.sync.aspects.strategy;

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

public class OverrideFlags {
@Contract(pure = true)
static @NotNull String newRepositoryFlag(boolean useInjectedRepository) {
if (useInjectedRepository) {
return "--inject_repository";
} else {
return "--override_repository";
}
}

public static @NotNull String overrideRepositoryFlag(boolean useInjectedRepository) {
return String.format("%s=intellij_aspect", newRepositoryFlag(useInjectedRepository));
}

public static @NotNull String overrideRepositoryTemplateFlag(boolean useInjectedRepository) {
return String.format("%s=intellij_aspect_template", newRepositoryFlag(useInjectedRepository));
}
}

0 comments on commit d2dec72

Please sign in to comment.