Search in sources :

Example 1 with ExcludesConfiguration

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

the class GroovyCompilerConfigurable method createExcludedConfigurable.

private ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
    final ExcludesConfiguration configuration = myConfig.getExcludeFromStubGeneration();
    final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && !index.isExcluded(file);
        }
    };
    descriptor.setRoots(ContainerUtil.concat(ContainerUtil.map(ModuleManager.getInstance(project).getModules(), new Function<Module, List<VirtualFile>>() {

        @Override
        public List<VirtualFile> fun(final Module module) {
            return ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
        }
    })));
    return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludedEntriesConfigurable(com.intellij.openapi.compiler.options.ExcludedEntriesConfigurable) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) List(java.util.List) Module(com.intellij.openapi.module.Module)

Example 2 with ExcludesConfiguration

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

the class ExcludeFromValidationAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    final Pair<ExcludesConfiguration, VirtualFile> pair = getExcludedConfigurationAndFile(e, project);
    if (pair == null)
        return;
    final ExcludeEntryDescription description = new ExcludeEntryDescription(pair.getSecond(), false, true, project);
    pair.getFirst().addExcludeEntryDescription(description);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription)

Example 3 with ExcludesConfiguration

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

the class ValidationConfigurable method createExcludedConfigurable.

private static ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
    final ExcludesConfiguration configuration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
    final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {

        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && (project.isDefault() || !index.isExcluded(file));
        }
    };
    List<VirtualFile> allContentRoots = new ArrayList<>();
    for (final Module module : ModuleManager.getInstance(project).getModules()) {
        final VirtualFile[] moduleContentRoots = ModuleRootManager.getInstance(module).getContentRoots();
        Collections.addAll(allContentRoots, moduleContentRoots);
    }
    descriptor.setRoots(allContentRoots);
    return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludedEntriesConfigurable(com.intellij.openapi.compiler.options.ExcludedEntriesConfigurable) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) Module(com.intellij.openapi.module.Module)

Example 4 with ExcludesConfiguration

use of com.intellij.openapi.compiler.options.ExcludesConfiguration 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 5 with ExcludesConfiguration

use of com.intellij.openapi.compiler.options.ExcludesConfiguration 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)

Aggregations

ExcludesConfiguration (com.intellij.openapi.compiler.options.ExcludesConfiguration)11 ExcludeEntryDescription (com.intellij.openapi.compiler.options.ExcludeEntryDescription)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 Module (com.intellij.openapi.module.Module)4 Project (com.intellij.openapi.project.Project)4 ExcludedEntriesConfigurable (com.intellij.openapi.compiler.options.ExcludedEntriesConfigurable)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)2 List (java.util.List)2 CompilerConfiguration (com.intellij.compiler.CompilerConfiguration)1 CompilerConfigurationImpl (com.intellij.compiler.CompilerConfigurationImpl)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Navigatable (com.intellij.pom.Navigatable)1 PsiFile (com.intellij.psi.PsiFile)1 Processor (com.intellij.util.Processor)1 HashSet (com.intellij.util.containers.hash.HashSet)1 ArrayList (java.util.ArrayList)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)1 NotNull (org.jetbrains.annotations.NotNull)1