@@ -68,6 +68,14 @@ export interface JSONScanner {
68
68
* The length of the last read token.
69
69
*/
70
70
getTokenLength(): number ;
71
+ /**
72
+ * The zero-based start line number of the last read token.
73
+ */
74
+ getTokenLine(): number ;
75
+ /**
76
+ * The zero-based character (start column) of the last read token.
77
+ */
78
+ getTokenCharacter(): number ;
71
79
/**
72
80
* An error code of the last scan.
73
81
*/
@@ -93,42 +101,42 @@ export declare function parse(text: string, errors?: {error: ParseErrorCode;}[],
93
101
export declare function visit(text : string , visitor : JSONVisitor , options ? : ParseOptions ): any ;
94
102
95
103
export interface JSONVisitor {
96
- /**
97
- * Invoked when an open brace is encountered and an object is started. The offset and length represent the location of the open brace.
98
- */
99
- onObjectBegin? : (offset : number , length : number ) => void ;
100
- /**
101
- * Invoked when a property is encountered. The offset and length represent the location of the property name.
102
- */
103
- onObjectProperty? : (property : string , offset : number , length : number ) => void ;
104
- /**
105
- * Invoked when a closing brace is encountered and an object is completed. The offset and length represent the location of the closing brace.
106
- */
107
- onObjectEnd? : (offset : number , length : number ) => void ;
108
- /**
109
- * Invoked when an open bracket is encountered. The offset and length represent the location of the open bracket.
110
- */
111
- onArrayBegin? : (offset : number , length : number ) => void ;
112
- /**
113
- * Invoked when a closing bracket is encountered. The offset and length represent the location of the closing bracket.
114
- */
115
- onArrayEnd? : (offset : number , length : number ) => void ;
116
- /**
117
- * Invoked when a literal value is encountered. The offset and length represent the location of the literal value.
118
- */
119
- onLiteralValue? : (value : any , offset : number , length : number ) => void ;
120
- /**
121
- * Invoked when a comma or colon separator is encountered. The offset and length represent the location of the separator.
122
- */
123
- onSeparator? : (charcter : string , offset : number , length : number ) => void ;
104
+ /**
105
+ * Invoked when an open brace is encountered and an object is started. The offset and length represent the location of the open brace.
106
+ */
107
+ onObjectBegin? : (offset : number , length : number , startLine : number , startCharacter : number ) => void ;
108
+ /**
109
+ * Invoked when a property is encountered. The offset and length represent the location of the property name.
110
+ */
111
+ onObjectProperty? : (property : string , offset : number , length : number , startLine : number , startCharacter : number ) => void ;
112
+ /**
113
+ * Invoked when a closing brace is encountered and an object is completed. The offset and length represent the location of the closing brace.
114
+ */
115
+ onObjectEnd? : (offset : number , length : number , startLine : number , startCharacter : number ) => void ;
116
+ /**
117
+ * Invoked when an open bracket is encountered. The offset and length represent the location of the open bracket.
118
+ */
119
+ onArrayBegin? : (offset : number , length : number , startLine : number , startCharacter : number ) => void ;
120
+ /**
121
+ * Invoked when a closing bracket is encountered. The offset and length represent the location of the closing bracket.
122
+ */
123
+ onArrayEnd? : (offset : number , length : number , startLine : number , startCharacter : number ) => void ;
124
+ /**
125
+ * Invoked when a literal value is encountered. The offset and length represent the location of the literal value.
126
+ */
127
+ onLiteralValue? : (value : any , offset : number , length : number , startLine : number , startCharacter : number ) => void ;
128
+ /**
129
+ * Invoked when a comma or colon separator is encountered. The offset and length represent the location of the separator.
130
+ */
131
+ onSeparator? : (character : string , offset : number , length : number , startLine : number , startCharacter : number ) => void ;
124
132
/**
125
133
* When comments are allowed, invoked when a line or block comment is encountered. The offset and length represent the location of the comment.
126
134
*/
127
- onComment? : (offset : number , length : number ) => void ;
128
- /**
129
- * Invoked on an error.
130
- */
131
- onError? : (error : ParseErrorCode , offset : number , length : number ) => void ;
135
+ onComment? : (offset : number , length : number , startLine : number , startCharacter : number ) => void ;
136
+ /**
137
+ * Invoked on an error.
138
+ */
139
+ onError? : (error : ParseErrorCode , offset : number , length : number , startLine : number , startCharacter : number ) => void ;
132
140
}
133
141
134
142
/**
@@ -298,4 +306,4 @@ License
298
306
299
307
(MIT License)
300
308
301
- Copyright 2018, Microsoft
309
+ Copyright 2018, Microsoft
0 commit comments