src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js
function normalizeText(text, start, end, removeTrailingSemiColons) {
        var trimmedText;

        // Remove leading spaces
        trimmedText = _.trimLeft(text);

        if (trimmedText.length < text.length) {
            start += (text.length - trimmedText.length);
        }

        text = trimmedText;

        // Remove trailing spaces
        trimmedText = _.trimRight(text);

        if (trimmedText.length < text.length) {
            end -= (text.length - trimmedText.length);
        }

        text = trimmedText;

        // Remove trailing semicolons
        if (removeTrailingSemiColons) {
            trimmedText = _.trimRight(text, ';');

            if (trimmedText.length < text.length) {
                end -= (text.length - trimmedText.length);
            }
        }

        return {
            text: trimmedText,
            start: start,
            end: end
        };
    }
function normalizeText(text, start, end, removeTrailingSemiColons) {
        var trimmedText;

        // Remove leading spaces
        trimmedText = _.trimLeft(text);

        if (trimmedText.length < text.length) {
            start += (text.length - trimmedText.length);
        }

        text = trimmedText;

        // Remove trailing spaces
        trimmedText = _.trimRight(text);

        if (trimmedText.length < text.length) {
            end -= (text.length - trimmedText.length);
        }

        text = trimmedText;

        // Remove trailing semicolons
        if (removeTrailingSemiColons) {
            trimmedText = _.trimRight(text, ';');

            if (trimmedText.length < text.length) {
                end -= (text.length - trimmedText.length);
            }
        }

        return {
            text: trimmedText,
            start: start,
            end: end
        };
    }
function normalizeText ( text , start , end , removeTrailingSemiColons ) { var trimmedText ; // Remove leading spaces trimmedText = _ . trimLeft ( text ) ; if ( trimmedText . length < text . length ) { start += ( text . length - trimmedText . length ) ; } text = trimmedText ; // Remove trailing spaces trimmedText = _ . trimRight ( text ) ; if ( trimmedText . length < text . length ) { end -= ( text . length - trimmedText . length ) ; } text = trimmedText ; // Remove trailing semicolons if ( removeTrailingSemiColons ) { trimmedText = _ . trimRight ( text , ';' ) ; if ( trimmedText . length < text . length ) { end -= ( text . length - trimmedText . length ) ; } } return { text : trimmedText , start : start , end : end } ; }
Normalize text by removing leading and trailing whitespace characters
and moves the start and end offset to reflect the new offset
@param {!string} text - selected text
@param {!number} start - the start offset of the text
@param {!number} end - the end offset of the text
@param {!boolean} removeTrailingSemiColons - removes trailing semicolons also if true
@return {!{text: string, start: number, end: number}}
Normalize text by removing leading and trailing whitespace characters and moves the start and end offset to reflect the new offset