IronPython.Compiler.Ast.Node.IndexToLocation C# (CSharp) Method

IndexToLocation() private method

private IndexToLocation ( int index ) : Microsoft.Scripting.SourceLocation
index int
return Microsoft.Scripting.SourceLocation
        internal SourceLocation IndexToLocation(int index) {
            if (index == -1) {
                return SourceLocation.Invalid;
            }

            var locs = GlobalParent._lineLocations;
            int match = Array.BinarySearch(locs, index);
            if (match < 0) {
                // If our index = -1, it means we're on the first line.
                if (match == -1) {
                    return new SourceLocation(index, 1, index + 1);
                }

                // If we couldn't find an exact match for this line number, get the nearest
                // matching line number less than this one
                match = ~match - 1;
            }
            return new SourceLocation(index, match + 2, index - locs[match] + 1);
        }