Search in sources :

Example 16 with ConfigurationLocation

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

the class VersionMixExceptionTest method createChecker.

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

Example 17 with ConfigurationLocation

use of org.infernus.idea.checkstyle.model.ConfigurationLocation 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

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