docs: @VisibleForTesting
    static Optional<Integer> computeEndPosition(
        Tree methodInvocationTree, CharSequence sourceCode, VisitorState state) {
      int invocationEnd = state.getEndPosition(methodInvocationTree);
      if (invocationEnd == -1) {
        return Optional.empty();
      }
  
      // Finding a good end position is expensive so first check whether we have any comment at
      // the end of our line. If we don't then we can just use the end of the methodInvocationTree
      int nextNewLine = CharMatcher.is('\n').indexIn(sourceCode, invocationEnd);
      if (nextNewLine == -1) {
        return Optional.of(invocationEnd);
      }
  
      if (CharMatcher.is('/').matchesNoneOf(sourceCode.subSequence(invocationEnd, nextNewLine))) {
        return Optional.of(invocationEnd);
      }
  
      int nextNodeEnd = state.getEndPosition(getNextNodeOrParent(methodInvocationTree, state));
      if (nextNodeEnd == -1) {
        return Optional.of(invocationEnd);
      }
  
      return Optional.of(nextNodeEnd);
    }