Search in sources :

Example 1 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_multipleSubdirectoriesAreNotMerged.

@Test
public void testSourcesToSourceDirectories_multipleSubdirectoriesAreNotMerged() throws Exception {
    mockInputStreamProvider.addFile("/root/java/com/google/package0/Bla.java", "package com.google.packagewrong0;\n public class Bla {}").addFile("/root/java/com/google/package1/Bla.java", "package com.google.packagewrong1;\n public class Bla {}");
    List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/package0/Bla.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/package1/Bla.java").setIsSource(true)).build());
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    issues.assertNoIssues();
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google").addSource(BlazeSourceDirectory.builder("/root/java/com/google").setPackagePrefix("com.google").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/package0").setPackagePrefix("com.google.packagewrong0").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/package1").setPackagePrefix("com.google.packagewrong1").build()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Example 2 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testWorkspacePathIsAddedWithoutSources.

@Test
public void testWorkspacePathIsAddedWithoutSources() throws Exception {
    List<SourceArtifact> sourceArtifacts = ImmutableList.of();
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google/app")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    issues.assertNoIssues();
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google/app").addSource(BlazeSourceDirectory.builder("/root/java/com/google/app").setPackagePrefix("com.google.app").build()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Example 3 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_packagesDoNotMatchPath.

@Test
public void testSourcesToSourceDirectories_packagesDoNotMatchPath() throws Exception {
    mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.facebook;\n public class Bla {}");
    List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/Bla.java").setIsSource(true)).build());
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    issues.assertNoIssues();
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google").addSource(BlazeSourceDirectory.builder("/root/java/com/google").setPackagePrefix("com.facebook").build()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Example 4 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_multipleMatchingPackagesAreMerged.

@Test
public void testSourcesToSourceDirectories_multipleMatchingPackagesAreMerged() throws Exception {
    mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.google;\n public class Bla {}").addFile("/root/java/com/google/subpackage/Bla.java", "package com.google.subpackage;\n public class Bla {}");
    List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/Bla.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/subpackage/Bla.java").setIsSource(true)).build());
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    issues.assertNoIssues();
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google").addSource(BlazeSourceDirectory.builder("/root/java/com/google").setPackagePrefix("com.google").build()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Example 5 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testIncorrectPackageInMiddleOfTreeCausesMergePointHigherUp.

@Test
public void testIncorrectPackageInMiddleOfTreeCausesMergePointHigherUp() throws Exception {
    mockInputStreamProvider.addFile("/root/java/com/google/idea/blaze/plugin/run/Run.java", "package com.google.idea.blaze.plugin.run;\n public class run {}").addFile("/root/java/com/google/idea/blaze/plugin/sync/Sync.java", "package com.google.idea.blaze.plugin.sync;\n public class Sync {}").addFile("/root/java/com/google/idea/blaze/Incorrect.java", "package com.google.idea.blaze.incorrect;\n public class Incorrect {}");
    List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/idea/blaze/plugin/run/Run.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/idea/blaze/plugin/sync/Sync.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/idea/blaze/Incorrect.java").setIsSource(true)).build());
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    issues.assertNoIssues();
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root").addSource(BlazeSourceDirectory.builder("/root").setPackagePrefix("").build()).addSource(BlazeSourceDirectory.builder("/root/java").setPackagePrefix("").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/idea/blaze").setPackagePrefix("com.google.idea.blaze.incorrect").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/idea/blaze/plugin").setPackagePrefix("com.google.idea.blaze.plugin").build()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Aggregations

BlazeContentEntry (com.google.idea.blaze.java.sync.model.BlazeContentEntry)29 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)27 Test (org.junit.Test)26 BlazeJavaSyncData (com.google.idea.blaze.java.sync.model.BlazeJavaSyncData)6 BlazeSourceDirectory (com.google.idea.blaze.java.sync.model.BlazeSourceDirectory)5 File (java.io.File)5 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)4 SourceFolder (com.intellij.openapi.roots.SourceFolder)4 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)3 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)3 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)3 GlobSet (com.google.idea.blaze.base.projectview.section.Glob.GlobSet)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)2 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)2 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)2 Joiner (com.google.common.base.Joiner)1 Objects (com.google.common.base.Objects)1 Splitter (com.google.common.base.Splitter)1 Strings (com.google.common.base.Strings)1