use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testHandlesSourceAtProjectRoot.
@Test
public void testHandlesSourceAtProjectRoot() throws Exception {
mockInputStreamProvider.addFile("/root/Bla.java", "package com.google;\n public class Bla {}");
List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("Bla.java").setIsSource(true)).build());
ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
assertThat(result).containsExactly(BlazeContentEntry.builder("/root").addSource(BlazeSourceDirectory.builder("/root").setPackagePrefix("com.google").build()).build());
issues.assertNoIssues();
}
use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testLowestDirectoryIsPrioritised.
@Test
public void testLowestDirectoryIsPrioritised() throws Exception {
mockInputStreamProvider.addFile("/root/java/com/google/android/chimera/internal/Preconditions.java", "package com.google.android.chimera.container.internal;\n " + "public class Preconditions {}").addFile("/root/java/com/google/android/chimera/container/FileApkUtils.java", "package com.google.android.chimera.container;\n public class FileApkUtils {}");
List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/android/chimera/internal/Preconditions.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/android/chimera/container/FileApkUtils.java").setIsSource(true)).build());
ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google/android")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
issues.assertNoIssues();
assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google/android").addSource(BlazeSourceDirectory.builder("/root/java/com/google/android").setPackagePrefix("com.google.android").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/android/chimera/internal").setPackagePrefix("com.google.android.chimera.container.internal").build()).build());
}
use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_childMatchesPathButParentDoesnt.
@Test
public void testSourcesToSourceDirectories_childMatchesPathButParentDoesnt() throws Exception {
mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.facebook;\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.facebook").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/subpackage").setPackagePrefix("com.google.subpackage").build()).build());
}
use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testCompetingPackageDeclarationWithEqualCountsPicksDefault.
@Test
public void testCompetingPackageDeclarationWithEqualCountsPicksDefault() throws Exception {
mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.google.different;\n public class Bla {}").addFile("/root/java/com/google/Foo.java", "package com.google;\n public class Foo {}");
List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/Foo.java").setIsSource(true)).build(), 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.google").build()).build());
}
use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testManifestMissingSourcesFallback.
@Test
public void testManifestMissingSourcesFallback() throws Exception {
setPackageManifest("/root/java/com/test.manifest", ImmutableList.of("java/com/google/Bla.java", "java/com/google/Foo.java"), ImmutableList.of("com.google", "com.google"));
mockInputStreamProvider.addFile("/root/java/com/google/subpackage/Bla.java", "package com.google.different;\n public class Bla {}");
ImmutableMap<TargetKey, ArtifactLocation> manifests = ImmutableMap.of(TargetKey.forPlainTarget(LABEL), ArtifactLocation.builder().setRelativePath("java/com/test.manifest").setIsSource(true).build());
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/Foo.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, getDecoder(), buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google")), ImmutableList.of()), sourceArtifacts, 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/subpackage").setPackagePrefix("com.google.different").build()).build());
}
Aggregations