private static int findReplacementOffset(int selectionEndOffset, PsiReference reference) { final List<TextRange> ranges = ReferenceRange.getAbsoluteRanges(reference); for (TextRange range : ranges) { if (range.contains(selectionEndOffset)) { return range.getEndOffset(); } } return reference.getElement().getTextRange().getStartOffset() + reference.getRangeInElement().getEndOffset(); }
private static void addReferences( int offset, PsiElement element, final Collection<PsiReference> outReferences) { for (final PsiReference reference : element.getReferences()) { if (reference == null) { LOG.error(element); } for (TextRange range : ReferenceRange.getRanges(reference)) { assert range != null : reference; if (range.containsOffset(offset)) { outReferences.add(reference); } } } }
public InfoMultiple(@NotNull final PsiElement elementAtPointer, @NotNull PsiReference ref) { super(elementAtPointer, ReferenceRange.getAbsoluteRanges(ref)); }
public InfoSingle(final PsiReference ref, @NotNull final PsiElement targetElement) { super(ref.getElement(), ReferenceRange.getAbsoluteRanges(ref)); myTargetElement = targetElement; }