use of com.intellij.openapi.vfs.encoding.EncodingProjectManager in project intellij-community by JetBrains.
the class EncodingManager method applySettings.
private void applySettings(VirtualFile file) {
if (file == null)
return;
if (!Utils.isEnabled(CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings()))
return;
// Prevent "setEncoding" calling "saveAll" from causing an endless loop
isApplyingSettings = true;
try {
final String filePath = Utils.getFilePath(myProject, file);
final List<OutPair> outPairs = SettingsProviderComponent.getInstance().getOutPairs(myProject, filePath);
final EncodingProjectManager encodingProjectManager = EncodingProjectManager.getInstance(myProject);
final String charset = Utils.configValueForKey(outPairs, charsetKey);
if (!charset.isEmpty()) {
final Charset newCharset = encodingMap.get(charset);
if (newCharset != null) {
if (Comparing.equal(newCharset, file.getCharset()))
return;
encodingProjectManager.setEncoding(file, newCharset);
} else {
Utils.invalidConfigMessage(myProject, charset, charsetKey, filePath);
}
}
} finally {
isApplyingSettings = false;
}
}
Aggregations