use of com.intellij.compiler.CompilerConfiguration in project intellij-plugins by JetBrains.
the class CompilerConfigGenerator method addLibClasses.
private void addLibClasses(final Element rootElement) throws IOException {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myModule.getProject()).getFileIndex();
final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(myModule.getProject());
final Ref<Boolean> noClasses = new Ref<>(true);
for (final VirtualFile sourceRoot : ModuleRootManager.getInstance(myModule).getSourceRoots(false)) {
fileIndex.iterateContentUnderDirectory(sourceRoot, file -> {
if (file.isDirectory())
return true;
if (!FlexCommonUtils.isSourceFile(file.getName()))
return true;
if (compilerConfiguration.isExcludedFromCompilation(file))
return true;
final String packageText = VfsUtilCore.getRelativePath(file.getParent(), sourceRoot, '.');
assert packageText != null : sourceRoot.getPath() + ": " + file.getPath();
final String qName = (packageText.length() > 0 ? packageText + "." : "") + file.getNameWithoutExtension();
if (isSourceFileWithPublicDeclaration(myModule, file, qName)) {
addOption(rootElement, CompilerOptionInfo.INCLUDE_CLASSES_INFO, qName);
noClasses.set(false);
}
return true;
});
}
if (noClasses.get() && myBC.getCompilerOptions().getFilesToIncludeInSWC().isEmpty() && !ApplicationManager.getApplication().isUnitTestMode()) {
throw new IOException(FlexCommonBundle.message("nothing.to.compile.in.library", myModule.getName(), myBC.getName()));
}
}
use of com.intellij.compiler.CompilerConfiguration in project intellij-plugins by JetBrains.
the class CompilerConfigGenerator method addFilesIncludedInSwc.
private void addFilesIncludedInSwc(final Element rootElement) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myModule.getProject()).getFileIndex();
final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(myModule.getProject());
final Map<String, String> filePathToPathInSwc = new THashMap<>();
for (String path : myBC.getCompilerOptions().getFilesToIncludeInSWC()) {
final VirtualFile fileOrDir = LocalFileSystem.getInstance().findFileByPath(path);
if (fileOrDir == null || compilerConfiguration.isExcludedFromCompilation(fileOrDir) || FileTypeManager.getInstance().isFileIgnored(fileOrDir)) {
continue;
}
if (fileOrDir.isDirectory()) {
final VirtualFile srcRoot = fileIndex.getModuleForFile(fileOrDir) == myModule ? fileIndex.getSourceRootForFile(fileOrDir) : null;
final String baseRelativePath = srcRoot == null ? fileOrDir.getName() : VfsUtilCore.getRelativePath(fileOrDir, srcRoot, '/');
assert baseRelativePath != null;
VfsUtilCore.visitChildrenRecursively(fileOrDir, new VirtualFileVisitor() {
@Override
public boolean visitFile(@NotNull final VirtualFile file) {
if (FileTypeManager.getInstance().isFileIgnored(file))
return false;
if (!file.isDirectory() && !FlexCommonUtils.isSourceFile(file.getName()) && !compilerConfiguration.isExcludedFromCompilation(file)) {
final String relativePath = VfsUtilCore.getRelativePath(file, fileOrDir, '/');
final String pathInSwc = baseRelativePath.isEmpty() ? relativePath : baseRelativePath + "/" + relativePath;
filePathToPathInSwc.put(file.getPath(), pathInSwc);
}
return true;
}
});
} else {
final VirtualFile srcRoot = fileIndex.getSourceRootForFile(fileOrDir);
final String relativePath = srcRoot == null ? null : VfsUtilCore.getRelativePath(fileOrDir, srcRoot, '/');
final String pathInSwc = StringUtil.notNullize(relativePath, fileOrDir.getName());
filePathToPathInSwc.put(fileOrDir.getPath(), pathInSwc);
}
}
for (Map.Entry<String, String> entry : filePathToPathInSwc.entrySet()) {
final String value = entry.getValue() + CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR + entry.getKey();
addOption(rootElement, CompilerOptionInfo.INCLUDE_FILE_INFO, value);
}
}
use of com.intellij.compiler.CompilerConfiguration in project intellij-community by JetBrains.
the class AbstractModuleDataService method setBytecodeTargetLevel.
private void setBytecodeTargetLevel(@NotNull Project project, @NotNull Module module, @NotNull E data) {
String targetLevel = data.getTargetCompatibility();
if (targetLevel != null) {
CompilerConfiguration configuration = CompilerConfiguration.getInstance(project);
configuration.setBytecodeTargetLevel(module, targetLevel);
}
}
use of com.intellij.compiler.CompilerConfiguration 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));
}
}
use of com.intellij.compiler.CompilerConfiguration in project intellij-community by JetBrains.
the class TypeCustomizerInspection method buildVisitor.
@NotNull
@Override
protected BaseInspectionVisitor buildVisitor() {
return new BaseInspectionVisitor() {
@Override
public void visitFile(@NotNull GroovyFileBase file) {
CompilerConfiguration configuration = CompilerConfiguration.getInstance(file.getProject());
if (configuration != null && !configuration.isResourceFile(file.getVirtualFile()) && fileSeemsToBeTypeCustomizer(file)) {
final LocalQuickFix[] fixes = { new AddToResourceFix(file) };
final String message = GroovyInspectionBundle.message("type.customizer.is.not.marked.as.a.resource.file");
registerError(file, message, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
};
}
Aggregations