public string GetSourceCode(SequencePoint sequencePoint)
    {
        string[] lines;
        try
        {
            lines = sourceCodeProvider.GetSourceCode(sequencePoint.Document.Url);
        }
        catch (Exception)
        {
            throw new WeavingException("Can not find sourcecode. Ensure that generating PDB is enabled.");
        }

        if (lines == null)
        {
            return(null);
        }

        if (sequencePoint.StartLine == sequencePoint.EndLine)
        {
            return(lines[sequencePoint.StartLine - 1].Substring(sequencePoint.StartColumn - 1, sequencePoint.EndColumn - sequencePoint.StartColumn));
        }

        var list = new List <string>();

        var startLine = sequencePoint.StartLine - 1;
        var endLine   = sequencePoint.EndLine - 1;

        list.Add(lines[startLine].Substring(sequencePoint.StartColumn - 1));
        for (var i = startLine + 1; i < endLine; i++)
        {
            list.Add(lines[i]);
        }

        var endColumn = sequencePoint.EndColumn - 1;
        var lastLine  = lines[endLine];

        if (endColumn < lastLine.Length)
        {
            list.Add(lastLine.Remove(endColumn));
        }
        else
        {
            list.Add(lastLine);
        }

        return(string.Join(" ", list.Select(x => x.Trim())));
    }
 public FunctionMapStore(ISourceCodeProvider sourceCodeProvider, Func <string, SourceMap> sourceMapGetter)
 {
     _functionMapGenerator = new FunctionMapGenerator();
     _functionMapCache     = new KeyValueCache <string, IReadOnlyList <FunctionMapEntry> >(sourceCodeUrl => _functionMapGenerator.GenerateFunctionMap(
                                                                                               sourceCodeProvider.GetSourceCode(sourceCodeUrl),
                                                                                               sourceMapGetter(sourceCodeUrl)));
 }