Search in sources :

Example 1 with NonClasspathDirectoriesScope

use of com.intellij.psi.search.NonClasspathDirectoriesScope in project intellij-community by JetBrains.

the class MavenGroovyPomScriptType method doPatchResolveScope.

public GlobalSearchScope doPatchResolveScope(@NotNull GroovyFile file, @NotNull GlobalSearchScope baseScope) {
    final Module module = ModuleUtilCore.findModuleForPsiElement(file);
    if (module == null) {
        return baseScope;
    }
    Project project = module.getProject();
    GlobalSearchScope result = baseScope;
    CachedValuesManager cachedValuesManager = CachedValuesManager.getManager(file.getProject());
    Boolean hasGroovyModuleLib = cachedValuesManager.getCachedValue(file.getProject(), () -> CachedValueProvider.Result.createSingleDependency(hasModuleWithGroovyLibrary(project), ProjectRootManagerEx.getInstanceEx(project)));
    if (hasGroovyModuleLib) {
        final Collection<VirtualFile> files = additionalScopeFiles();
        result = result.uniteWith(new NonClasspathDirectoriesScope(files));
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NonClasspathDirectoriesScope(com.intellij.psi.search.NonClasspathDirectoriesScope) Project(com.intellij.openapi.project.Project) CachedValuesManager(com.intellij.psi.util.CachedValuesManager) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Module(com.intellij.openapi.module.Module)

Example 2 with NonClasspathDirectoriesScope

use of com.intellij.psi.search.NonClasspathDirectoriesScope 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)

Aggregations

Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)2 NonClasspathDirectoriesScope (com.intellij.psi.search.NonClasspathDirectoriesScope)2 ExternalModuleBuildGlobalSearchScope (com.intellij.openapi.externalSystem.psi.search.ExternalModuleBuildGlobalSearchScope)1 Module (com.intellij.openapi.module.Module)1 JdkOrderEntry (com.intellij.openapi.roots.JdkOrderEntry)1 OrderEntry (com.intellij.openapi.roots.OrderEntry)1 CachedValuesManager (com.intellij.psi.util.CachedValuesManager)1