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