use of org.infernus.idea.checkstyle.checker.Problem 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.checker.Problem in project checkstyle-idea by jshiell.
the class CheckStyleInspection method inspectFile.
private List<Problem> inspectFile(@NotNull final PsiFile psiFile, @NotNull final List<ScannableFile> scannableFiles, @Nullable final Module module, @NotNull final InspectionManager manager) {
LOG.debug("Inspection has been invoked for " + psiFile.getName());
ConfigurationLocation configurationLocation = null;
try {
configurationLocation = configurationLocationSource(manager.getProject()).getConfigurationLocation(module, null);
if (configurationLocation == null || configurationLocation.isBlocked()) {
return NO_PROBLEMS_FOUND;
}
return checkerFactory(psiFile.getProject()).checker(module, configurationLocation).map(checker -> checker.scan(scannableFiles, configurationManager(psiFile.getProject()).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, configurationLocation, manager.getProject());
return NO_PROBLEMS_FOUND;
} finally {
scannableFiles.forEach(ScannableFile::deleteIfRequired);
}
}
use of org.infernus.idea.checkstyle.checker.Problem in project checkstyle-idea by jshiell.
the class ResultTreeModel method setModel.
/**
* Set the displayed model.
*
* @param results the model.
* @param levels the levels to display.
*/
public void setModel(final Map<PsiFile, List<Problem>> results, final SeverityLevel... levels) {
visibleRootNode.removeAllChildren();
int itemCount = 0;
for (final PsiFile file : sortedFileNames(results)) {
final TogglableTreeNode fileNode = new TogglableTreeNode();
final List<Problem> problems = results.get(file);
int problemCount = 0;
if (problems != null) {
for (final Problem problem : problems) {
if (problem.severityLevel() != SeverityLevel.Ignore) {
final ResultTreeNode problemObj = new ResultTreeNode(file, problem);
final TogglableTreeNode problemNode = new TogglableTreeNode(problemObj);
fileNode.add(problemNode);
++problemCount;
}
}
}
itemCount += problemCount;
if (problemCount > 0) {
final ResultTreeNode nodeObject = new ResultTreeNode(file.getName(), problemCount);
fileNode.setUserObject(nodeObject);
visibleRootNode.add(fileNode);
}
}
if (itemCount == 0) {
setRootMessage("plugin.results.scan-no-results");
} else {
setRootText(CheckStyleBundle.message("plugin.results.scan-results", itemCount, results.size()));
}
filter(false, levels);
nodeStructureChanged(visibleRootNode);
}
Aggregations