Search in sources :

Example 21 with BlazeContentEntry

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();
}
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 22 with BlazeContentEntry

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());
}
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 23 with BlazeContentEntry

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());
}
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 24 with BlazeContentEntry

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());
}
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 25 with BlazeContentEntry

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());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) 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