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