use of org.infernus.idea.checkstyle.csapi.CheckstyleInternalObject in project checkstyle-idea by jshiell.
the class CheckStyleCodeStyleImporter method importScheme.
@Nullable
@Override
public CodeStyleScheme importScheme(@NotNull final Project project, @NotNull final VirtualFile selectedFile, @NotNull final CodeStyleScheme currentScheme, @NotNull final SchemeFactory<CodeStyleScheme> schemeFactory) throws SchemeImportException {
try {
CodeStyleScheme targetScheme = currentScheme;
if (currentScheme.isDefault()) {
targetScheme = schemeFactory.createNewScheme(currentScheme.getName());
}
CheckstyleInternalObject configuration = loadConfiguration(project, selectedFile);
if (configuration != null) {
importConfiguration(checkstyleProjectService(project), configuration, targetScheme.getCodeStyleSettings());
return targetScheme;
}
} catch (Exception e) {
LOG.warn("Failed to import style", e);
throw new SchemeImportException(e);
}
return null;
}
use of org.infernus.idea.checkstyle.csapi.CheckstyleInternalObject in project checkstyle-idea by jshiell.
the class CheckStyleCodeStyleImporter method importScheme.
@Override
@Nullable
public CodeStyleScheme importScheme(@NotNull Project project, @NotNull VirtualFile selectedFile, @NotNull CodeStyleScheme currentScheme, @NotNull SchemeFactory<? extends CodeStyleScheme> schemeFactory) throws SchemeImportException {
try {
CodeStyleScheme targetScheme = currentScheme;
if (currentScheme.isDefault()) {
targetScheme = schemeFactory.createNewScheme(currentScheme.getName());
}
CheckstyleInternalObject configuration = loadConfiguration(project, selectedFile);
if (configuration != null) {
importConfiguration(checkstyleProjectService(project), configuration, targetScheme.getCodeStyleSettings());
return targetScheme;
}
} catch (Exception e) {
LOG.warn("Failed to import style", e);
throw new SchemeImportException(e);
}
return null;
}
use of org.infernus.idea.checkstyle.csapi.CheckstyleInternalObject in project checkstyle-idea by jshiell.
the class OpLoadConfigurationTest method testLoadBundledSunChecks.
@Test
public void testLoadBundledSunChecks() {
final ConfigurationLocationFactory clf = new ConfigurationLocationFactory();
CheckstyleProjectService projectService = mock(CheckstyleProjectService.class);
when(projectService.underlyingClassLoader()).thenReturn(getClass().getClassLoader());
CheckstyleInternalObject csConfig = new CheckstyleActionsImpl(PROJECT, projectService).loadConfiguration(clf.create(BundledConfig.SUN_CHECKS, mock(Project.class)), true, null);
Assert.assertNotNull(csConfig);
}
use of org.infernus.idea.checkstyle.csapi.CheckstyleInternalObject in project checkstyle-idea by jshiell.
the class OpLoadConfigurationTest method testLoadFromString.
@Test
public void testLoadFromString() throws IOException, URISyntaxException {
CheckstyleProjectService projectService = mock(CheckstyleProjectService.class);
when(projectService.underlyingClassLoader()).thenReturn(getClass().getClassLoader());
final String configXml = FileUtil.readFile("cmd/config-ok.xml");
CheckstyleInternalObject csConfig = new CheckstyleActionsImpl(PROJECT, projectService).loadConfiguration(configXml);
Assert.assertNotNull(csConfig);
}
use of org.infernus.idea.checkstyle.csapi.CheckstyleInternalObject in project checkstyle-idea by jshiell.
the class OpLoadConfigurationTest method testLoadBundledGoogleChecks.
@Test
public void testLoadBundledGoogleChecks() {
final ConfigurationLocationFactory clf = new ConfigurationLocationFactory();
CheckstyleProjectService projectService = mock(CheckstyleProjectService.class);
when(projectService.underlyingClassLoader()).thenReturn(getClass().getClassLoader());
CheckstyleInternalObject csConfig = new CheckstyleActionsImpl(PROJECT, projectService).loadConfiguration(clf.create(BundledConfig.GOOGLE_CHECKS, mock(Project.class)), true, null);
Assert.assertNotNull(csConfig);
}
Aggregations