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);
       }
     }
   }
 }
示例#3
0
 public InfoMultiple(@NotNull final PsiElement elementAtPointer, @NotNull PsiReference ref) {
   super(elementAtPointer, ReferenceRange.getAbsoluteRanges(ref));
 }
示例#4
0
 public InfoSingle(final PsiReference ref, @NotNull final PsiElement targetElement) {
   super(ref.getElement(), ReferenceRange.getAbsoluteRanges(ref));
   myTargetElement = targetElement;
 }