All files / types position.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 4/4
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65                                                  995x             633x                       3x                                   6x    
/**
 * Position and Range types for LSP integration
 * These types are compatible with VS Code's Position and Range
 */
 
/**
 * A position in a text document (0-based line and character)
 */
export interface Position {
  readonly line: number;
  readonly character: number;
}
 
/**
 * A range in a text document
 */
export interface Range {
  readonly start: Position;
  readonly end: Position;
}
 
/**
 * Create a Position
 */
export function createPosition(line: number, character: number): Position {
  return { line, character };
}
 
/**
 * Create a Range
 */
export function createRange(start: Position, end: Position): Range {
  return { start, end };
}
 
/**
 * Create a Range from line/character numbers
 */
export function createRangeFromNumbers(
  startLine: number,
  startChar: number,
  endLine: number,
  endChar: number,
): Range {
  return {
    start: { line: startLine, character: startChar },
    end: { line: endLine, character: endChar },
  };
}
 
/**
 * A located value - wraps a value with its position in the document
 */
export interface Located<T> {
  readonly value: T;
  readonly range: Range;
}
 
/**
 * Create a Located value
 */
export function located<T>(value: T, range: Range): Located<T> {
  return { value, range };
}