Search in sources :

Example 1 with PerlFileType

use of com.perl5.lang.perl.fileTypes.PerlFileType 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)

Example 2 with PerlFileType

use of com.perl5.lang.perl.fileTypes.PerlFileType in project Perl5-IDEA by Camelcade.

the class PerlUseStrictInspection 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).checkStrictPragma()) {
                return;
            }
            for (PerlUseStatement useStatement : PsiTreeUtil.findChildrenOfType(file, PerlUseStatement.class)) {
                if (useStatement.getPackageProcessor() instanceof PerlStrictProvider) {
                    return;
                }
            }
            holder.registerProblem(file, PerlBundle.message("perl.inspection.use.strict"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new PerlUsePackageQuickFix("strict"));
        }
    };
}
Also used : InjectedFileViewProvider(com.intellij.psi.impl.source.tree.injected.InjectedFileViewProvider) PerlFileType(com.perl5.lang.perl.fileTypes.PerlFileType) PerlStrictProvider(com.perl5.lang.perl.extensions.packageprocessor.PerlStrictProvider) 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) PerlUseStatement(com.perl5.lang.perl.psi.PerlUseStatement) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with PerlFileType

use of com.perl5.lang.perl.fileTypes.PerlFileType in project Perl5-IDEA by Camelcade.

the class PerlInterpreterEditorNotification method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile virtualFile, @NotNull FileEditor fileEditor) {
    if (virtualFile.getFileType() instanceof PerlFileType && !(virtualFile instanceof LightVirtualFile)) {
        final PerlLocalSettings perlLocalSettings = PerlLocalSettings.getInstance(myProject);
        if (perlLocalSettings.DISABLE_NO_INTERPRETER_WARNING) {
            return null;
        }
        EditorNotificationPanel panel;
        String sdkPath = PerlProjectManager.getSdkPath(myProject, virtualFile);
        if (sdkPath != null && VfsUtil.findFileByIoFile(new File(sdkPath), true) != null) {
            return null;
        }
        panel = new EditorNotificationPanel();
        panel.setText(PerlBundle.message("perl.notification.sdk.not.configured"));
        panel.createActionLabel(PerlBundle.message("perl.notification.configure"), () -> Perl5SettingsConfigurable.open(myProject));
        panel.createActionLabel(PerlBundle.message("perl.notification.disable.notification"), () -> {
            perlLocalSettings.DISABLE_NO_INTERPRETER_WARNING = true;
            EditorNotifications.getInstance(myProject).updateAllNotifications();
        });
        return panel;
    }
    return null;
}
Also used : PerlFileType(com.perl5.lang.perl.fileTypes.PerlFileType) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PerlLocalSettings(com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

LightVirtualFile (com.intellij.testFramework.LightVirtualFile)3 PerlFileType (com.perl5.lang.perl.fileTypes.PerlFileType)3 FileType (com.intellij.openapi.fileTypes.FileType)2 PsiFile (com.intellij.psi.PsiFile)2 InjectedFileViewProvider (com.intellij.psi.impl.source.tree.injected.InjectedFileViewProvider)2 PerlUsePackageQuickFix (com.perl5.lang.perl.idea.quickfixes.PerlUsePackageQuickFix)2 PerlUseStatement (com.perl5.lang.perl.psi.PerlUseStatement)2 PerlVisitor (com.perl5.lang.perl.psi.PerlVisitor)2 NotNull (org.jetbrains.annotations.NotNull)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 EditorNotificationPanel (com.intellij.ui.EditorNotificationPanel)1 PerlStrictProvider (com.perl5.lang.perl.extensions.packageprocessor.PerlStrictProvider)1 PerlWarningsProvider (com.perl5.lang.perl.extensions.packageprocessor.PerlWarningsProvider)1 PerlLocalSettings (com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings)1 File (java.io.File)1 Nullable (org.jetbrains.annotations.Nullable)1