use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project checkstyle-idea by jshiell.
the class CheckStyleConfigurableTest method buildMockPanel.
private CheckStyleConfigPanel buildMockPanel(final Project mockProject) {
CheckStyleConfigPanel mockPanel = mock(CheckStyleConfigPanel.class);
final SortedSet<ConfigurationLocation> mockLocations = buildMockLocations(mockProject, new ConfigurationLocationFactory());
final PluginConfiguration mockConfigDto = PluginConfigurationBuilder.testInstance("7.1.2").withLocations(mockLocations).withThirdPartyClassPath(Arrays.asList("cp1", "cp2")).withActiveLocation(mockLocations.first()).build();
when(mockPanel.getPluginConfiguration()).thenReturn(mockConfigDto);
return mockPanel;
}
use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project checkstyle-idea by jshiell.
the class CheckStyleConfigurableTest method buildMockLocations.
private static SortedSet<ConfigurationLocation> buildMockLocations(final Project mockProject, final ConfigurationLocationFactory mockLocFactory) {
ConfigurationLocation mockLocation1 = mockLocFactory.create(mockProject, ConfigurationType.PROJECT_RELATIVE, "src/test/resources/emptyFile1.xml", "description1");
ConfigurationLocation mockLocation2 = mockLocFactory.create(mockProject, ConfigurationType.PROJECT_RELATIVE, "src/test/resources/emptyFile2.xml", "description2");
SortedSet<ConfigurationLocation> result = new TreeSet<>();
result.add(mockLocation1);
result.add(mockLocation2);
return result;
}
use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project checkstyle-idea by jshiell.
the class CheckStyleInspection method inspectFile.
@Nullable
public List<Problem> inspectFile(@NotNull final PsiFile psiFile, @Nullable final Module module, @NotNull final InspectionManager manager) {
LOG.debug("Inspection has been invoked.");
final CheckStylePlugin plugin = plugin(manager.getProject());
ConfigurationLocation configurationLocation = null;
final List<ScannableFile> scannableFiles = new ArrayList<>();
try {
configurationLocation = plugin.getConfigurationLocation(module, null);
if (configurationLocation == null || configurationLocation.isBlacklisted()) {
return NO_PROBLEMS_FOUND;
}
scannableFiles.addAll(ScannableFile.createAndValidate(singletonList(psiFile), plugin, module));
return checkerFactory(psiFile.getProject()).checker(module, configurationLocation).map(checker -> checker.scan(scannableFiles, plugin.configurationManager().getCurrent().isSuppressErrors())).map(results -> results.get(psiFile)).map(this::dropIgnoredProblems).orElse(NO_PROBLEMS_FOUND);
} catch (ProcessCanceledException | AssertionError e) {
LOG.debug("Process cancelled when scanning: " + psiFile.getName());
return NO_PROBLEMS_FOUND;
} catch (CheckStylePluginParseException e) {
LOG.debug("Parse exception caught when scanning: " + psiFile.getName(), e);
return NO_PROBLEMS_FOUND;
} catch (Throwable e) {
handlePluginException(e, psiFile, plugin, configurationLocation, manager.getProject());
return NO_PROBLEMS_FOUND;
} finally {
scannableFiles.forEach(ScannableFile::deleteIfRequired);
}
}
use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project checkstyle-idea by jshiell.
the class PluginConfiguration method locationsAreEqual.
private boolean locationsAreEqual(final PluginConfiguration other) {
Iterator<ConfigurationLocation> locationIterator = locations.iterator();
Iterator<ConfigurationLocation> otherLocationIterator = other.locations.iterator();
while (locationIterator.hasNext() && otherLocationIterator.hasNext()) {
try {
if (locationIterator.next().hasChangedFrom(otherLocationIterator.next())) {
return false;
}
} catch (IOException e) {
throw new CheckStylePluginException("Unable to test configuration properties for changes", e);
}
}
return locations.size() == other.locations.size();
}
use of org.infernus.idea.checkstyle.model.ConfigurationLocation in project checkstyle-idea by jshiell.
the class OpCreateCheckerTest method testCreateCheckerWithConfigsMock.
@Test
public void testCreateCheckerWithConfigsMock() throws IOException, URISyntaxException {
final ConfigurationLocation configLoc = new StringConfigurationLocation(FileUtil.readFile("cmd/" + CONFIG_FILE), mock(Project.class));
final CheckStyleChecker checker = new CheckstyleActionsImpl(PROJECT, checkstyleProjectServiceMock).createChecker(moduleMock, configLoc, emptyMap(), configurationsMock, getClass().getClassLoader());
assertNotNull(checker);
}
Aggregations