use of org.infernus.idea.checkstyle.csapi.ConfigurationModule in project checkstyle-idea by jshiell.
the class OpPeruseConfiguration method buildModuleInfo.
@Nullable
private ConfigurationModule buildModuleInfo(@NotNull final Configuration currentConfig) throws CheckstyleException {
final String name = currentConfig.getName();
final Map<String, String> messages = messagesFrom(currentConfig);
final Map<String, String> properties = new HashMap<>();
Set<KnownTokenTypes> knownTokenTypes = EnumSet.noneOf(KnownTokenTypes.class);
for (String key : currentConfig.getAttributeNames()) {
if (key != null) {
String value = currentConfig.getAttribute(key);
if (value != null) {
if (TOKENS_PROP.equals(key)) {
knownTokenTypes = buildKnownTokenTypesSet(value);
} else {
properties.put(key, value);
}
}
}
}
ConfigurationModule result = null;
if (name != null) {
result = new ConfigurationModule(name, properties, knownTokenTypes, messages);
}
return result;
}
use of org.infernus.idea.checkstyle.csapi.ConfigurationModule in project checkstyle-idea by jshiell.
the class CheckstylePluginApiTest method currentConfigurationCanBeVisited.
@Test
public void currentConfigurationCanBeVisited() {
BundledConfigurationLocation googleChecks = new ConfigurationLocationFactory().create(GOOGLE_CHECKS, project);
TreeSet<ConfigurationLocation> locations = new TreeSet<>();
locations.add(googleChecks);
when(pluginConfigManager.getCurrent()).thenReturn(PluginConfigurationBuilder.testInstance(CHECKSTYLE_VERSION).withLocations(locations).withActiveLocation(googleChecks).build());
CheckstylePluginApi.ConfigurationVisitor visitor = mock(CheckstylePluginApi.ConfigurationVisitor.class);
underTest.visitCurrentConfiguration(visitor);
ArgumentCaptor<ConfigurationModule> configModuleCaptor = ArgumentCaptor.forClass(ConfigurationModule.class);
verify(visitor, times(58)).accept(eq("Google Checks"), configModuleCaptor.capture());
assertThat(configModuleCaptor.getValue(), is(not(nullValue())));
assertThat(configModuleCaptor.getValue().getName(), is("CommentsIndentation"));
}
Aggregations