public abstract class AbstractSourcePathResolver extends Object implements SourcePathResolver
Most of the SourcePathResolverAdapter interface can be implemented in terms of just a few functions ( the main requirement is resolving BuildTargetSourcePaths).
Existing code may expect to resolve each SourcePath
to only one Path
. In such
cases, SourcePathResolverAdapter
is used to convert the resolver to return only one
Path
per SourcePath
.
Constructor and Description |
---|
AbstractSourcePathResolver() |
Modifier and Type | Method and Description |
---|---|
com.google.common.collect.ImmutableMap<Path,Path> |
createRelativeMap(Path basePath,
Iterable<SourcePath> sourcePaths)
Creates a map where given source paths are resolved relatively to the given base path and
stored (as keys) with their absolute paths (as values).
|
com.google.common.collect.ImmutableCollection<Path> |
filterInputsToCompareToOutput(Iterable<? extends SourcePath> sources)
|
com.google.common.collect.ImmutableSortedSet<Path> |
getAbsolutePath(SourcePath sourcePath) |
com.google.common.collect.ImmutableSortedSet<Path> |
getAllAbsolutePaths(Collection<? extends SourcePath> sourcePaths) |
protected abstract ProjectFilesystem |
getBuildTargetSourcePathFilesystem(BuildTargetSourcePath sourcePath) |
ProjectFilesystem |
getFilesystem(SourcePath sourcePath) |
com.google.common.collect.ImmutableSortedSet<Path> |
getIdeallyRelativePath(SourcePath sourcePath) |
<T> com.google.common.collect.ImmutableMap<T,com.google.common.collect.ImmutableSortedSet<Path>> |
getMappedPaths(Map<T,SourcePath> sourcePathMap) |
com.google.common.collect.ImmutableSortedSet<Path> |
getRelativePath(ProjectFilesystem projectFilesystem,
SourcePath sourcePath) |
com.google.common.collect.ImmutableSortedSet<Path> |
getRelativePath(SourcePath sourcePath) |
abstract String |
getSourcePathName(BuildTarget target,
SourcePath sourcePath) |
com.google.common.collect.ImmutableMap<String,SourcePath> |
getSourcePathNames(BuildTarget target,
String parameter,
Iterable<SourcePath> sourcePaths)
Resolved the logical names for a group of SourcePath objects into a map, throwing an error on
duplicates.
|
<T> com.google.common.collect.ImmutableMap<String,T> |
getSourcePathNames(BuildTarget target,
String parameter,
Iterable<T> objects,
java.util.function.Predicate<T> filter,
java.util.function.Function<T,SourcePath> objectSourcePathFunction)
Resolves the logical names for a group of objects that have a SourcePath into a map, throwing
an error on duplicates.
|
protected abstract com.google.common.collect.ImmutableSortedSet<SourcePath> |
resolveDefaultBuildTargetSourcePath(DefaultBuildTargetSourcePath targetSourcePath) |
protected abstract com.google.common.collect.ImmutableSortedSet<SourcePath> resolveDefaultBuildTargetSourcePath(DefaultBuildTargetSourcePath targetSourcePath)
public abstract String getSourcePathName(BuildTarget target, SourcePath sourcePath)
getSourcePathName
in interface SourcePathResolver
protected abstract ProjectFilesystem getBuildTargetSourcePathFilesystem(BuildTargetSourcePath sourcePath)
public <T> com.google.common.collect.ImmutableMap<T,com.google.common.collect.ImmutableSortedSet<Path>> getMappedPaths(Map<T,SourcePath> sourcePathMap)
getMappedPaths
in interface SourcePathResolver
public ProjectFilesystem getFilesystem(SourcePath sourcePath)
getFilesystem
in interface SourcePathResolver
ProjectFilesystem
associated with sourcePath
.public com.google.common.collect.ImmutableSortedSet<Path> getAbsolutePath(SourcePath sourcePath)
getAbsolutePath
in interface SourcePathResolver
Path
instances for this sourcePath
, resolved using its associated
ProjectFilesystem
.public com.google.common.collect.ImmutableSortedSet<Path> getAllAbsolutePaths(Collection<? extends SourcePath> sourcePaths)
getAllAbsolutePaths
in interface SourcePathResolver
public com.google.common.collect.ImmutableSortedSet<Path> getRelativePath(SourcePath sourcePath)
getRelativePath
in interface SourcePathResolver
Path
instances the sourcePath
refers to, relative to its owning
ProjectFilesystem
.public com.google.common.collect.ImmutableSortedSet<Path> getIdeallyRelativePath(SourcePath sourcePath)
getIdeallyRelativePath
in interface SourcePathResolver
Path
instances the sourcePath
refers to, ideally relative to its
owning ProjectFilesystem
. Absolute path may get returned however!
We should make sure that getPathPrivateImpl(com.facebook.buck.core.sourcepath.SourcePath)
always returns a relative path
after which we should simply call getRelativePath(com.facebook.buck.core.sourcepath.SourcePath)
. Until then we still need this
nonsense.
public com.google.common.collect.ImmutableMap<String,SourcePath> getSourcePathNames(BuildTarget target, String parameter, Iterable<SourcePath> sourcePaths)
getSourcePathNames
in interface SourcePathResolver
public <T> com.google.common.collect.ImmutableMap<String,T> getSourcePathNames(BuildTarget target, String parameter, Iterable<T> objects, java.util.function.Predicate<T> filter, java.util.function.Function<T,SourcePath> objectSourcePathFunction)
getSourcePathNames
in interface SourcePathResolver
public com.google.common.collect.ImmutableCollection<Path> filterInputsToCompareToOutput(Iterable<? extends SourcePath> sources)
filterInputsToCompareToOutput
in interface SourcePathResolver
public com.google.common.collect.ImmutableSortedSet<Path> getRelativePath(ProjectFilesystem projectFilesystem, SourcePath sourcePath)
getRelativePath
in interface SourcePathResolver
Path
instances to the given SourcePath
that is relative to the given
ProjectFilesystem
public com.google.common.collect.ImmutableMap<Path,Path> createRelativeMap(Path basePath, Iterable<SourcePath> sourcePaths)
SourcePathResolver
createRelativeMap
in interface SourcePathResolver