Podfile.prototype.scopeRanges = function()

in appcenter-link-scripts/src/ios/PodFile.js [153:181]


Podfile.prototype.scopeRanges = function (content) {
    const targetKeyword = 'target';

    const result = [];
    const targetsStack = [];
    const currentRange = { start: 0, end: 0 };
    let currentOffset = 0;

    let keywordMatch = this.nextKeyword(content, currentOffset);
    while (keywordMatch.index >= 0) {
        if (keywordMatch.keyword === targetKeyword) {
            currentRange.end = keywordMatch.index - 1;
            if (targetsStack.length === 0) {
                result.push({ ...currentRange });
            }
            targetsStack.push(keywordMatch.index);
        } else {
            targetsStack.pop();
            if (targetsStack.length === 0) {
                currentRange.start = keywordMatch.index + keywordMatch.keyword.length;
            }
        }
        currentOffset = keywordMatch.index + keywordMatch.keyword.length;
        keywordMatch = this.nextKeyword(content, currentOffset);
    }
    currentRange.end = content.length;
    result.push({ ...currentRange });
    return result;
};