use of com.perl5.lang.pod.psi.PsiLinkName in project Perl5-IDEA by Camelcade.
the class PodFormatterL method computeReferences.
@Override
public PsiReference[] computeReferences() {
List<PsiReference> references = new ArrayList<>();
final PodLinkDescriptor descriptor = getLinkDescriptor();
if (descriptor != null && !descriptor.isUrl()) {
int linkStartOffset = getTextRange().getStartOffset();
PsiLinkName linkNameElement = getLinkNameElement();
if (linkNameElement != null) {
references.add(new PodLinkToFileReference(this, linkNameElement.getTextRange().shiftLeft(linkStartOffset)));
}
PsiLinkSection linkSectionElement = getLinkSectionElement();
if (linkSectionElement != null) {
references.add(new PodLinkToSectionReference(this, linkSectionElement.getTextRange().shiftLeft(linkStartOffset)));
}
}
references.addAll(Arrays.asList(ReferenceProvidersRegistry.getReferencesFromProviders(this)));
return references.toArray(PsiReference.EMPTY_ARRAY);
}
use of com.perl5.lang.pod.psi.PsiLinkName in project Perl5-IDEA by Camelcade.
the class PodLinkDescriptor method create.
@Nullable
public static PodLinkDescriptor create(@NotNull PodFormatterL formatterL) {
PsiLinkText textElement = formatterL.getLinkTextElement();
PsiLinkName nameElement = formatterL.getLinkNameElement();
PsiLinkSection sectionElement = formatterL.getLinkSectionElement();
PsiLinkUrl linkUrlElement = formatterL.getLinkUrlElement();
if (nameElement == null && sectionElement == null && linkUrlElement == null) {
return null;
}
String linkTextText = null;
String linkTextHtml = null;
String linkName = null;
String linkSection = null;
boolean isUrl = false;
boolean isSameFile = false;
if (textElement != null) {
linkTextHtml = PodRenderUtil.renderPsiElementAsHTML(textElement);
linkTextText = PodRenderUtil.renderPsiElementAsText(textElement);
}
if (linkUrlElement != null) {
isUrl = true;
linkName = linkUrlElement.getText();
if (linkTextText == null) {
linkTextText = linkTextHtml = linkName;
}
} else if (sectionElement != null) {
linkSection = PodRenderUtil.renderPsiElementAsText(sectionElement);
if (linkTextText == null) {
linkTextHtml = PodRenderUtil.renderPsiElementAsHTML(sectionElement);
linkTextText = linkSection;
if (nameElement != null) {
linkName = nameElement.getText();
linkTextHtml = buildTitle(linkName, linkTextHtml, false);
linkTextText = buildTitle(linkName, linkTextText, false);
}
}
}
if (linkName == null) {
if (nameElement != null) {
linkName = nameElement.getText();
} else {
PsiFile containingFile = formatterL.getContainingFile();
if (containingFile instanceof PodLinkTarget) {
linkName = ((PodLinkTarget) containingFile).getPodLink();
isSameFile = true;
}
}
}
return new PodLinkDescriptor(linkName, linkSection, linkTextText, linkTextHtml, isUrl, isSameFile);
}
Aggregations