示例#1
0
        /// <summary>
        /// Gets the row and column of the given position.
        /// </summary>
        /// <param name="position">Position to get the row and column of.</param>
        /// <param name="row">Resulting row.</param>
        /// <param name="column">Resulting column.</param>
        public void GetRowColumn(Position position, out int row, out int column)
        {
            int pos = 0, next;

            // count the number of newlines until the offset
            row = 1;
            while ((next = _input.IndexOf('\n', pos, position.Offset - pos)) >= 0) {
                row++;
                pos = next + 1;
            }

            // get the start column
            column = position.Offset - pos + 1;
        }
示例#2
0
        /// <summary>
        /// Gets the start and end row and column of the given position.
        /// </summary>
        /// <param name="position">Position to get the row and column of.</param>
        /// <param name="startRow">Resulting start row.</param>
        /// <param name="startColumn">Resulting start column.</param>
        /// <param name="endRow">Resulting end row.</param>
        /// <param name="endColumn">Resulting end column.</param>
        public void GetRowColumn(Position position,
		                         out int startRow,
		                         out int startColumn,
		                         out int endRow,
		                         out int endColumn)
        {
            // get start row and column first
            GetRowColumn(position, out startRow, out startColumn);

            // count the number of newlines until we're at the end
            int pos = position.Offset - startColumn + 1, next;
            endRow = startRow;
            while ((next = _input.IndexOf('\n', pos, position.Offset + position.Length - pos)) >= 0) {
                endRow++;
                pos = next + 1;
            }

            // get the end column
            endColumn = position.Offset + position.Length - pos + 1;
        }
示例#3
0
 /// <summary>
 /// Reports a warning message at the specified position.
 /// </summary>
 /// <param name="position">Position the error occurred.</param>
 /// <param name="message">Error message.</param>
 protected void Warning(Position position, string message)
 {
     _observer.Warning(position, message);
 }
示例#4
0
 /// <summary>
 /// Reports an error message at the specified position.
 /// </summary>
 /// <param name="position">Position the error occurred.</param>
 /// <param name="message">Error message.</param>
 protected void Error(Position position, string message)
 {
     _observer.Error(position, message);
 }