Search in sources :

Example 1 with WorkspacePathResolverImpl

use of com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl in project intellij by bazelbuild.

the class ProjectViewParserTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    context = new BlazeContext();
    errorCollector = new ErrorCollector();
    context.addOutputSink(IssueOutput.class, errorCollector);
    projectViewParser = new ProjectViewParser(context, new WorkspacePathResolverImpl(workspaceRoot));
    projectViewStorageManager = new MockProjectViewStorageManager();
    applicationServices.register(ProjectViewStorageManager.class, projectViewStorageManager);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) ErrorCollector(com.google.idea.blaze.base.scope.ErrorCollector)

Example 2 with WorkspacePathResolverImpl

use of com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl in project intellij by bazelbuild.

the class CPrefetchFileSourceTest method parseProjectView.

private ProjectViewSet parseProjectView(String... contents) {
    ProjectViewParser projectViewParser = new ProjectViewParser(new BlazeContext(), new WorkspacePathResolverImpl(workspaceRoot));
    projectViewParser.parseProjectView(Joiner.on("\n").join(contents));
    return projectViewParser.getResult();
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser)

Example 3 with WorkspacePathResolverImpl

use of com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl in project intellij by bazelbuild.

the class BlazeSyncTask method computeWorkspacePathResolverAndProjectView.

private WorkspacePathResolverAndProjectView computeWorkspacePathResolverAndProjectView(BlazeContext context, BlazeVcsHandler vcsHandler, ListeningExecutorService executor) {
    context.output(new StatusOutput("Updating VCS..."));
    for (int i = 0; i < 3; ++i) {
        WorkspacePathResolver vcsWorkspacePathResolver = null;
        BlazeVcsHandler.BlazeVcsSyncHandler vcsSyncHandler = vcsHandler.createSyncHandler(project, workspaceRoot);
        if (vcsSyncHandler != null) {
            boolean ok = Scope.push(context, (childContext) -> {
                childContext.push(new TimingScope("UpdateVcs", EventType.Other));
                return vcsSyncHandler.update(context, executor);
            });
            if (!ok) {
                return null;
            }
            vcsWorkspacePathResolver = vcsSyncHandler.getWorkspacePathResolver();
        }
        WorkspacePathResolver workspacePathResolver = vcsWorkspacePathResolver != null ? vcsWorkspacePathResolver : new WorkspacePathResolverImpl(workspaceRoot);
        ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).reloadProjectView(context, workspacePathResolver);
        if (projectViewSet == null) {
            return null;
        }
        if (vcsSyncHandler != null) {
            BlazeVcsHandler.BlazeVcsSyncHandler.ValidationResult validationResult = vcsSyncHandler.validateProjectView(context, projectViewSet);
            switch(validationResult) {
                case OK:
                    // Fall-through and return
                    break;
                case Error:
                    return null;
                case RestartSync:
                    continue;
                default:
                    // Cannot happen
                    return null;
            }
        }
        return new WorkspacePathResolverAndProjectView(workspacePathResolver, projectViewSet);
    }
    return null;
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) BlazeVcsHandler(com.google.idea.blaze.base.vcs.BlazeVcsHandler)

Example 4 with WorkspacePathResolverImpl

use of com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl in project intellij by bazelbuild.

the class BlazeSyncIntegrationTestCase method setProjectView.

protected void setProjectView(String... contents) {
    ProjectViewParser projectViewParser = new ProjectViewParser(context, new WorkspacePathResolverImpl(workspaceRoot));
    projectViewParser.parseProjectView(Joiner.on("\n").join(contents));
    ProjectViewSet result = projectViewParser.getResult();
    assertThat(result.getProjectViewFiles()).isNotEmpty();
    errorCollector.assertNoIssues();
    setProjectViewSet(result);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser)

Example 5 with WorkspacePathResolverImpl

use of com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method getDecoder.

private static ArtifactLocationDecoder getDecoder() {
    File root = new File("/root");
    WorkspaceRoot workspaceRoot = new WorkspaceRoot(root);
    BlazeInfo roots = BlazeInfo.createMockBlazeInfo("/", "/root", "/root/out/crosstool/bin", "/root/out/crosstool/gen");
    return new ArtifactLocationDecoderImpl(roots, new WorkspacePathResolverImpl(workspaceRoot));
}
Also used : BlazeInfo(com.google.idea.blaze.base.command.info.BlazeInfo) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) ArtifactLocationDecoderImpl(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoderImpl) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) File(java.io.File)

Aggregations

WorkspacePathResolverImpl (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl)13 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)6 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)6 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)6 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)5 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)5 Test (org.junit.Test)5 GoFile (com.goide.psi.GoFile)4 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)3 BlazeInfo (com.google.idea.blaze.base.command.info.BlazeInfo)2 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)2 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)2 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)2 ProjectViewParser (com.google.idea.blaze.base.projectview.parser.ProjectViewParser)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 ArtifactLocationDecoderImpl (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoderImpl)2 WorkspacePathResolver (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver)2 BlazeVcsHandler (com.google.idea.blaze.base.vcs.BlazeVcsHandler)2 GoFunctionDeclaration (com.goide.psi.GoFunctionDeclaration)1 GoTypeSpec (com.goide.psi.GoTypeSpec)1