Search in sources :

Example 6 with ExcludeEntryDescription

use of com.intellij.openapi.compiler.options.ExcludeEntryDescription in project intellij-community by JetBrains.

the class CompilerReferencesFindUsagesTest method testFindUsagesWithExcludedFromCompilationFile.

public void testFindUsagesWithExcludedFromCompilationFile() {
    doTestRunnableFindUsagesWithExcludesConfiguration(configuration -> {
        final VirtualFile dirToExclude = findClass("Foo").getContainingFile().getVirtualFile();
        configuration.addExcludeEntryDescription(new ExcludeEntryDescription(dirToExclude, false, true, myProject));
    }, 2, "Foo.java", "Bar.java");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription)

Example 7 with ExcludeEntryDescription

use of com.intellij.openapi.compiler.options.ExcludeEntryDescription in project android by JetBrains.

the class AndroidPrecompileTask method unexcludeAllSourceRoots.

private static void unexcludeAllSourceRoots(AndroidFacet facet, ExcludesConfiguration configuration) {
    final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(facet.getModule()).getSourceRoots();
    final Set<VirtualFile> sourceRootSet = new HashSet<>();
    sourceRootSet.addAll(Arrays.asList(sourceRoots));
    final String aidlGenSourceRootPath = AndroidRootUtil.getAidlGenSourceRootPath(facet);
    if (aidlGenSourceRootPath != null) {
        final VirtualFile aidlGenSourceRoot = LocalFileSystem.getInstance().findFileByPath(aidlGenSourceRootPath);
        if (aidlGenSourceRoot != null) {
            sourceRootSet.remove(aidlGenSourceRoot);
        }
    }
    final String aptGenSourceRootPath = AndroidRootUtil.getAptGenSourceRootPath(facet);
    if (aptGenSourceRootPath != null) {
        final VirtualFile aptGenSourceRoot = LocalFileSystem.getInstance().findFileByPath(aptGenSourceRootPath);
        if (aptGenSourceRoot != null) {
            sourceRootSet.remove(aptGenSourceRoot);
        }
    }
    final VirtualFile rsGenRoot = AndroidRootUtil.getRenderscriptGenDir(facet);
    if (rsGenRoot != null) {
        sourceRootSet.remove(rsGenRoot);
    }
    final VirtualFile buildconfigGenDir = AndroidRootUtil.getBuildconfigGenDir(facet);
    if (buildconfigGenDir != null) {
        sourceRootSet.remove(buildconfigGenDir);
    }
    final ExcludeEntryDescription[] descriptions = configuration.getExcludeEntryDescriptions();
    configuration.removeAllExcludeEntryDescriptions();
    for (ExcludeEntryDescription description : descriptions) {
        final VirtualFile file = description.getVirtualFile();
        if (file == null || !sourceRootSet.contains(file)) {
            configuration.addExcludeEntryDescription(description);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription) HashSet(com.intellij.util.containers.hash.HashSet)

Example 8 with ExcludeEntryDescription

use of com.intellij.openapi.compiler.options.ExcludeEntryDescription in project android by JetBrains.

the class AndroidPrecompileTask method prepareForCompilation.

private static boolean prepareForCompilation(CompileContext context) {
    final Project project = context.getProject();
    if (!checkArtifacts(context)) {
        return false;
    }
    checkAndroidDependencies(context);
    ExcludesConfiguration configuration = CompilerConfiguration.getInstance(project).getExcludedEntriesConfiguration();
    Set<ExcludeEntryDescription> addedEntries = new HashSet<>();
    for (Module module : ModuleManager.getInstance(project).getModules()) {
        final AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet == null) {
            continue;
        }
        if (context.isRebuild()) {
            clearResCache(facet, context);
        }
        final AndroidPlatform platform = facet.getConfiguration().getAndroidPlatform();
        final int platformToolsRevision = platform != null ? platform.getSdkData().getPlatformToolsRevision() : -1;
        LOG.debug("Platform-tools revision for module " + module.getName() + " is " + platformToolsRevision);
        if (!facet.isAppProject()) {
            if (platformToolsRevision >= 0 && platformToolsRevision <= 7) {
                LOG.debug("Excluded sources of module " + module.getName());
                excludeAllSourceRoots(module, configuration, addedEntries);
            } else {
                // todo: support this by project converter to use on compile-server
                unexcludeAllSourceRoots(facet, configuration);
            }
        }
    }
    if (addedEntries.size() > 0) {
        LOG.debug("Files excluded by Android: " + addedEntries.size());
        project.getMessageBus().connect().subscribe(CompilerTopics.COMPILATION_STATUS, new MyCompilationStatusListener(project, addedEntries));
    }
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) HashSet(com.intellij.util.containers.hash.HashSet)

Example 9 with ExcludeEntryDescription

use of com.intellij.openapi.compiler.options.ExcludeEntryDescription in project android by JetBrains.

the class AndroidCompileUtil method excludeFromCompilation.

private static void excludeFromCompilation(@NotNull Project project, @NotNull VirtualFile dir) {
    final ExcludesConfiguration configuration = CompilerConfiguration.getInstance(project).getExcludedEntriesConfiguration();
    for (ExcludeEntryDescription description : configuration.getExcludeEntryDescriptions()) {
        if (Comparing.equal(description.getVirtualFile(), dir)) {
            return;
        }
    }
    configuration.addExcludeEntryDescription(new ExcludeEntryDescription(dir, true, false, project));
}
Also used : ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription)

Example 10 with ExcludeEntryDescription

use of com.intellij.openapi.compiler.options.ExcludeEntryDescription in project intellij-community by JetBrains.

the class CompilerExcludes method isAvailable.

public static boolean isAvailable(Project project) {
    final CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(project);
    final ExcludeEntryDescription[] excludeEntryDescriptions = compilerConfiguration.getExcludedEntriesConfiguration().getExcludeEntryDescriptions();
    return excludeEntryDescriptions.length > 0;
}
Also used : ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription) CompilerConfigurationImpl(com.intellij.compiler.CompilerConfigurationImpl)

Aggregations

ExcludeEntryDescription (com.intellij.openapi.compiler.options.ExcludeEntryDescription)17 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 ExcludesConfiguration (com.intellij.openapi.compiler.options.ExcludesConfiguration)6 Project (com.intellij.openapi.project.Project)6 CompilerConfigurationImpl (com.intellij.compiler.CompilerConfigurationImpl)2 Module (com.intellij.openapi.module.Module)2 HashSet (com.intellij.util.containers.hash.HashSet)2 NotNull (org.jetbrains.annotations.NotNull)2 CompilerConfiguration (com.intellij.compiler.CompilerConfiguration)1 ExcludedEntriesConfiguration (com.intellij.openapi.compiler.options.ExcludedEntriesConfiguration)1 ExcludedEntriesListener (com.intellij.openapi.compiler.options.ExcludedEntriesListener)1 FileType (com.intellij.openapi.fileTypes.FileType)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 VfsUtilCore (com.intellij.openapi.vfs.VfsUtilCore)1 ManagingFS (com.intellij.openapi.vfs.newvfs.ManagingFS)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 Collection (java.util.Collection)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1