Search in sources :

Example 6 with ExcludesConfiguration

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

the class ExcludeFromValidationAction method getExcludedConfigurationAndFile.

@Nullable
private static Pair<ExcludesConfiguration, VirtualFile> getExcludedConfigurationAndFile(final AnActionEvent event, Project project) {
    Navigatable navigatable = event.getData(CommonDataKeys.NAVIGATABLE);
    if (project != null && navigatable instanceof OpenFileDescriptor) {
        final VirtualFile file = ((OpenFileDescriptor) navigatable).getFile();
        final ExcludesConfiguration configuration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
        return Pair.create(configuration, file);
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Navigatable(com.intellij.pom.Navigatable) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with ExcludesConfiguration

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

the class InspectionValidatorWrapper method getProcessingItems.

@Override
@NotNull
public ProcessingItem[] getProcessingItems(final CompileContext context) {
    final Project project = context.getProject();
    if (project.isDefault() || !ValidationConfiguration.shouldValidate(this, context)) {
        return ProcessingItem.EMPTY_ARRAY;
    }
    final ExcludesConfiguration excludesConfiguration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
    final List<ProcessingItem> items = DumbService.getInstance(project).runReadActionInSmartMode((Computable<List<ProcessingItem>>) () -> {
        final CompileScope compileScope = context.getCompileScope();
        if (!myValidator.isAvailableOnScope(compileScope))
            return null;
        final ArrayList<ProcessingItem> items1 = new ArrayList<>();
        final Processor<VirtualFile> processor = file -> {
            if (!file.isValid()) {
                return true;
            }
            if (myCompilerManager.isExcludedFromCompilation(file) || excludesConfiguration.isExcluded(file)) {
                return true;
            }
            final Module module = context.getModuleByFile(file);
            if (module != null) {
                final PsiFile psiFile = myPsiManager.findFile(file);
                if (psiFile != null) {
                    items1.add(new MyValidatorProcessingItem(psiFile));
                }
            }
            return true;
        };
        ContainerUtil.process(myValidator.getFilesToProcess(myPsiManager.getProject(), context), processor);
        return items1;
    });
    if (items == null)
        return ProcessingItem.EMPTY_ARRAY;
    return items.toArray(new ProcessingItem[items.size()]);
}
Also used : Project(com.intellij.openapi.project.Project) Processor(com.intellij.util.Processor) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 8 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 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)

Example 9 with ExcludesConfiguration

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

the class AndroidCompileUtil method includeAaptGenSourceRootToCompilation.

private static void includeAaptGenSourceRootToCompilation(AndroidFacet facet) {
    final Project project = facet.getModule().getProject();
    final ExcludesConfiguration configuration = ((CompilerConfigurationImpl) CompilerConfiguration.getInstance(project)).getExcludedEntriesConfiguration();
    final ExcludeEntryDescription[] descriptions = configuration.getExcludeEntryDescriptions();
    configuration.removeAllExcludeEntryDescriptions();
    for (ExcludeEntryDescription description : descriptions) {
        final VirtualFile vFile = description.getVirtualFile();
        if (!Comparing.equal(vFile, AndroidRootUtil.getAaptGenDir(facet))) {
            configuration.addExcludeEntryDescription(description);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription) CompilerConfigurationImpl(com.intellij.compiler.CompilerConfigurationImpl)

Example 10 with ExcludesConfiguration

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

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