Search in sources :

Example 1 with ConfigurationModule

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;
}
Also used : KnownTokenTypes(org.infernus.idea.checkstyle.csapi.KnownTokenTypes) HashMap(java.util.HashMap) ConfigurationModule(org.infernus.idea.checkstyle.csapi.ConfigurationModule) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with ConfigurationModule

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"));
}
Also used : ConfigurationLocationFactory(org.infernus.idea.checkstyle.model.ConfigurationLocationFactory) ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation) BundledConfigurationLocation(org.infernus.idea.checkstyle.model.BundledConfigurationLocation) TreeSet(java.util.TreeSet) BundledConfigurationLocation(org.infernus.idea.checkstyle.model.BundledConfigurationLocation) ConfigurationModule(org.infernus.idea.checkstyle.csapi.ConfigurationModule) Test(org.junit.Test)

Aggregations

ConfigurationModule (org.infernus.idea.checkstyle.csapi.ConfigurationModule)2 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 KnownTokenTypes (org.infernus.idea.checkstyle.csapi.KnownTokenTypes)1 BundledConfigurationLocation (org.infernus.idea.checkstyle.model.BundledConfigurationLocation)1 ConfigurationLocation (org.infernus.idea.checkstyle.model.ConfigurationLocation)1 ConfigurationLocationFactory (org.infernus.idea.checkstyle.model.ConfigurationLocationFactory)1 Nullable (org.jetbrains.annotations.Nullable)1 Test (org.junit.Test)1