function parseFunction()

in scripts/gocov-to-istanbul-coverage.js [27:104]


function parseFunction(folderName, functionInfo) {
    // console.error('functionInfo', functionInfo);
    var filePath = path.join(process.cwd(), functionInfo.File);

    var fileObj = this.output[filePath];
    if (!fileObj) {
        fileObj = this.output[filePath] = new FileCoverageInfo(filePath);
    }

    var fileLoc = this.fileLocCache[filePath];
    if (!fileLoc) {
        fileLoc = this.fileLocCache[filePath] = new FileLoc(filePath);
    }

    var fnName = functionInfo.Name;
    var startOffset = functionInfo.Start;
    var endOffset = functionInfo.End;

    var startLoc = fileLoc.computeFunctionStartLocation(startOffset);
    var endLoc = fileLoc.computeFunctionEndLocation(endOffset);

    // console.error('functionLoc', {
    //     start: startLoc,
    //     end: endLoc
    // });

    var fnId = fileObj.fnCounter;
    fileObj.f[fnId] = 1
    fileObj.fnMap[fnId] = {
        name: fnName,
        line: startLoc.line,
        loc: {
            start: startLoc,
            end: endLoc
        },
        skip: false
    };
    fileObj.fnCounter++;

    // TODO(sindelar): Investigate
    if (functionInfo.Statements == null) {
        return
    }
    for (var i = 0; i < functionInfo.Statements.length; i++) {
        var statement = functionInfo.Statements[i];
        
        var startLoc = fileLoc.computeStatementLocation(statement.Start);
        var endLoc = fileLoc.computeStatementLocation(statement.End);

        var skipped = false
            
        // ignoredLines is 0 indexed, startLoc is 1 indexed
        var lineIndex = startLoc.line - 1;
        if (fileLoc.ignoredLines.indexOf(lineIndex) >= 0) {
            // If this statement is ignored then it is ignored
            skipped = true
        }

        var sId = fileObj.sCounter;
        fileObj.s[sId] = statement.Reached;
        fileObj.statementMap[sId] = {
            start: startLoc,
            end: endLoc,
            skip: skipped
        };

        // console.error('handleStatement', {
        //     fnName: fnName,
        //     offsets: [statement.Start,statement.End],
        //     fileName: filePath,
        //     start: startLoc,
        //     end: endLoc,
        //     ignoredLines: fileLoc.ignoredLines
        // });

        fileObj.sCounter++;
    }
};