use of com.intellij.openapi.vfs.VirtualFileFilter in project intellij-community by JetBrains.
the class PyMultiFileResolveTestCase method doResolve.
protected PsiElement doResolve(PsiFile psiFile) {
final PsiReference ref = PyResolveTestCase.findReferenceByMarker(psiFile);
final PsiManagerEx psiManager = (PsiManagerEx) myFixture.getPsiManager();
psiManager.setAssertOnFileLoadingFilter(new VirtualFileFilter() {
@Override
public boolean accept(VirtualFile file) {
FileType fileType = file.getFileType();
return fileType == PythonFileType.INSTANCE;
}
}, myFixture.getTestRootDisposable());
final PsiElement result;
if (ref instanceof PsiPolyVariantReference) {
final ResolveResult[] resolveResults = ((PsiPolyVariantReference) ref).multiResolve(false);
result = resolveResults.length == 0 || !resolveResults[0].isValidResult() ? null : resolveResults[0].getElement();
} else {
result = ref.resolve();
}
psiManager.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, myFixture.getTestRootDisposable());
return result;
}
use of com.intellij.openapi.vfs.VirtualFileFilter in project intellij-community by JetBrains.
the class Src15RepositoryUseTest method testAnnotationIndex.
public void testAnnotationIndex() throws Exception {
PsiManagerEx.getInstanceEx(getProject()).setAssertOnFileLoadingFilter(new VirtualFileFilter() {
@Override
public boolean accept(final VirtualFile file) {
return !"package-info.java".equals(file.getName());
}
}, getTestRootDisposable());
final PsiClass annotationTypeClass = findClass("annotations.AnnotationType");
assertTrue(annotationTypeClass.isAnnotationType());
final Collection<PsiMember> all = AnnotatedMembersSearch.search(annotationTypeClass, GlobalSearchScope.moduleScope(myModule)).findAll();
assertEquals(2, all.size());
Set<String> correctNames = new HashSet<>(Arrays.asList("AnnotatedClass", "correctMethod"));
for (PsiMember member : all) {
assertTrue(correctNames.contains(member.getName()));
}
final Collection<PsiPackage> packages = AnnotatedPackagesSearch.search(annotationTypeClass, GlobalSearchScope.moduleScope(myModule)).findAll();
assertEquals(1, packages.size());
assertEquals("annotated", packages.iterator().next().getQualifiedName());
tearDownLoadingFilter();
}
use of com.intellij.openapi.vfs.VirtualFileFilter in project intellij-community by JetBrains.
the class AppEngineFacetConverterTest method testConvert.
public void testConvert() throws IOException {
String testDataPath = "plugins/google-app-engine/testData/conversion/appEngineFacet/";
File testData = PathManagerEx.findFileUnderProjectHome(testDataPath + "before", getClass());
File tempDir = FileUtil.createTempDirectory("app-engine-project", null);
FileUtil.copyDir(testData, tempDir);
ProjectConversionTestUtil.convert(tempDir.getAbsolutePath());
File expectedDataDir = PathManagerEx.findFileUnderProjectHome(testDataPath + "after", getClass());
PlatformTestUtil.assertDirectoriesEqual(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(expectedDataDir), LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir), new VirtualFileFilter() {
@Override
public boolean accept(VirtualFile file) {
return !file.getName().startsWith(ProjectConversionUtil.PROJECT_FILES_BACKUP);
}
});
}
use of com.intellij.openapi.vfs.VirtualFileFilter in project android by JetBrains.
the class AndroidConversionTest method testConvert.
public void testConvert() throws IOException {
final String testDataPath = AndroidTestCase.getTestDataPath() + "/conversion/proguardOptions";
final File testData = new File(testDataPath, "before");
final File tempDir = FileUtil.createTempDirectory("project", null);
FileUtil.copyDir(testData, tempDir);
ProjectConversionTestUtil.convert(tempDir.getAbsolutePath());
final File expectedDataDir = new File(testDataPath, "after");
PlatformTestUtil.assertDirectoriesEqual(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(expectedDataDir), LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir), new VirtualFileFilter() {
@Override
public boolean accept(VirtualFile file) {
return !file.getName().startsWith(ProjectConversionUtil.PROJECT_FILES_BACKUP);
}
});
}
use of com.intellij.openapi.vfs.VirtualFileFilter in project intellij-community by JetBrains.
the class FindInProjectTask method iterateAll.
private static boolean iterateAll(@NotNull VirtualFile[] files, @NotNull final GlobalSearchScope searchScope, @NotNull final ContentIterator iterator) {
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
final VirtualFileFilter contentFilter = file -> file.isDirectory() || !fileTypeManager.isFileIgnored(file) && !file.getFileType().isBinary() && searchScope.contains(file);
for (VirtualFile file : files) {
if (!VfsUtilCore.iterateChildrenRecursively(file, contentFilter, iterator))
return false;
}
return true;
}
Aggregations