use of com.perl5.lang.perl.psi.PerlVisitor in project Perl5-IDEA by Camelcade.
the class PerlNamespaceRecursiveInheritanceInspection 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;
}
if (hasRecursiveInheritance(o, new THashSet<>())) {
registerError(holder, o.getContainingFile(), "Namespace " + packageName + " has recursive inheritance");
registerError(holder, nameIdentifier, "Namespace " + packageName + " has recursive inheritance");
}
}
};
}
use of com.perl5.lang.perl.psi.PerlVisitor 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.psi.PerlVisitor in project Perl5-IDEA by Camelcade.
the class PerlUnresolvedSubInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PerlVisitor() {
@Override
public void visitStringContentElement(@NotNull PerlStringContentElementImpl o) {
if (EXPORT_ASSIGNED_STRING_CONTENT.accepts(o)) {
if (!isResolvable(o.getReference())) {
registerProblem(holder, o, PerlBundle.message("perl.inspection.no.exported.entity"));
}
}
}
@Override
public void visitPerlMethod(@NotNull PerlMethod o) {
PerlNamespaceElement namespaceElement = o.getNamespaceElement();
PerlSubNameElement subNameElement = o.getSubNameElement();
// fixme adjust built in checking to the file; Remove second condition after implementing annotations
if (subNameElement == null || namespaceElement != null && namespaceElement.isBuiltin() || subNameElement.isBuiltIn()) {
return;
}
for (PsiReference reference : subNameElement.getReferences()) {
if (isResolvable(reference)) {
return;
}
}
registerProblem(holder, subNameElement, PerlBundle.message("perl.inspection.no.sub.definition"));
}
};
}
use of com.perl5.lang.perl.psi.PerlVisitor in project Perl5-IDEA by Camelcade.
the class PerlUseVarsInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
return new PerlVisitor() {
@Override
public void visitUseStatement(@NotNull PsiPerlUseStatement o) {
if (PACKAGE_VARS.equals(o.getPackageName())) {
PerlUseVarsQuickFix quickFix = new PerlUseVarsQuickFix(o);
holder.registerProblem(o, quickFix.isRemoval() ? PerlBundle.message("perl.redundant.code") : PerlBundle.message("perl.inspection.use.vars"), quickFix.isRemoval() ? ProblemHighlightType.LIKE_UNUSED_SYMBOL : ProblemHighlightType.GENERIC_ERROR_OR_WARNING, quickFix);
}
}
};
}
use of com.perl5.lang.perl.psi.PerlVisitor in project Perl5-IDEA by Camelcade.
the class PerlUnresolvedVariableInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PerlVisitor() {
@Override
public void visitPerlVariable(@NotNull final PerlVariable variable) {
PsiElement parent = variable.getParent();
if (parent instanceof PerlVariableDeclarationElement || variable.isBuiltIn()) {
return;
}
PerlVariableNameElement variableNameElement = variable.getVariableNameElement();
if (variableNameElement != null) {
for (PsiReference reference : variableNameElement.getReferences()) {
if (reference instanceof PsiPolyVariantReference && ((PsiPolyVariantReference) reference).multiResolve(false).length > 0 || reference.resolve() != null) {
return;
}
}
registerProblem(holder, variableNameElement, "Unable to find variable declaration.");
}
}
};
}
Aggregations