Search in sources :

Example 1 with CheckstyleActions

use of org.infernus.idea.checkstyle.csapi.CheckstyleActions in project checkstyle-idea by jshiell.

the class CheckstylePluginApi method visitCurrentConfiguration.

public void visitCurrentConfiguration(@NotNull final ConfigurationVisitor visitor) {
    ConfigurationLocation activeLocation = pluginConfigurationManager().getCurrent().getActiveLocation();
    if (activeLocation != null) {
        CheckstyleActions checkstyleInstance = checkstyleProjectService().getCheckstyleInstance();
        checkstyleInstance.peruseConfiguration(checkstyleInstance.loadConfiguration(activeLocation, true, new HashMap<>()), module -> visitor.accept(activeLocation.getDescription(), module));
    }
}
Also used : CheckstyleActions(org.infernus.idea.checkstyle.csapi.CheckstyleActions) HashMap(java.util.HashMap) ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation)

Example 2 with CheckstyleActions

use of org.infernus.idea.checkstyle.csapi.CheckstyleActions in project checkstyle-idea by jshiell.

the class ServiceLayerBasicTest method createChecker.

private CheckStyleChecker createChecker(@NotNull final String configXmlFile) throws IOException, URISyntaxException {
    final ConfigurationLocation configLoc = new StringConfigurationLocation(FileUtil.readFile(configXmlFile), mock(Project.class));
    final Module module = mock(Module.class);
    when(module.getProject()).thenReturn(PROJECT);
    final TabWidthAndBaseDirProvider configurations = mock(TabWidthAndBaseDirProvider.class);
    when(configurations.tabWidth()).thenReturn(2);
    when(configurations.baseDir()).thenReturn(Optional.of(new File(getClass().getResource(configXmlFile).toURI()).getParent()));
    final CheckstyleActions csInstance = checkstyleProjectService.getCheckstyleInstance();
    return csInstance.createChecker(module, configLoc, Collections.emptyMap(), configurations, getClass().getClassLoader());
}
Also used : CheckstyleActions(org.infernus.idea.checkstyle.csapi.CheckstyleActions) Project(com.intellij.openapi.project.Project) ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation) TabWidthAndBaseDirProvider(org.infernus.idea.checkstyle.csapi.TabWidthAndBaseDirProvider) Module(com.intellij.openapi.module.Module) File(java.io.File)

Example 3 with CheckstyleActions

use of org.infernus.idea.checkstyle.csapi.CheckstyleActions in project checkstyle-idea by jshiell.

the class VersionMixExceptionTest method runChecker.

private void runChecker(@NotNull final CheckStyleChecker checker) throws URISyntaxException {
    final File sourceFile = new File(getClass().getResource("SourceFile.java").toURI());
    final ScannableFile file1 = mock(ScannableFile.class);
    when(file1.getFile()).thenReturn(sourceFile);
    final List<ScannableFile> filesToScan = Collections.singletonList(file1);
    final CheckstyleActions csInstance = csService.getCheckstyleInstance();
    // 
    csInstance.scan(// 
    checker.getCheckerWithConfig4UnitTest(), // 
    filesToScan, // 
    false, // 
    2, Optional.of(sourceFile.getParent()));
}
Also used : CheckstyleActions(org.infernus.idea.checkstyle.csapi.CheckstyleActions) ScannableFile(org.infernus.idea.checkstyle.checker.ScannableFile) ScannableFile(org.infernus.idea.checkstyle.checker.ScannableFile) File(java.io.File)

Example 4 with CheckstyleActions

use of org.infernus.idea.checkstyle.csapi.CheckstyleActions in project checkstyle-idea by jshiell.

the class ServiceLayerBasicTest method runChecker.

private void runChecker(@NotNull final CheckStyleChecker checker) throws URISyntaxException {
    final File sourceFile = new File(getClass().getResource("SourceFile.java").toURI());
    final ScannableFile file1 = mock(ScannableFile.class);
    when(file1.getFile()).thenReturn(sourceFile);
    final List<ScannableFile> filesToScan = Collections.singletonList(file1);
    final CheckstyleActions csInstance = checkstyleProjectService.getCheckstyleInstance();
    // 
    csInstance.scan(// 
    checker.getCheckerWithConfig4UnitTest(), // 
    filesToScan, // 
    false, // 
    2, Optional.of(sourceFile.getParent()));
}
Also used : CheckstyleActions(org.infernus.idea.checkstyle.csapi.CheckstyleActions) ScannableFile(org.infernus.idea.checkstyle.checker.ScannableFile) ScannableFile(org.infernus.idea.checkstyle.checker.ScannableFile) File(java.io.File)

Aggregations

CheckstyleActions (org.infernus.idea.checkstyle.csapi.CheckstyleActions)4 File (java.io.File)3 ScannableFile (org.infernus.idea.checkstyle.checker.ScannableFile)2 ConfigurationLocation (org.infernus.idea.checkstyle.model.ConfigurationLocation)2 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 HashMap (java.util.HashMap)1 TabWidthAndBaseDirProvider (org.infernus.idea.checkstyle.csapi.TabWidthAndBaseDirProvider)1