mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add ProjectFileIndex#isInLibrary(fileOrDir)
This commit is contained in:
@@ -858,7 +858,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
private void checkInfo(VirtualFile file,
|
||||
@Nullable Module module,
|
||||
boolean isInLibrary,
|
||||
boolean isInLibraryClasses,
|
||||
boolean isInLibrarySource,
|
||||
@Nullable String packageName,
|
||||
@Nullable final JpsModuleSourceRootType<?> moduleSourceRootType,
|
||||
@@ -872,8 +872,9 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
else {
|
||||
assertFalse("isInModuleSource", info.isInModuleSource());
|
||||
}
|
||||
assertEquals(isInLibrary, info.hasLibraryClassRoot());
|
||||
assertEquals(isInLibraryClasses, info.hasLibraryClassRoot());
|
||||
assertEquals(isInLibrarySource, info.isInLibrarySource());
|
||||
assertEquals(isInLibraryClasses || isInLibrarySource, myFileIndex.isInLibrary(file));
|
||||
|
||||
if (file.isDirectory()) {
|
||||
assertEquals(packageName, myFileIndex.getPackageNameByDirectory(file));
|
||||
|
||||
@@ -140,6 +140,16 @@ public interface ProjectFileIndex extends FileIndex {
|
||||
*/
|
||||
boolean isInLibraryClasses(@NotNull VirtualFile fileOrDir);
|
||||
|
||||
/**
|
||||
* Returns true if <code>fileOrDir</code> is a file which belongs to the classes or sources of some library.
|
||||
*
|
||||
* @param fileOrDir the file or directory to check.
|
||||
* @return true if the file belongs to the classes or sources of some library, false otherwise.
|
||||
*/
|
||||
default boolean isInLibrary(@NotNull VirtualFile fileOrDir) {
|
||||
return isInLibraryClasses(fileOrDir) || isInLibrarySource(fileOrDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if <code>fileOrDir</code> is a file or directory from library source.
|
||||
*
|
||||
@@ -173,4 +183,4 @@ public interface ProjectFileIndex extends FileIndex {
|
||||
* @return true if <code>file</code> is ignored, false otherwise.
|
||||
*/
|
||||
boolean isUnderIgnored(@NotNull VirtualFile file);
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -191,6 +191,12 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn
|
||||
return getInfoForFileOrDirectory(fileOrDir).isInLibrarySource();
|
||||
}
|
||||
|
||||
// a slightly faster implementation then the default one
|
||||
public boolean isInLibrary(@NotNull VirtualFile fileOrDir) {
|
||||
DirectoryInfo info = getInfoForFileOrDirectory(fileOrDir);
|
||||
return info.isInProject() && info.hasLibraryClassRoot() || info.isInLibrarySource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnored(@NotNull VirtualFile file) {
|
||||
return isExcluded(file);
|
||||
|
||||
Reference in New Issue
Block a user