Search in sources :

Example 6 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class BlazeResolveConfigurationEquivalenceTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    super.initTest(applicationServices, projectServices);
    applicationServices.register(BlazeExecutor.class, new MockBlazeExecutor());
    CPPEnvironmentAdapter.registerForTest(applicationServices.getPicoContainer());
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    applicationServices.register(CompilerVersionChecker.class, new MockCompilerVersionChecker("1234"));
    applicationServices.register(ProgressManager.class, new ProgressManagerImpl());
    applicationServices.register(VirtualFileManager.class, mock(VirtualFileManager.class));
    mockFileSystem = mock(LocalFileSystem.class);
    applicationServices.register(VirtualFileSystemProvider.class, mock(VirtualFileSystemProvider.class));
    when(VirtualFileSystemProvider.getInstance().getSystem()).thenReturn(mockFileSystem);
    projectServices.register(PsiManager.class, new MockPsiManager(project));
    projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager());
    BuildSystemProvider buildSystemProvider = new BazelBuildSystemProvider();
    registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class).registerExtension(buildSystemProvider);
    BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(new BlazeImportSettings("", "", "", "", buildSystemProvider.buildSystem()));
    context.addOutputSink(IssueOutput.class, errorCollector);
    resolver = new BlazeConfigurationResolver(project);
    resolverResult = BlazeConfigurationResolverResult.empty(project);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager) ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) MockPsiManager(com.intellij.mock.MockPsiManager) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) VirtualFileSystemProvider(com.google.idea.blaze.base.io.VirtualFileSystemProvider) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)

Example 7 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class DeprecatedLoadQuickFix method findContainingPackage.

@Nullable
private static File findContainingPackage(Project project, File file) {
    BuildSystemProvider provider = Blaze.getBuildSystemProvider(project);
    file = file.getParentFile();
    while (file != null) {
        File buildFile = provider.findBuildFileInDirectory(file);
        if (buildFile != null) {
            return file;
        }
        file = file.getParentFile();
    }
    return null;
}
Also used : BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) File(java.io.File) Nullable(javax.annotation.Nullable)

Example 8 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class GenerateFromBuildFileSelectProjectViewOption method validate.

@Override
public BlazeValidationResult validate() {
    String buildFilePath = getBuildFilePath();
    if (buildFilePath.isEmpty()) {
        return BlazeValidationResult.failure("BUILD file field cannot be empty.");
    }
    if (!WorkspacePath.isValid(buildFilePath)) {
        return BlazeValidationResult.failure("Invalid BUILD file path: specify a path relative to the workspace root.");
    }
    WorkspacePathResolver workspacePathResolver = builder.getWorkspaceOption().getWorkspacePathResolver();
    File file = workspacePathResolver.resolveToFile(new WorkspacePath(buildFilePath));
    if (!file.exists()) {
        return BlazeValidationResult.failure("BUILD file does not exist.");
    }
    if (file.isDirectory()) {
        return BlazeValidationResult.failure("Specified path is a directory, not a file");
    }
    BuildSystemProvider buildSystemProvider = BuildSystemProvider.getBuildSystemProvider(builder.getBuildSystem());
    checkState(buildSystemProvider != null);
    if (!buildSystemProvider.isBuildFile(file.getName())) {
        return BlazeValidationResult.failure("File must be a BUILD file.");
    }
    return BlazeValidationResult.success();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 9 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class WorkspaceHelper method deriveLabel.

private static Label deriveLabel(Project project, Workspace workspace, WorkspacePath workspacePath) {
    BuildSystemProvider provider = Blaze.getBuildSystemProvider(project);
    File file = workspace.root.fileForPath(workspacePath);
    if (provider.isBuildFile(file.getName())) {
        return Label.create(workspace.externalWorkspaceName, workspace.root.workspacePathFor(file.getParentFile()), TargetName.create("__pkg__"));
    }
    WorkspacePath packagePath = getPackagePath(provider, workspace.root, workspacePath);
    if (packagePath == null) {
        return null;
    }
    TargetName targetName = TargetName.createIfValid(FileUtil.getRelativePath(workspace.root.fileForPath(packagePath), file));
    return targetName != null ? Label.create(workspace.externalWorkspaceName, packagePath, targetName) : null;
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) TargetName(com.google.idea.blaze.base.model.primitives.TargetName) File(java.io.File)

Example 10 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class BlazeKotlinSyncPluginTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    ExtensionPointImpl<BuildSystemProvider> buildSystems = registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
    buildSystems.registerExtension(new BazelBuildSystemProvider());
    ExtensionPointImpl<BlazeSyncPlugin> syncPlugins = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
    syncPlugins.registerExtension(new BlazeJavaSyncPlugin());
    syncPlugins.registerExtension(new BlazeKotlinSyncPlugin());
    context = new BlazeContext();
    context.addOutputSink(IssueOutput.class, errorCollector);
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) BlazeJavaSyncPlugin(com.google.idea.blaze.java.sync.BlazeJavaSyncPlugin) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)

Aggregations

BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)13 File (java.io.File)6 BazelBuildSystemProvider (com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)5 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)4 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)4 WorkspacePathResolver (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver)4 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)4 Nullable (javax.annotation.Nullable)3 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)2 VirtualFileSystemProvider (com.google.idea.blaze.base.io.VirtualFileSystemProvider)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)2 ProgressManagerImpl (com.intellij.openapi.progress.impl.ProgressManagerImpl)2 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Futures (com.google.common.util.concurrent.Futures)1