change.d.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @license
  3. * Copyright Google Inc. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. export interface Host {
  9. write(path: string, content: string): Promise<void>;
  10. read(path: string): Promise<string>;
  11. }
  12. export interface Change {
  13. apply(host: Host): Promise<void>;
  14. readonly path: string | null;
  15. readonly order: number;
  16. readonly description: string;
  17. }
  18. /**
  19. * An operation that does nothing.
  20. */
  21. export declare class NoopChange implements Change {
  22. description: string;
  23. order: number;
  24. path: null;
  25. apply(): Promise<void>;
  26. }
  27. /**
  28. * Will add text to the source code.
  29. */
  30. export declare class InsertChange implements Change {
  31. path: string;
  32. pos: number;
  33. toAdd: string;
  34. order: number;
  35. description: string;
  36. constructor(path: string, pos: number, toAdd: string);
  37. /**
  38. * This method does not insert spaces if there is none in the original string.
  39. */
  40. apply(host: Host): Promise<void>;
  41. }
  42. /**
  43. * Will remove text from the source code.
  44. */
  45. export declare class RemoveChange implements Change {
  46. path: string;
  47. private pos;
  48. private toRemove;
  49. order: number;
  50. description: string;
  51. constructor(path: string, pos: number, toRemove: string);
  52. apply(host: Host): Promise<void>;
  53. }
  54. /**
  55. * Will replace text from the source code.
  56. */
  57. export declare class ReplaceChange implements Change {
  58. path: string;
  59. private pos;
  60. private oldText;
  61. private newText;
  62. order: number;
  63. description: string;
  64. constructor(path: string, pos: number, oldText: string, newText: string);
  65. apply(host: Host): Promise<void>;
  66. }