Improved calculation of function/methods sourceEnd for code folding