Search in sources :

Example 1 with VirtualFileFilter

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileFilter(com.intellij.openapi.vfs.VirtualFileFilter) FileType(com.intellij.openapi.fileTypes.FileType) PythonFileType(com.jetbrains.python.PythonFileType) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx)

Example 2 with VirtualFileFilter

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileFilter(com.intellij.openapi.vfs.VirtualFileFilter) HashSet(java.util.HashSet)

Example 3 with VirtualFileFilter

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);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileFilter(com.intellij.openapi.vfs.VirtualFileFilter) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 4 with VirtualFileFilter

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);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileFilter(com.intellij.openapi.vfs.VirtualFileFilter) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 5 with VirtualFileFilter

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FindInProjectManager(com.intellij.find.findInProject.FindInProjectManager) FindBundle(com.intellij.find.FindBundle) ReadAction(com.intellij.openapi.application.ReadAction) TrigramBuilder(com.intellij.openapi.util.text.TrigramBuilder) PsiManager(com.intellij.psi.PsiManager) HashMultiset(com.google.common.collect.HashMultiset) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FindModel(com.intellij.find.FindModel) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) ProgressManager(com.intellij.openapi.progress.ProgressManager) DumbService(com.intellij.openapi.project.DumbService) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager) Processors(com.intellij.util.Processors) ProjectUtil(com.intellij.openapi.project.ProjectUtil) UsageViewManagerImpl(com.intellij.usages.impl.UsageViewManagerImpl) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) PsiUtilCore(com.intellij.psi.util.PsiUtilCore) com.intellij.psi.search(com.intellij.psi.search) Processor(com.intellij.util.Processor) ApplicationManager(com.intellij.openapi.application.ApplicationManager) IdIndex(com.intellij.psi.impl.cache.impl.id.IdIndex) Registry(com.intellij.openapi.util.registry.Registry) VirtualFileVisitor(com.intellij.openapi.vfs.VirtualFileVisitor) NotNull(org.jetbrains.annotations.NotNull) java.util(java.util) Multiset(com.google.common.collect.Multiset) ModuleManager(com.intellij.openapi.module.ModuleManager) PsiSearchHelperImpl(com.intellij.psi.impl.search.PsiSearchHelperImpl) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) UsageInfo(com.intellij.usageView.UsageInfo) ContainerUtil(com.intellij.util.containers.ContainerUtil) com.intellij.openapi.roots(com.intellij.openapi.roots) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) FileBasedIndexImpl(com.intellij.util.indexing.FileBasedIndexImpl) CacheManager(com.intellij.psi.impl.cache.CacheManager) FindUsagesProcessPresentation(com.intellij.usages.FindUsagesProcessPresentation) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) PsiBinaryFile(com.intellij.psi.PsiBinaryFile) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) StringUtil(com.intellij.openapi.util.text.StringUtil) VirtualFileFilter(com.intellij.openapi.vfs.VirtualFileFilter) FileType(com.intellij.openapi.fileTypes.FileType) AtomicLong(java.util.concurrent.atomic.AtomicLong) UsageLimitUtil(com.intellij.usages.UsageLimitUtil) Pair(com.intellij.openapi.util.Pair) TrigramIndex(com.intellij.find.ngrams.TrigramIndex) Condition(com.intellij.openapi.util.Condition) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileFilter(com.intellij.openapi.vfs.VirtualFileFilter) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 VirtualFileFilter (com.intellij.openapi.vfs.VirtualFileFilter)9 FileType (com.intellij.openapi.fileTypes.FileType)2 Module (com.intellij.openapi.module.Module)2 File (java.io.File)2 HashMultiset (com.google.common.collect.HashMultiset)1 Multiset (com.google.common.collect.Multiset)1 FindBundle (com.intellij.find.FindBundle)1 FindModel (com.intellij.find.FindModel)1 FindInProjectManager (com.intellij.find.findInProject.FindInProjectManager)1 TrigramIndex (com.intellij.find.ngrams.TrigramIndex)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ApplicationNamesInfo (com.intellij.openapi.application.ApplicationNamesInfo)1 ReadAction (com.intellij.openapi.application.ReadAction)1 Logger (com.intellij.openapi.diagnostic.Logger)1 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1