use of com.perl5.lang.pod.parser.psi.PodFormatterL in project Perl5-IDEA by Camelcade.
the class PodLinkToFileReference method resolveInner.
@NotNull
@Override
protected ResolveResult[] resolveInner(boolean incompleteCode) {
PodFormatterL podLink = getElement();
PodLinkDescriptor descriptor = podLink.getLinkDescriptor();
if (descriptor != null && !descriptor.isUrl() && descriptor.getFileId() != null) {
PsiFile targetFile = PodFileUtil.getPodOrPackagePsiByDescriptor(podLink.getProject(), descriptor);
if (targetFile != null) {
return new ResolveResult[] { new PsiElementResolveResult(targetFile) };
}
}
return ResolveResult.EMPTY_ARRAY;
}
use of com.perl5.lang.pod.parser.psi.PodFormatterL in project Perl5-IDEA by Camelcade.
the class PodLegacySectionLinkInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PodVisitor() {
@Override
public void visitPodFormatterL(@NotNull PodFormatterL o) {
PodLinkDescriptor descriptor = o.getLinkDescriptor();
if (descriptor != null && !descriptor.isUrl() && descriptor.getSection() != null) {
PsiElement contentBlock = o.getContentBlock();
TextRange sectionRange = descriptor.getSectionTextRangeInLink();
if (contentBlock != null && sectionRange != null) {
if (isSectionLegacy(contentBlock.getText(), sectionRange)) {
holder.registerProblem(o, "Section \"" + descriptor.getSection() + "\" should have a slash before it", ProblemHighlightType.LIKE_DEPRECATED, sectionRange.shiftRight(contentBlock.getStartOffsetInParent()));
}
}
}
super.visitPodFormatterL(o);
}
private boolean isSectionLegacy(String text, TextRange sectionRange) {
if (text == null) {
return false;
}
int sectionStartOffset = sectionRange.getStartOffset();
if (sectionStartOffset == 0) {
return true;
}
char prevChar = text.charAt(sectionStartOffset - 1);
if (sectionStartOffset == 1) {
return prevChar != '/';
}
char prevPrevChar = text.charAt(sectionStartOffset - 2);
return !(prevChar == '/' || prevChar == '"' && prevPrevChar == '/');
}
};
}
Aggregations