use of org.infernus.idea.checkstyle.exception.CheckStylePluginParseException 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.exception.CheckStylePluginParseException 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.exception.CheckStylePluginParseException in project checkstyle-idea by jshiell.
the class CheckStyleToolWindowPanel method displayErrorResult.
/**
* Clear the results and display notice to say an error occurred.
*
* @param error the error that occurred.
*/
public void displayErrorResult(final Throwable error) {
// match some friendly error messages.
String errorText = null;
if (error instanceof CheckstyleToolException && error.getCause() != null) {
for (final Map.Entry<Pattern, String> errorPatternEntry : CHECKSTYLE_ERROR_PATTERNS.entrySet()) {
final Matcher errorMatcher = errorPatternEntry.getKey().matcher(error.getCause().getMessage());
if (errorMatcher.find()) {
final Object[] args = new Object[errorMatcher.groupCount()];
for (int i = 0; i < errorMatcher.groupCount(); ++i) {
args[i] = errorMatcher.group(i + 1);
}
errorText = message(errorPatternEntry.getValue(), args);
}
}
}
if (errorText == null) {
if (error instanceof CheckStylePluginParseException) {
errorText = message("plugin.results.unparseable");
} else {
errorText = message("plugin.results.error");
}
}
treeModel.clear();
treeModel.setRootText(errorText);
clearProgress();
}
Aggregations