Search in sources :

Example 1 with PerlWarningsProvider

use of com.perl5.lang.perl.extensions.packageprocessor.PerlWarningsProvider in project Perl5-IDEA by Camelcade.

the class PerlUseWarningsInspection method buildVisitor.

@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    return new PerlVisitor() {

        @Override
        public void visitFile(PsiFile file) {
            if (file.getViewProvider() instanceof InjectedFileViewProvider || !file.isWritable() || !file.isPhysical() || file.getVirtualFile() instanceof LightVirtualFile) {
                return;
            }
            FileType fileType = file.getFileType();
            if (!(fileType instanceof PerlFileType) || !((PerlFileType) fileType).checkWarningsPragma()) {
                return;
            }
            for (PerlUseStatement useStatement : PsiTreeUtil.findChildrenOfType(file, PerlUseStatement.class)) {
                if (useStatement.getPackageProcessor() instanceof PerlWarningsProvider) {
                    return;
                }
            }
            holder.registerProblem(file, PerlBundle.message("perl.inspection.use.warnings"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new PerlUsePackageQuickFix("warnings FATAL => 'all'"), new PerlUsePackageQuickFix("warnings"));
        }
    };
}
Also used : InjectedFileViewProvider(com.intellij.psi.impl.source.tree.injected.InjectedFileViewProvider) PerlFileType(com.perl5.lang.perl.fileTypes.PerlFileType) PerlUsePackageQuickFix(com.perl5.lang.perl.idea.quickfixes.PerlUsePackageQuickFix) FileType(com.intellij.openapi.fileTypes.FileType) PerlFileType(com.perl5.lang.perl.fileTypes.PerlFileType) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PsiFile(com.intellij.psi.PsiFile) PerlVisitor(com.perl5.lang.perl.psi.PerlVisitor) PerlWarningsProvider(com.perl5.lang.perl.extensions.packageprocessor.PerlWarningsProvider) PerlUseStatement(com.perl5.lang.perl.psi.PerlUseStatement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FileType (com.intellij.openapi.fileTypes.FileType)1 PsiFile (com.intellij.psi.PsiFile)1 InjectedFileViewProvider (com.intellij.psi.impl.source.tree.injected.InjectedFileViewProvider)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 PerlWarningsProvider (com.perl5.lang.perl.extensions.packageprocessor.PerlWarningsProvider)1 PerlFileType (com.perl5.lang.perl.fileTypes.PerlFileType)1 PerlUsePackageQuickFix (com.perl5.lang.perl.idea.quickfixes.PerlUsePackageQuickFix)1 PerlUseStatement (com.perl5.lang.perl.psi.PerlUseStatement)1 PerlVisitor (com.perl5.lang.perl.psi.PerlVisitor)1 NotNull (org.jetbrains.annotations.NotNull)1