use of com.perl5.lang.pod.parser.psi.PodLinkDescriptor in project Perl5-IDEA by Camelcade.
the class PodUnresolvableLinkInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PodVisitor() {
@Override
public void visitPodFormatLink(@NotNull PsiPodFormatLink o) {
for (PsiReference reference : o.getReferences()) {
if (reference instanceof PsiPolyVariantReference && ((PsiPolyVariantReference) reference).multiResolve(false).length == 0) {
String error;
if (reference instanceof PodLinkToFileReference) {
String fileName = "UNKNONW";
PodLinkDescriptor descriptor = o.getLinkDescriptor();
if (descriptor != null && descriptor.getFileId() != null) {
fileName = descriptor.getFileId();
}
error = "Can't find POD or PM file by: " + fileName;
} else if (reference instanceof PodLinkToSectionReference) {
String fileName = "UNKNONW";
PodLinkDescriptor descriptor = o.getLinkDescriptor();
if (descriptor != null && descriptor.getSection() != null) {
fileName = descriptor.getSection();
}
error = "Can't find POD section: " + fileName;
} else {
error = "Can't find reference target";
}
holder.registerProblem(reference, error, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
super.visitPodFormatLink(o);
}
};
}
Aggregations