コード例 #1
0
 public PackagePathCache(
     ImmutableSet<IjFolder> startingFolders, JavaPackageFinder javaPackageFinder) {
   delegate = new ParsingJavaPackageFinder.PackagePathCache();
   for (IjFolder startingFolder : startingFolders) {
     if (!startingFolder.getWantsPackagePrefix()) {
       continue;
     }
     Path path =
         FluentIterable.from(startingFolder.getInputs()).first().or(lookupPath(startingFolder));
     delegate.insert(path, javaPackageFinder.findJavaPackageFolder(path));
   }
 }
コード例 #2
0
 @Nullable
 private String getPackagPrefix(IjFolder folder) {
   if (!folder.getWantsPackagePrefix()) {
     return null;
   }
   Path fileToLookupPackageIn;
   if (!folder.getInputs().isEmpty()
       && folder.getInputs().first().getParent().equals(folder.getPath())) {
     fileToLookupPackageIn = folder.getInputs().first();
   } else {
     fileToLookupPackageIn = folder.getPath().resolve("notfound");
   }
   String packagePrefix = javaPackageFinder.findJavaPackage(fileToLookupPackageIn);
   if (packagePrefix.isEmpty()) {
     // It doesn't matter either way, but an empty prefix looks confusing.
     return null;
   }
   return packagePrefix;
 }