@@ -109,6 +109,22 @@ let check_error = function (instance) {
109109 } , { className : "syntax-error" } ) ) ;
110110 } )
111111 } ) ;
112+
113+
114+ return true ;
115+ }
116+ let missing_parts = find_missing ( instance ) ;
117+ if ( missing_parts . length > 0 ) {
118+ missing_parts . forEach ( missing_part => {
119+ instance . syntaxErrorMark . push ( instance . markText ( {
120+ line : missing_part . start . row ,
121+ ch : missing_part . start . column
122+ } ,
123+ {
124+ line : missing_part . end . row ,
125+ ch : missing_part . end . column
126+ } , { className : "syntax-error" } ) ) ;
127+ } ) ;
112128 return true ;
113129 }
114130 return false ;
@@ -121,7 +137,46 @@ let check_error_bloc = function (text) {
121137 let errors = error_query . matches ( parser . parse ( text ) . rootNode ) ;
122138 return errors . length > 0 ;
123139}
124-
140+
141+ let find_missing = function ( instance ) {
142+ let cursor = parser . parse ( instance . getValue ( ) ) . walk ( ) ;
143+ let make_move = function ( cursor , move , fn ) {
144+ if ( move == "down" ) {
145+ fn ( cursor ) ;
146+ if ( cursor . gotoFirstChild ( ) ) {
147+ make_move ( cursor , "down" , fn ) ;
148+ } else if ( cursor . gotoNextSibling ( ) ) {
149+ make_move ( cursor , "right" , fn ) ;
150+ } else if ( cursor . gotoParent ( ) ) {
151+ make_move ( cursor , "up" , fn ) ;
152+ }
153+ } else if ( move == "right" ) {
154+ fn ( cursor ) ;
155+ if ( cursor . gotoFirstChild ( ) ) {
156+ make_move ( cursor , "down" , fn ) ;
157+ } else if ( cursor . gotoNextSibling ( ) ) {
158+ make_move ( cursor , "right" , fn ) ;
159+ } else if ( cursor . gotoParent ( ) ) {
160+ make_move ( cursor , "up" , fn ) ;
161+ }
162+ } else if ( move == "up" ) {
163+ if ( cursor . gotoNextSibling ( ) ) {
164+ make_move ( cursor , "right" , fn ) ;
165+ } else if ( cursor . gotoParent ( ) ) {
166+ make_move ( cursor , "up" , fn ) ;
167+ }
168+ }
169+ }
170+ let missing = [ ] ;
171+ make_move ( cursor , "down" , function ( cursor ) {
172+ if ( cursor . currentNode . isMissing ) {
173+ let start = cursor . currentNode . parent . startPosition ;
174+ let end = cursor . currentNode . parent . endPosition ;
175+ missing . push ( { start : start , end : end } ) ;
176+ }
177+ } ) ;
178+ return missing ;
179+ }
125180
126181
127182let calculate_interval = function ( instance ) {
0 commit comments