public @Nullable("null means range is invalid") ProperTextRange getRangeInElement() {
    PsiElement element = getElement();
    if (element == null) return null;
    PsiFile psiFile = getFile();
    boolean isNullOrBinary = psiFile == null || psiFile.getFileType().isBinary();
    if (isNullOrBinary) return new ProperTextRange(0,0);
    TextRange elementRange = element.getTextRange();
    ProperTextRange result;
    if (myPsiFileRange == null) {
      int startOffset = element.getTextOffset();
      result = ProperTextRange.create(startOffset, elementRange.getEndOffset());
    }
    else {
      Segment rangeInFile = myPsiFileRange.getRange();
      if (rangeInFile == null) return null;
      result = ProperTextRange.create(rangeInFile);
    }
    int delta = elementRange.getStartOffset();
    return result.getStartOffset() < delta ? null : result.shiftRight(-delta);
  }
public @Nullable("null means range is invalid") ProperTextRange getRangeInElement()