Search in sources :

Example 11 with ConfigurationLocation

use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project checkstyle-idea by jshiell.

the class CheckStyleConfigurableTest method mockPluginConfigurationManager.

private PluginConfigurationManager mockPluginConfigurationManager(@NotNull final Project project) {
    final ConfigurationLocationFactory mockLocFactory = new ConfigurationLocationFactory();
    final SortedSet<ConfigurationLocation> mockLocations = buildMockLocations(project, mockLocFactory);
    final PluginConfiguration mockConfigDto = PluginConfigurationBuilder.testInstance("7.1.2").withLocations(mockLocations).withThirdPartyClassPath(Arrays.asList("cp1", "cp2")).withActiveLocation(mockLocations.first()).build();
    PluginConfigurationManager mockConfig = mock(PluginConfigurationManager.class);
    when(mockConfig.getCurrent()).thenReturn(mockConfigDto);
    return mockConfig;
}
Also used : ConfigurationLocationFactory(org.infernus.idea.checkstyle.model.ConfigurationLocationFactory) ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation) PluginConfigurationManager(org.infernus.idea.checkstyle.config.PluginConfigurationManager) PluginConfiguration(org.infernus.idea.checkstyle.config.PluginConfiguration)

Example 12 with ConfigurationLocation

use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project watchdog by TestRoots.

the class CheckStyleStartup method addMessagesForActiveConfiguration.

// TODO (TimvdLippe): update the messages when the configuration changes
private void addMessagesForActiveConfiguration(CheckstyleProjectService service) {
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    final ConfigurationLocation activeConfigLocation = checkStylePlugin.configurationManager().getCurrent().getActiveLocation();
    if (activeConfigLocation == null) {
        return;
    }
    service.getCheckstyleInstance().peruseConfiguration(service.getCheckstyleInstance().loadConfiguration(activeConfigLocation, true, new HashMap<>()), module -> addMessagesForActiveConfiguration(activeConfigLocation.getDescription(), module));
}
Also used : HashMap(java.util.HashMap) ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation) CheckStylePlugin(org.infernus.idea.checkstyle.CheckStylePlugin)

Example 13 with ConfigurationLocation

use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project checkstyle-idea by jshiell.

the class PluginConfigurationBuilder method defaultConfiguration.

public static PluginConfigurationBuilder defaultConfiguration(final Project project) {
    final String csDefaultVersion = new VersionListReader().getDefaultVersion();
    final SortedSet<ConfigurationLocation> defaultLocations = new TreeSet<>();
    defaultLocations.add(configurationLocationFactory(project).create(BundledConfig.SUN_CHECKS, project));
    defaultLocations.add(configurationLocationFactory(project).create(BundledConfig.GOOGLE_CHECKS, project));
    final boolean copyLibs = OS.isWindows();
    return new PluginConfigurationBuilder(csDefaultVersion, ScanScope.getDefaultValue(), false, copyLibs, defaultLocations, Collections.emptyList(), null, false, CheckStylePlugin.version());
}
Also used : ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation) TreeSet(java.util.TreeSet) VersionListReader(org.infernus.idea.checkstyle.VersionListReader)

Example 14 with ConfigurationLocation

use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project checkstyle-idea by jshiell.

the class ProjectConfigurationState method ensureBundledConfigs.

private void ensureBundledConfigs(@NotNull final List<ConfigurationLocation> configurationLocations) {
    final ConfigurationLocation sunChecks = configurationLocationFactory().create(BundledConfig.SUN_CHECKS, project);
    final ConfigurationLocation googleChecks = configurationLocationFactory().create(BundledConfig.GOOGLE_CHECKS, project);
    if (!configurationLocations.contains(sunChecks)) {
        configurationLocations.add(sunChecks);
    }
    if (!configurationLocations.contains(googleChecks)) {
        configurationLocations.add(googleChecks);
    }
}
Also used : ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation)

Example 15 with ConfigurationLocation

use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project checkstyle-idea by jshiell.

the class ConfigurationsTest method createClassUnderTest.

private TabWidthAndBaseDirProvider createClassUnderTest(final Configuration pConfig) throws IOException {
    final Module module = mock(Module.class);
    final ConfigurationLocation configurationLocation = mock(ConfigurationLocation.class);
    final CodeStyleSettings codeStyleSettings = mock(CodeStyleSettings.class);
    when(configurationLocation.resolveAssociatedFile(eq("aFileToResolve"), eq(module), any(ClassLoader.class))).thenReturn("aResolvedFile");
    when(configurationLocation.resolveAssociatedFile(eq("triggersAnIoException"), eq(module), any(ClassLoader.class))).thenThrow(new IOException("aTriggeredIoException"));
    when(codeStyleSettings.getTabSize(JavaFileType.INSTANCE)).thenReturn(CODE_STYLE_TAB_SIZE);
    return new Configurations(module, pConfig) {

        @NotNull
        @Override
        CodeStyleSettings currentCodeStyleSettings() {
            return codeStyleSettings;
        }
    };
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation) IOException(java.io.IOException) Module(com.intellij.openapi.module.Module)

Aggregations

ConfigurationLocation (org.infernus.idea.checkstyle.model.ConfigurationLocation)17 Project (com.intellij.openapi.project.Project)6 Module (com.intellij.openapi.module.Module)4 IOException (java.io.IOException)4 TreeSet (java.util.TreeSet)4 ScannableFile (org.infernus.idea.checkstyle.checker.ScannableFile)3 Nullable (org.jetbrains.annotations.Nullable)3 Test (org.junit.Test)3 InspectionManager (com.intellij.codeInspection.InspectionManager)2 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)2 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)2 ServiceManager (com.intellij.openapi.components.ServiceManager)2 Logger (com.intellij.openapi.diagnostic.Logger)2 ModuleUtil (com.intellij.openapi.module.ModuleUtil)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 PsiFile (com.intellij.psi.PsiFile)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 Collections (java.util.Collections)2 Collections.singletonList (java.util.Collections.singletonList)2