void (@NotNull InsertionContext context) { context.commitDocument(); if (myFile.isValid()) { final PsiReference psiReference = context.getFile().findReferenceAt(context.getStartOffset()); final Pair<FileReference, Boolean> fileReferencePair = getReference(psiReference); if (fileReferencePair != null) { FileReference ref = fileReferencePair.getFirst(); context.setTailOffset(ref.getRangeInElement().getEndOffset() + ref.getElement().getTextRange().getStartOffset()); if (ref instanceof FileReferenceWithExtendedCompletion) { ((FileReferenceWithExtendedCompletion)ref).bindToExtendedElement(myFile); } else { ref.bindToElement(myFile); } } } }