public abstract class SyntheticLibrary
extends java.lang.Object
Library
.
When provided by AdditionalLibraryRootsProvider
, a library of this type contributes the followings:
getSourceRoots()
) extend GlobalSearchScope.allScope(Project)
(in UI, "Project and Libraries" scope).
Files contained inside the returned roots are considered as library source files:
ProjectFileIndex.isInLibrarySource(VirtualFile)
returns true
for them.
getExcludedRoots()
).
These roots won't be indexed and will be handled as LibraryEx.getExcludedRoots()
getSourceRoots()
are handled similarly to library.getFiles(OrderRootType.SOURCES)
.
isShowInExternalLibrariesNode()
and
is instance of ItemPresentation
AdditionalLibraryRootsProvider
Constructor and Description |
---|
SyntheticLibrary() |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(VirtualFile file) |
boolean |
contains(VirtualFile file,
boolean includeSources,
boolean includeBinaries) |
abstract boolean |
equals(java.lang.Object o)
This method is vital if this library is shown under "External Libraries" (the library should implement ItemPresentation for that).
|
java.util.Collection<VirtualFile> |
getAllRoots() |
java.util.Collection<VirtualFile> |
getBinaryRoots() |
java.util.Set<VirtualFile> |
getExcludedRoots() |
Condition<VirtualFile> |
getExcludeFileCondition() |
abstract java.util.Collection<VirtualFile> |
getSourceRoots() |
abstract int |
hashCode() |
boolean |
isShowInExternalLibrariesNode() |
static SyntheticLibrary |
newImmutableLibrary(java.util.Collection<VirtualFile> sourceRoots)
Deprecated.
use
newImmutableLibrary(List) instead |
static SyntheticLibrary |
newImmutableLibrary(java.util.List<VirtualFile> sourceRoots) |
static SyntheticLibrary |
newImmutableLibrary(java.util.List<VirtualFile> sourceRoots,
java.util.List<VirtualFile> binaryRoots,
java.util.Set<VirtualFile> excludedRoots,
Condition<VirtualFile> excludeCondition) |
static SyntheticLibrary |
newImmutableLibrary(java.util.List<VirtualFile> sourceRoots,
java.util.Set<VirtualFile> excludedRoots,
Condition<VirtualFile> excludeCondition) |
public abstract java.util.Collection<VirtualFile> getSourceRoots()
public java.util.Collection<VirtualFile> getBinaryRoots()
public java.util.Set<VirtualFile> getExcludedRoots()
public Condition<VirtualFile> getExcludeFileCondition()
null
E.g. you can exclude all non-java file by returning file -> !file.getName().endsWith(".java")
Excluding directory leads to excluding all its content recursively.
NOTE: The condition is participating in building indexing and project model, it must be bloody fast in order not to affect overall IDE performance.
NOTE 2: Try not to use file.getFileType() method since it might load file's content to know the type, which will try to load encoding and guess files project which is lead to SOE.
public boolean isShowInExternalLibrariesNode()
public abstract boolean equals(java.lang.Object o)
ExternalLibrariesNode.getChildren()
invocation will create a new
SyntheticLibraryElementNode
instance passing this library as a value.
In order to figure out if "External Library" children are updated or not, AbstractTreeUi uses
node's equals/hashCode methods which in turn depend on this library's equals/hashCode methods:
see AbstractTreeNode.hashCode()
.
Please make sure that two SyntheticLibrary instances are equal if they reference the same state. Otherwise, constant UI updates
will degrade performance.
Consider implementing a better equals/hashCode if needed or instantiate SyntheticLibrary
only if state
changed (use some caching in AdditionalLibraryRootsProvider.getAdditionalProjectLibraries(Project)
).
equals
in class java.lang.Object
public abstract int hashCode()
hashCode
in class java.lang.Object
javadoc
public static SyntheticLibrary newImmutableLibrary(java.util.List<VirtualFile> sourceRoots)
@Deprecated public static SyntheticLibrary newImmutableLibrary(java.util.Collection<VirtualFile> sourceRoots)
newImmutableLibrary(List)
insteadpublic static SyntheticLibrary newImmutableLibrary(java.util.List<VirtualFile> sourceRoots, java.util.Set<VirtualFile> excludedRoots, Condition<VirtualFile> excludeCondition)
public static SyntheticLibrary newImmutableLibrary(java.util.List<VirtualFile> sourceRoots, java.util.List<VirtualFile> binaryRoots, java.util.Set<VirtualFile> excludedRoots, Condition<VirtualFile> excludeCondition)
public final java.util.Collection<VirtualFile> getAllRoots()
public final boolean contains(VirtualFile file, boolean includeSources, boolean includeBinaries)
public final boolean contains(VirtualFile file)