final boolean checkTestClasses = this.plugin.getConfiguration().isScanningTestClasses();
final boolean scanOnlyJavaFiles = !plugin.getConfiguration().isScanningNonJavaFiles();
try {
final AccessToken readAccessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
for (final PsiFile psiFile : psiFilesToScan) {
if (LOG.isDebugEnabled()) {
LOG.debug("Processing " + describe(psiFile));
}
if (psiFile == null || !psiFile.getVirtualFile().isValid() || !psiFile.isPhysical()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping as invalid type: " + describe(psiFile));
}
continue;
}
if (module == null) {
module = ModuleUtil.findModuleForPsiElement(psiFile);
} else {
final Module elementModule = ModuleUtil.findModuleForPsiElement(psiFile);
if (!elementModule.equals(module)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping as modules do not match: " + describe(psiFile)
+ " : " + elementModule + " does not match " + module);
}
continue;
}
}
if (!checkTestClasses && isTestClass(psiFile)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping test class " + psiFile.getName());
}
continue;
}
if (scanOnlyJavaFiles && !CheckStyleUtilities.isJavaFile(psiFile.getFileType())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping non-Java file " + psiFile.getName());
}
continue;
}
final ScannableFile tempFile = createTemporaryFile(psiFile, module);
if (tempFile != null) {
tempFiles.add(tempFile);
filesToElements.put(tempFile.getAbsolutePath(), psiFile);
}
}
} finally {
readAccessToken.finish();
}
if (module == null || filesToElements.isEmpty()) {
if (LOG.isDebugEnabled()) {
LOG.debug("No valid files were supplied");