You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.2 KiB

4 years ago
  1. import { Options } from "./options";
  2. import { namedTypes } from "ast-types";
  3. declare type Pos = namedTypes.Position;
  4. declare type LineInfo = {
  5. readonly line: string;
  6. readonly indent: number;
  7. readonly locked: boolean;
  8. readonly sliceStart: number;
  9. readonly sliceEnd: number;
  10. };
  11. export declare class Lines {
  12. private infos;
  13. readonly length: number;
  14. readonly name: string | null;
  15. private mappings;
  16. private cachedSourceMap;
  17. private cachedTabWidth;
  18. constructor(infos: LineInfo[], sourceFileName?: string | null);
  19. toString(options?: Options): string;
  20. getSourceMap(sourceMapName: string, sourceRoot?: string): any;
  21. bootstrapCharAt(pos: Pos): string;
  22. charAt(pos: Pos): string;
  23. stripMargin(width: number, skipFirstLine: boolean): Lines;
  24. indent(by: number): Lines;
  25. indentTail(by: number): Lines;
  26. lockIndentTail(): Lines;
  27. getIndentAt(line: number): number;
  28. guessTabWidth(): number;
  29. startsWithComment(): boolean;
  30. isOnlyWhitespace(): boolean;
  31. isPrecededOnlyByWhitespace(pos: Pos): boolean;
  32. getLineLength(line: number): number;
  33. nextPos(pos: Pos, skipSpaces?: boolean): boolean;
  34. prevPos(pos: Pos, skipSpaces?: boolean): boolean;
  35. firstPos(): {
  36. line: number;
  37. column: number;
  38. };
  39. lastPos(): {
  40. line: number;
  41. column: number;
  42. };
  43. skipSpaces(pos: Pos, backward?: boolean, modifyInPlace?: boolean): namedTypes.Position | null;
  44. trimLeft(): Lines;
  45. trimRight(): Lines;
  46. trim(): Lines;
  47. eachPos(callback: (pos: Pos) => any, startPos?: Pos, skipSpaces?: boolean): void;
  48. bootstrapSlice(start: Pos, end: Pos): Lines;
  49. slice(start?: Pos, end?: Pos): Lines;
  50. bootstrapSliceString(start: Pos, end: Pos, options?: Options): string;
  51. sliceString(start?: Pos, end?: Pos, options?: Options): string;
  52. isEmpty(): boolean;
  53. join(elements: (string | Lines)[]): Lines;
  54. concat(...args: (string | Lines)[]): Lines;
  55. }
  56. export declare function countSpaces(spaces: any, tabWidth?: number): number;
  57. /**
  58. * @param {Object} options - Options object that configures printing.
  59. */
  60. export declare function fromString(string: string | Lines, options?: Options): Lines;
  61. export declare function concat(elements: any): Lines;
  62. export {};