doc: Range datatype (#3296)

This commit is contained in:
Dmitry Bushev 2022-02-22 13:21:24 +03:00 committed by GitHub
parent 5c6c882c38
commit 9010a2c3a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 6 deletions

View File

@ -983,17 +983,44 @@ struct Position {
A representation of a range of text in a text file.
For example, given the function.
```
0|inc x =
1| x + 1
^^^^^^^^^
012345678
```
The range of `inc` is
```typescript
{
start: { line: 0, character: 0},
end: { line: 0, character: 3}
}
```
The range of `1` is
```typescript
{
start: { line: 1, character: 8},
end: { line: 1, character: 9}
}
```
#### Format
```typescript
interface Range {
/**
* The range's start position.
* The range's start position (inclusive).
*/
start: Position;
/**
* The range's end position.
* The range's end position (exclusive).
*/
end: Position;
}

View File

@ -4,8 +4,8 @@ object model {
/** A representation of a position in a text file.
*
* @param line a line position in a document (zero-based).
* @param character a character offset
* @param line a line position in a document (zero-based)
* @param character a character offset (zero-based)
*/
case class Position(line: Int, character: Int) extends Ordered[Position] {
@ -26,8 +26,28 @@ object model {
/** A representation of a range of text in a text file.
*
* @param start the range's start position
* @param end the range's end position
* ==Example==
* Given the function.
*
* {{{
* 0|inc x =
1| x + 1
* ^^^^^^^^^
* 012345678
* }}}
*
* The range of `inc` is
* {{{
* Range(Position(0, 0), Position(0, 3))
* }}}
*
* The range of `1` is
* {{{
* Range(Position(1, 8), Position(1, 9))
* }}}
*
* @param start the range's start position (inclusive)
* @param end the range's end position (exclusive)
*/
case class Range(start: Position, end: Position)