Search in sources :

Example 1 with BlazeImportSettings

use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.

the class ProjectViewManagerImpl method reloadProjectView.

@Nullable
@Override
public ProjectViewSet reloadProjectView(BlazeContext context, WorkspacePathResolver workspacePathResolver) {
    BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(project).getImportSettings();
    assert importSettings != null;
    assert importSettings.getProjectViewFile() != null;
    File projectViewFile = new File(importSettings.getProjectViewFile());
    ProjectViewParser parser = new ProjectViewParser(context, workspacePathResolver);
    parser.parseProjectView(projectViewFile);
    boolean success = !context.hasErrors();
    if (success) {
        ProjectViewSet projectViewSet = parser.getResult();
        File file = getCacheFile(project, importSettings);
        try {
            SerializationUtil.saveToDisk(file, projectViewSet);
        } catch (IOException e) {
            logger.error(e);
        }
        this.projectViewSet = projectViewSet;
    }
    return success ? projectViewSet : null;
}
Also used : BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) IOException(java.io.IOException) File(java.io.File) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser) Nullable(javax.annotation.Nullable)

Example 2 with BlazeImportSettings

use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.

the class BlazeBuildServiceTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager();
    importSettingsManager.setImportSettings(new BlazeImportSettings("", "", "", "", Blaze.BuildSystem.Blaze));
    projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    ProjectView view = ProjectView.builder().add(ListSection.builder(TargetSection.KEY).add(TargetExpression.fromStringSafe("//view/target:one")).add(TargetExpression.fromStringSafe("//view/target:two"))).build();
    viewSet = ProjectViewSet.builder().add(new File("view/target/.blazeproject"), view).build();
    ProjectViewManager viewManager = new MockProjectViewManager(viewSet);
    projectServices.register(ProjectViewManager.class, viewManager);
    BlazeProjectData blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).build();
    projectServices.register(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
    applicationServices.register(BlazeBuildService.class, spy(new BlazeBuildService()));
    service = BlazeBuildService.getInstance();
    assertThat(service).isNotNull();
    // Can't mock BlazeExecutor.submitTask.
    doNothing().when(service).buildTargetExpressions(any(), any(), any(), any());
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) File(java.io.File) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) ProjectViewManager(com.google.idea.blaze.base.projectview.ProjectViewManager)

Example 3 with BlazeImportSettings

use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.

the class BlazeRenderErrorContributorTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    super.initTest(applicationServices, projectServices);
    applicationServices.register(FileTypeManager.class, new MockFileTypeManager());
    projectServices.register(ProjectFileIndex.class, mock(ProjectFileIndex.class));
    projectServices.register(BuildReferenceManager.class, new MockBuildReferenceManager(project));
    projectServices.register(TransitiveDependencyMap.class, new TransitiveDependencyMap(project));
    projectServices.register(ProjectScopeBuilder.class, new ProjectScopeBuilderImpl(project));
    projectServices.register(AndroidResourceModuleRegistry.class, new AndroidResourceModuleRegistry());
    BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager();
    BlazeImportSettings settings = new BlazeImportSettings("", "", "", "", BuildSystem.Blaze);
    importSettingsManager.setImportSettings(settings);
    projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);
    createPsiClassesAndSourceToTargetMap(projectServices);
    projectDataManager = new MockBlazeProjectDataManager();
    projectServices.register(BlazeProjectDataManager.class, projectDataManager);
    ExtensionPoint<RenderErrorContributor.Provider> extensionPoint = registerExtensionPoint(ExtensionPointName.create("com.android.rendering.renderErrorContributor"), RenderErrorContributor.Provider.class);
    extensionPoint.registerExtension(new RenderErrorContributor.Provider());
    extensionPoint.registerExtension(new BlazeRenderErrorContributor.BlazeProvider());
    module = new MockModule(project, () -> {
    });
    // For the isApplicable tests.
    provider = new BlazeRenderErrorContributor.BlazeProvider();
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) RenderErrorContributor(com.android.tools.idea.rendering.RenderErrorContributor) AndroidResourceModuleRegistry(com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry) MockFileTypeManager(com.intellij.openapi.fileTypes.MockFileTypeManager) TransitiveDependencyMap(com.google.idea.blaze.base.targetmaps.TransitiveDependencyMap) MockModule(com.intellij.mock.MockModule) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) ProjectScopeBuilderImpl(com.intellij.psi.search.ProjectScopeBuilderImpl)

Example 4 with BlazeImportSettings

use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.

the class CPrefetchFileSourceTest method getImportRoots.

private ImportRoots getImportRoots(ProjectViewSet projectViewSet) {
    BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(getProject()).getImportSettings();
    WorkspaceRoot workspaceRoot = WorkspaceRoot.fromImportSettings(importSettings);
    return ImportRoots.builder(workspaceRoot, importSettings.getBuildSystem()).add(projectViewSet).build();
}
Also used : BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot)

Example 5 with BlazeImportSettings

use of com.google.idea.blaze.base.settings.BlazeImportSettings in project intellij by bazelbuild.

the class BlazeConfigurationResolverTest 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());
    compilerVersionChecker = new MockCompilerVersionChecker("1234");
    applicationServices.register(CompilerVersionChecker.class, compilerVersionChecker);
    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(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) VirtualFileSystemProvider(com.google.idea.blaze.base.io.VirtualFileSystemProvider) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor)

Aggregations

BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)16 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)8 File (java.io.File)6 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)4 Nullable (javax.annotation.Nullable)4 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)3 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)3 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)2 BazelBuildSystemProvider (com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)2 BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)2 VirtualFileSystemProvider (com.google.idea.blaze.base.io.VirtualFileSystemProvider)2 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)2 MockModule (com.intellij.mock.MockModule)2 MockPsiManager (com.intellij.mock.MockPsiManager)2 MockFileTypeManager (com.intellij.openapi.fileTypes.MockFileTypeManager)2 ProgressManagerImpl (com.intellij.openapi.progress.impl.ProgressManagerImpl)2 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ProjectScopeBuilderImpl (com.intellij.psi.search.ProjectScopeBuilderImpl)2 IOException (java.io.IOException)2