Search in sources :

Example 11 with ExcludeEntryDescription

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

the class CompilerConfigurationImpl method createExcludedEntriesConfiguration.

// Overridden in Upsource
@NotNull
protected ExcludedEntriesConfiguration createExcludedEntriesConfiguration(@NotNull Project project) {
    final ExcludedEntriesConfiguration cfg = new ExcludedEntriesConfiguration(project.getMessageBus().syncPublisher(ExcludedEntriesListener.TOPIC));
    Disposer.register(project, cfg);
    project.getMessageBus().connect().subscribe(ExcludedEntriesListener.TOPIC, new ExcludedEntriesListener() {

        @Override
        public void onEntryAdded(@NotNull ExcludeEntryDescription description) {
            clearState();
        }

        @Override
        public void onEntryRemoved(@NotNull ExcludeEntryDescription description) {
            clearState();
        }

        private void clearState() {
            if (project.isOpen()) {
                BuildManager.getInstance().clearState(project);
            }
        }
    });
    return cfg;
}
Also used : ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription) ExcludedEntriesListener(com.intellij.openapi.compiler.options.ExcludedEntriesListener) ExcludedEntriesConfiguration(com.intellij.openapi.compiler.options.ExcludedEntriesConfiguration) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with ExcludeEntryDescription

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

the class ExcludedFromCompileFilesUtil method getExcludedFilesScope.

static GlobalSearchScope getExcludedFilesScope(@NotNull ExcludeEntryDescription[] descriptions, @NotNull Set<FileType> fileTypes, @NotNull Project project, @NotNull ProjectFileIndex fileIndex) {
    ManagingFS fs = ManagingFS.getInstance();
    final Collection<VirtualFile> excludedFiles = Stream.of(descriptions).flatMap(description -> {
        final VirtualFile file = description.getVirtualFile();
        if (file == null)
            return Stream.empty();
        if (description.isFile()) {
            return Stream.of(file);
        } else if (description.isIncludeSubdirectories()) {
            final Stream.Builder<VirtualFile> builder = Stream.builder();
            VfsUtilCore.iterateChildrenRecursively(file, f -> !f.isDirectory() || fs.areChildrenLoaded(f), f -> {
                builder.accept(f);
                return true;
            });
            return builder.build();
        } else {
            return fs.areChildrenLoaded(file) ? Stream.of(file.getChildren()) : Stream.empty();
        }
    }).filter(f -> !f.isDirectory() && fileTypes.contains(f.getFileType()) && fileIndex.isInSourceContent(f)).collect(Collectors.toList());
    return GlobalSearchScope.filesWithoutLibrariesScope(project, excludedFiles);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) Collection(java.util.Collection) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Set(java.util.Set) FileType(com.intellij.openapi.fileTypes.FileType) Collectors(java.util.stream.Collectors) Stream(java.util.stream.Stream) ManagingFS(com.intellij.openapi.vfs.newvfs.ManagingFS) Project(com.intellij.openapi.project.Project) NotNull(org.jetbrains.annotations.NotNull) ManagingFS(com.intellij.openapi.vfs.newvfs.ManagingFS)

Example 13 with ExcludeEntryDescription

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

the class ExcludeFromCompileAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    VirtualFile file = getSelectedFile();
    if (file != null && file.isValid()) {
        ExcludeEntryDescription description = new ExcludeEntryDescription(file, false, true, myProject);
        CompilerConfiguration.getInstance(myProject).getExcludedEntriesConfiguration().addExcludeEntryDescription(description);
        FileStatusManager.getInstance(myProject).fileStatusesChanged();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription)

Example 14 with ExcludeEntryDescription

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

the class MavenCompilerConfigurer method configure.

@Override
public void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module) {
    if (module == null)
        return;
    CompilerConfiguration configuration = CompilerConfiguration.getInstance(project);
    if (!Boolean.TRUE.equals(module.getUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY))) {
        String targetLevel = mavenProject.getTargetLevel();
        // default source and target settings of maven-compiler-plugin is 1.5, see details at http://maven.apache.org/plugins/maven-compiler-plugin
        configuration.setBytecodeTargetLevel(module, ObjectUtils.notNull(targetLevel, "1.5"));
    }
    module.putUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY, Boolean.FALSE);
    // Exclude src/main/archetype-resources
    VirtualFile dir = VfsUtil.findRelativeFile(mavenProject.getDirectoryFile(), "src", "main", "resources", "archetype-resources");
    if (dir != null && !configuration.isExcludedFromCompilation(dir)) {
        ExcludesConfiguration cfg = configuration.getExcludedEntriesConfiguration();
        cfg.addExcludeEntryDescription(new ExcludeEntryDescription(dir, true, false, project));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription) CompilerConfiguration(com.intellij.compiler.CompilerConfiguration)

Example 15 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 sourceRoot, @NotNull String aPackage) {
    final String buildConfigPath = sourceRoot.getPath() + '/' + aPackage.replace('.', '/') + "/BuildConfig.java";
    String url = VfsUtilCore.pathToUrl(buildConfigPath);
    final ExcludesConfiguration configuration = CompilerConfiguration.getInstance(project).getExcludedEntriesConfiguration();
    for (ExcludeEntryDescription description : configuration.getExcludeEntryDescriptions()) {
        if (Comparing.equal(description.getUrl(), url)) {
            return;
        }
    }
    configuration.addExcludeEntryDescription(new ExcludeEntryDescription(url, true, false, project));
}
Also used : ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription)

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