use of com.perl5.lang.perl.psi.PerlVisitor 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.psi.PerlVisitor in project Perl5-IDEA by Camelcade.
the class PerlRedundantNamespaceInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PerlVisitor() {
@Override
public void visitMethod(@NotNull PsiPerlMethod o) {
PerlNamespaceElement namespaceElement = o.getNamespaceElement();
if (namespaceElement != null) {
String packageName = namespaceElement.getCanonicalName();
if (StringUtil.isNotEmpty(packageName)) {
String contextPackageName = PerlPackageUtil.getContextPackageName(o);
if (StringUtil.equals(packageName, contextPackageName)) {
if (!namespaceElement.getTextRange().isEmpty()) {
holder.registerProblem(namespaceElement, "Redundant namespace qualifier", ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
}
}
super.visitMethod(o);
}
};
}
use of com.perl5.lang.perl.psi.PerlVisitor in project Perl5-IDEA by Camelcade.
the class PerlClashedNamespacesInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PerlVisitor() {
@Override
public void visitPerlNamespaceDefinitionWithIdentifier(@NotNull PerlNamespaceDefinitionWithIdentifier o) {
PsiElement nameIdentifier = o.getNameIdentifier();
if (nameIdentifier == null) {
return;
}
String packageName = o.getPackageName();
if (PerlPackageUtil.MAIN_PACKAGE.equals(packageName)) {
return;
}
// fixme we should check that this is not in SDK
if (PerlPackageUtil.isBuiltIn(packageName)) {
registerProblem(holder, nameIdentifier, "Namespace definition clashes with built-in namespace");
}
}
};
}
Aggregations