-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapter.ts
84 lines (73 loc) · 2.08 KB
/
adapter.ts
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
interface Adapter<T> {
/**
* Get source code of the ast node
* @param node {T} ast node
* @returns {string} source code
*/
getSource(node: T, options?: { fixIndent: boolean }): string;
/**
* The file content of the ast node file
* @param node {T} ast node
* @returns file content
*/
fileContent(node: T): string;
/**
* @typedef Range
* @property start {number} - start posistion
* @property end {number} - end posistion
*/
/**
* Get the start/end range of the child node
* @param node {T} ast node
* @param childName {string} child name selector
* @returns {Range} child node range
*/
childNodeRange(node: T, childName: string): { start: number, end: number };
/**
* Get the value of the child node
* @param node {T} ast node
* @param childName {string} child name selector
* @returns {any} child node value
*/
childNodeValue(node: T, childName: string): any;
/**
* Get start position of ast node
* @param node {T} ast node
* @param childName {string} child name selector
* @returns {number} start position
*/
getStart(node: T, childName?: string): number;
/**
* Get end position of ast node
* @param node {T} ast node
* @param childName {string} child name selector
* @returns {number} end position
*/
getEnd(node: T, childName?: string): number;
/**
* @typedef Location
* @property line {number} - line
* @property column {number} - column
*/
/**
* Get start location of ast node
* @param node {T} ast node
* @param childName {string} child name selector
* @returns {Location} start location
*/
getStartLoc(node: T, childName?: string): { line: number, column: number };
/**
* Get end location of ast node
* @param node {T} ast node
* @param childName {string} child name selector
* @returns {Location} end location
*/
getEndLoc(node: T, childName?: string): { line: number, column: number };
/**
* Get indent of ast node
* @param node {T} ast node
* @returns {Number} indent
*/
getIndent(node: T): number;
}
export default Adapter;