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;
}
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()]);
}
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));
}
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);
}
}
}
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));
}
}
Aggregations