Package org.infernus.idea.checkstyle.util

Examples of org.infernus.idea.checkstyle.util.ScannableFile


    private ProblemDescriptor[] scanFile(final PsiFile psiFile,
                                         final InspectionManager manager,
                                         final CheckStylePlugin checkStylePlugin,
                                         final Module module)
            throws IOException {
        ScannableFile scannableFile = null;
        try {
            final CheckerContainer checkerContainer = getChecker(checkStylePlugin, module);
            final Configuration config = getConfig(checkStylePlugin, module);
            if (checkerContainer == null || config == null) {
                return new ProblemDescriptor[0];
            }

            final List<Check> checks = CheckFactory.getChecks(config);

            final Document fileDocument = PsiDocumentManager.getInstance(
                    manager.getProject()).getDocument(psiFile);
            if (fileDocument == null) {
                LOG.debug("Skipping check - file is binary or has no document: " + psiFile.getName());
                return null;
            }

            scannableFile = new ScannableFile(psiFile, module);

            final Map<String, PsiFile> filesToScan = Collections.singletonMap(scannableFile.getAbsolutePath(), psiFile);

            final boolean suppressingErrors = checkStylePlugin.getConfiguration().isSuppressingErrors();
            final CheckStyleAuditListener listener = new CheckStyleAuditListener(
                    filesToScan, manager, false, suppressingErrors, checkerContainer.getTabWidth(), checks);
            final Checker checker = checkerContainer.getChecker();
            synchronized (checker) {
                checker.addListener(listener);
                checker.process(Arrays.asList(scannableFile.getFile()));
                checker.removeListener(listener);
            }

            final List<ProblemDescriptor> problems = listener.getProblems(psiFile);
            return problems.toArray(new ProblemDescriptor[problems.size()]);

        } finally {
            if (scannableFile != null) {
                scannableFile.deleteIfRequired();
            }
        }
    }
View Full Code Here


        return file;
    }

    public void run() {
        try {
            file = new ScannableFile(psiFile, module);

        } catch (IOException e) {
            failure = e;
        }
    }
View Full Code Here

                            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");
                }
                return null;
            }

            return performCheckStyleScan(module, tempFiles, filesToElements, override);

        } finally {
            for (final ScannableFile tempFile : tempFiles) {
                if (tempFile != null) {
                    tempFile.deleteIfRequired();
                }
            }
        }
    }
View Full Code Here

        }
        return listOfFiles;
    }

    private ScannableFile createTemporaryFile(final PsiFile psiFile, final Module module) {
        ScannableFile tempFile = null;
        try {
            // we need to copy to a file as IntelliJ may not have
            // saved the file recently...
            final CreateScannableFileAction fileAction
                    = new CreateScannableFileAction(psiFile, module);
View Full Code Here

TOP

Related Classes of org.infernus.idea.checkstyle.util.ScannableFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.