Search in sources :

Example 1 with CompileContextEx

use of com.intellij.openapi.compiler.ex.CompileContextEx in project intellij-community by JetBrains.

the class InspectionValidatorUtil method expandCompileScopeIfNeeded.

public static Collection<VirtualFile> expandCompileScopeIfNeeded(final Collection<VirtualFile> result, final CompileContext context) {
    final ProjectFileIndex index = ProjectRootManager.getInstance(context.getProject()).getFileIndex();
    final THashSet<VirtualFile> set = new THashSet<>();
    final THashSet<Module> modules = new THashSet<>();
    for (VirtualFile file : result) {
        if (index.getSourceRootForFile(file) == null) {
            set.add(file);
            ContainerUtil.addIfNotNull(modules, index.getModuleForFile(file));
        }
    }
    if (!set.isEmpty()) {
        ((CompileContextEx) context).addScope(new FileSetCompileScope(set, modules.toArray(new Module[modules.size()])));
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) CompileContextEx(com.intellij.openapi.compiler.ex.CompileContextEx) Module(com.intellij.openapi.module.Module) THashSet(gnu.trove.THashSet) FileSetCompileScope(com.intellij.compiler.impl.FileSetCompileScope)

Aggregations

FileSetCompileScope (com.intellij.compiler.impl.FileSetCompileScope)1 CompileContextEx (com.intellij.openapi.compiler.ex.CompileContextEx)1 Module (com.intellij.openapi.module.Module)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 THashSet (gnu.trove.THashSet)1