Search in sources :

Example 1 with ExternalModuleBuildGlobalSearchScope

use of com.intellij.openapi.externalSystem.psi.search.ExternalModuleBuildGlobalSearchScope in project intellij-community by JetBrains.

the class GradleScriptType method patchResolveScopeInner.

public GlobalSearchScope patchResolveScopeInner(@Nullable Module module, @NotNull GlobalSearchScope baseScope) {
    if (module == null)
        return GlobalSearchScope.EMPTY_SCOPE;
    if (!ExternalSystemApiUtil.isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, module))
        return baseScope;
    GlobalSearchScope result = GlobalSearchScope.EMPTY_SCOPE;
    final Project project = module.getProject();
    for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) {
        if (entry instanceof JdkOrderEntry) {
            GlobalSearchScope scopeForSdk = LibraryScopeCache.getInstance(project).getScopeForSdk((JdkOrderEntry) entry);
            result = result.uniteWith(scopeForSdk);
        }
    }
    String modulePath = ExternalSystemApiUtil.getExternalProjectPath(module);
    if (modulePath == null)
        return result;
    final Collection<VirtualFile> files = GradleBuildClasspathManager.getInstance(project).getModuleClasspathEntries(modulePath);
    result = new ExternalModuleBuildGlobalSearchScope(project, result.uniteWith(new NonClasspathDirectoriesScope(files)), modulePath);
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NonClasspathDirectoriesScope(com.intellij.psi.search.NonClasspathDirectoriesScope) Project(com.intellij.openapi.project.Project) JdkOrderEntry(com.intellij.openapi.roots.JdkOrderEntry) OrderEntry(com.intellij.openapi.roots.OrderEntry) JdkOrderEntry(com.intellij.openapi.roots.JdkOrderEntry) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ExternalModuleBuildGlobalSearchScope(com.intellij.openapi.externalSystem.psi.search.ExternalModuleBuildGlobalSearchScope) ExternalModuleBuildGlobalSearchScope(com.intellij.openapi.externalSystem.psi.search.ExternalModuleBuildGlobalSearchScope)

Example 2 with ExternalModuleBuildGlobalSearchScope

use of com.intellij.openapi.externalSystem.psi.search.ExternalModuleBuildGlobalSearchScope in project intellij-community by JetBrains.

the class GradleClassFinder method findClass.

@Override
public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
    PsiClass aClass = super.findClass(qualifiedName, scope);
    if (aClass == null || scope instanceof ExternalModuleBuildGlobalSearchScope || scope instanceof EverythingGlobalScope) {
        return aClass;
    }
    PsiFile containingFile = aClass.getContainingFile();
    VirtualFile file = containingFile != null ? containingFile.getVirtualFile() : null;
    return (file != null && !ProjectFileIndex.SERVICE.getInstance(myProject).isInContent(file) && !ProjectFileIndex.SERVICE.getInstance(myProject).isInLibraryClasses(file) && !ProjectFileIndex.SERVICE.getInstance(myProject).isInLibrarySource(file)) ? aClass : null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiClass(com.intellij.psi.PsiClass) EverythingGlobalScope(com.intellij.psi.search.EverythingGlobalScope) PsiFile(com.intellij.psi.PsiFile) ExternalModuleBuildGlobalSearchScope(com.intellij.openapi.externalSystem.psi.search.ExternalModuleBuildGlobalSearchScope)

Aggregations

ExternalModuleBuildGlobalSearchScope (com.intellij.openapi.externalSystem.psi.search.ExternalModuleBuildGlobalSearchScope)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Project (com.intellij.openapi.project.Project)1 JdkOrderEntry (com.intellij.openapi.roots.JdkOrderEntry)1 OrderEntry (com.intellij.openapi.roots.OrderEntry)1 PsiClass (com.intellij.psi.PsiClass)1 PsiFile (com.intellij.psi.PsiFile)1 EverythingGlobalScope (com.intellij.psi.search.EverythingGlobalScope)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 NonClasspathDirectoriesScope (com.intellij.psi.search.NonClasspathDirectoriesScope)1