use of com.puppycrawl.tools.checkstyle.api.MessageDispatcher in project checkstyle by checkstyle.
the class TranslationCheck method checkFilesForConsistencyRegardingTheirKeys.
/**
* Compares th the specified key set with the key sets of the given translation files (arranged
* in a map). All missing keys are reported.
* @param fileKeys a Map from translation files to their key sets.
* @param keysThatMustExist the set of keys to compare with.
*/
private void checkFilesForConsistencyRegardingTheirKeys(SetMultimap<File, String> fileKeys, Set<String> keysThatMustExist) {
for (File currentFile : fileKeys.keySet()) {
final MessageDispatcher dispatcher = getMessageDispatcher();
final String path = currentFile.getPath();
dispatcher.fireFileStarted(path);
final Set<String> currentFileKeys = fileKeys.get(currentFile);
final Set<String> missingKeys = keysThatMustExist.stream().filter(e -> !currentFileKeys.contains(e)).collect(Collectors.toSet());
if (!missingKeys.isEmpty()) {
for (Object key : missingKeys) {
log(0, MSG_KEY, key);
}
}
fireErrors(path);
dispatcher.fireFileFinished(path);
}
}
use of com.puppycrawl.tools.checkstyle.api.MessageDispatcher in project checkstyle by checkstyle.
the class TranslationCheck method logMissingTranslation.
/**
* Logs that translation file is missing.
*
* @param filePath file path.
* @param fileName file name.
*/
private void logMissingTranslation(String filePath, String fileName) {
final MessageDispatcher dispatcher = getMessageDispatcher();
dispatcher.fireFileStarted(filePath);
log(1, MSG_KEY_MISSING_TRANSLATION_FILE, fileName);
fireErrors(filePath);
dispatcher.fireFileFinished(filePath);
}
use of com.puppycrawl.tools.checkstyle.api.MessageDispatcher in project checkstyle by checkstyle.
the class TranslationCheck method checkFilesForConsistencyRegardingTheirKeys.
/**
* Compares th the specified key set with the key sets of the given translation files (arranged
* in a map). All missing keys are reported.
*
* @param fileKeys a Map from translation files to their key sets.
* @param keysThatMustExist the set of keys to compare with.
*/
private void checkFilesForConsistencyRegardingTheirKeys(Map<File, Set<String>> fileKeys, Set<String> keysThatMustExist) {
for (Entry<File, Set<String>> fileKey : fileKeys.entrySet()) {
final Set<String> currentFileKeys = fileKey.getValue();
final Set<String> missingKeys = keysThatMustExist.stream().filter(key -> !currentFileKeys.contains(key)).collect(Collectors.toSet());
if (!missingKeys.isEmpty()) {
final MessageDispatcher dispatcher = getMessageDispatcher();
final String path = fileKey.getKey().getAbsolutePath();
dispatcher.fireFileStarted(path);
for (Object key : missingKeys) {
log(1, MSG_KEY, key);
}
fireErrors(path);
dispatcher.fireFileFinished(path);
}
}
}
Aggregations