per-module encoding: take into account encoding specified for parent directory of a source root

This commit is contained in:
nik
2012-07-30 15:40:04 +04:00
parent 153f358239
commit 6a66fa31d7
@@ -18,7 +18,9 @@ package com.intellij.compiler.impl;
import com.intellij.compiler.CompilerEncodingService;
import com.intellij.openapi.compiler.CompilerManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
@@ -95,6 +97,20 @@ public class CompilerEncodingServiceImpl extends CompilerEncodingService {
}
set.add(charset);
}
//todo[nik,jeka] perhaps we should take into account encodings of source roots only not individual files
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
for (VirtualFile file : ModuleRootManager.getInstance(module).getSourceRoots(true)) {
Charset encoding = EncodingProjectManager.getInstance(myProject).getEncoding(file, true);
if (encoding != null) {
Set<Charset> charsets = map.get(module);
if (charsets == null) {
charsets = new LinkedHashSet<Charset>();
map.put(module, charsets);
}
charsets.add(encoding);
}
}
}
return map;
}