コード例 #1
0
        public CodePosition GetTwoDimensionalCordinatesFor(int stringOffset)
        {
            CodePosition result;

            int line = newLineOffsets.BinarySearch(stringOffset);

            if(line < 0) // there is no newline string at this offset
            {
                int lineNumber = ~line;
                int lineStartOffset = 0;

                if(lineNumber != 0)
                {
                    lineStartOffset = newLineOffsets[lineNumber - 1] + NewLine.Length;
                }

                int column = stringOffset - lineStartOffset;
				if (isZeroIndexed)
				{
					result = new CodePosition(lineNumber, column);
				}
				else
				{
					result = new CodePosition(lineNumber + 1, column + 1); //VS editor uses [1,1] as origin as opposed to [0,0]
				}
            }
            else
            {
				if (isZeroIndexed)
				{
					result = new CodePosition(line, -1);
				}
				else
				{
					result = new CodePosition(line + 1, -1);
				}
            }

            return result;
        }
コード例 #2
0
 public CodeSpan(CodePosition start, CodePosition end)
 {
     Start = start;
     End = end;
 }
コード例 #3
0
 public CodeSpan(CodePosition start, CodePosition end)
 {
     Start = start;
     End   = end;
 }
コード例 #4
0
 public CodeSpan(CodePosition start, CodePosition end)
 {
     this.Start = start;
     this.End   = end;
     return;
 }