Search in sources :

Example 41 with WorkspaceRoot

use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.

the class ProjectViewManagerImpl method computeWorkspacePathResolver.

@Nullable
private static WorkspacePathResolver computeWorkspacePathResolver(Project project, BlazeContext context) {
    BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
    if (projectData != null) {
        return projectData.workspacePathResolver;
    }
    // otherwise try to compute the workspace path resolver from scratch
    WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
    BlazeVcsHandler vcsHandler = BlazeVcsHandler.vcsHandlerForProject(project);
    if (vcsHandler == null) {
        return null;
    }
    BlazeVcsHandler.BlazeVcsSyncHandler vcsSyncHandler = vcsHandler.createSyncHandler(project, workspaceRoot);
    if (vcsSyncHandler == null) {
        return new WorkspacePathResolverImpl(workspaceRoot);
    }
    boolean ok = vcsSyncHandler.update(context, BlazeExecutor.getInstance().getExecutor());
    return ok ? vcsSyncHandler.getWorkspacePathResolver() : null;
}
Also used : WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) BlazeVcsHandler(com.google.idea.blaze.base.vcs.BlazeVcsHandler) Nullable(javax.annotation.Nullable)

Example 42 with WorkspaceRoot

use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.

the class GitStatusLineProcessorTest method testGitStatusParser.

@Test
public void testGitStatusParser() {
    GitStatusLineProcessor lineProcessor = new GitStatusLineProcessor(new WorkspaceRoot(new File("/usr/blah")), "/usr/blah");
    for (String line : ImmutableList.of("D    root/README", "M    root/blaze-base/src/com/google/idea/blaze/base/root/citc/CitcUtil.java", "A    root/blah", "A    java/com/google/Test.java", "M    java/com/other/")) {
        lineProcessor.processLine(line);
    }
    assertThat(lineProcessor.addedFiles).containsExactly(new WorkspacePath("root/blah"), new WorkspacePath("java/com/google/Test.java"));
    assertThat(lineProcessor.modifiedFiles).containsExactly(new WorkspacePath("root/blaze-base/src/com/google/idea/blaze/base/root/citc/CitcUtil.java"), new WorkspacePath("java/com/other"));
    assertThat(lineProcessor.deletedFiles).containsExactly(new WorkspacePath("root/README"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) File(java.io.File) Test(org.junit.Test)

Example 43 with WorkspaceRoot

use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.

the class GitStatusLineProcessorTest method testGitStatusParserDifferentRoots.

@Test
public void testGitStatusParserDifferentRoots() {
    GitStatusLineProcessor lineProcessor = new GitStatusLineProcessor(new WorkspaceRoot(new File("/usr/blah/root")), "/usr/blah");
    for (String line : ImmutableList.of("D    root/README", "M    root/blaze-base/src/com/google/idea/blaze/base/root/citc/CitcUtil.java", "A    root/blah", "A    java/com/google/Test.java", "M    java/com/other/")) {
        lineProcessor.processLine(line);
    }
    assertThat(lineProcessor.addedFiles).containsExactly(new WorkspacePath("blah"));
    assertThat(lineProcessor.modifiedFiles).containsExactly(new WorkspacePath("blaze-base/src/com/google/idea/blaze/base/root/citc/CitcUtil.java"));
    assertThat(lineProcessor.deletedFiles).containsExactly(new WorkspacePath("README"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) File(java.io.File) Test(org.junit.Test)

Example 44 with WorkspaceRoot

use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.

the class RelatedWorkspacePathFinderTest method setUp.

@Before
public void setUp() throws IOException {
    files = new MockFileOperationProvider();
    relatedPathFinder = new RelatedWorkspacePathFinder(files);
    workspacePathResolver = new WorkspacePathResolverImpl(new WorkspaceRoot(WORKSPACE_ROOT));
}
Also used : WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) Before(org.junit.Before)

Example 45 with WorkspaceRoot

use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.

the class BlazeScalaWorkspaceImporterTest method importJava.

private BlazeJavaImportResult importJava(ProjectView projectView, TargetMap targetMap) {
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(projectView).build();
    WorkspaceLanguageSettings languageSettings = new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.SCALA, LanguageClass.JAVA));
    JavaSourceFilter sourceFilter = new JavaSourceFilter(project, workspaceRoot, projectViewSet, targetMap);
    JdepsMap jdepsMap = key -> ImmutableList.of();
    ArtifactLocationDecoder decoder = location -> new File(location.getRelativePath());
    return new BlazeJavaWorkspaceImporter(project, workspaceRoot, projectViewSet, languageSettings, targetMap, sourceFilter, jdepsMap, null, decoder).importWorkspace(context);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) LibraryKey(com.google.idea.blaze.base.model.LibraryKey) PrefetchService(com.google.idea.blaze.base.prefetch.PrefetchService) Map(java.util.Map) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) ImmutableSet(com.google.common.collect.ImmutableSet) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact) ErrorCollector(com.google.idea.blaze.base.scope.ErrorCollector) BlazeSourceDirectory(com.google.idea.blaze.java.sync.model.BlazeSourceDirectory) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) ScalaJavaLikeLanguage(com.google.idea.blaze.scala.sync.source.ScalaJavaLikeLanguage) NotNull(org.jetbrains.annotations.NotNull) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) JavaSourcePackageReader(com.google.idea.blaze.java.sync.source.JavaSourcePackageReader) PackageManifestReader(com.google.idea.blaze.java.sync.source.PackageManifestReader) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) DirectorySection(com.google.idea.blaze.base.projectview.section.sections.DirectorySection) RunWith(org.junit.runner.RunWith) BlazeJavaWorkspaceImporter(com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter) JavaIdeInfo(com.google.idea.blaze.base.ideinfo.JavaIdeInfo) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableList(com.google.common.collect.ImmutableList) BuildSystem(com.google.idea.blaze.base.settings.Blaze.BuildSystem) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) Nullable(javax.annotation.Nullable) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) BlazeTestCase(com.google.idea.blaze.base.BlazeTestCase) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) MockPrefetchService(com.google.idea.blaze.base.prefetch.MockPrefetchService) BlazeJavaSyncAugmenter(com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter) BlazeScalaImportResult(com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult) File(java.io.File) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) JdepsMap(com.google.idea.blaze.java.sync.jdeps.JdepsMap) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ListSection(com.google.idea.blaze.base.projectview.section.ListSection) JdepsMap(com.google.idea.blaze.java.sync.jdeps.JdepsMap) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) BlazeJavaWorkspaceImporter(com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter) File(java.io.File)

Aggregations

WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)50 File (java.io.File)30 Nullable (javax.annotation.Nullable)23 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)21 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)19 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)18 ImmutableList (com.google.common.collect.ImmutableList)14 List (java.util.List)13 Project (com.intellij.openapi.project.Project)12 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)10 Kind (com.google.idea.blaze.base.model.primitives.Kind)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 Lists (com.google.common.collect.Lists)9 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)9 ImportRoots (com.google.idea.blaze.base.sync.projectview.ImportRoots)9 Collectors (java.util.stream.Collectors)9 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)8 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)8 Label (com.google.idea.blaze.base.model.primitives.Label)8 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)8