1+
2+ /**
3+ formeo - https://formeo.io
4+ Version: 3.1.0
5+ Author: Draggable https://draggable.io
6+ */
7+
8+ ace . define ( "ace/mode/json_highlight_rules" , [ "require" , "exports" , "module" , "ace/lib/oop" , "ace/mode/text_highlight_rules" ] , function ( require , exports , module ) { "use strict" ;
9+ var oop = require ( "../lib/oop" ) ;
10+ var TextHighlightRules = require ( "./text_highlight_rules" ) . TextHighlightRules ;
11+ var JsonHighlightRules = function ( ) {
12+ this . $rules = {
13+ "start" : [
14+ {
15+ token : "variable" , // single line
16+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'
17+ } , {
18+ token : "string" , // single line
19+ regex : '"' ,
20+ next : "string"
21+ } , {
22+ token : "constant.numeric" , // hex
23+ regex : "0[xX][0-9a-fA-F]+\\b"
24+ } , {
25+ token : "constant.numeric" , // float
26+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
27+ } , {
28+ token : "constant.language.boolean" ,
29+ regex : "(?:true|false)\\b"
30+ } , {
31+ token : "text" , // single quoted strings are not allowed
32+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
33+ } , {
34+ token : "comment" , // comments are not allowed, but who cares?
35+ regex : "\\/\\/.*$"
36+ } , {
37+ token : "comment.start" , // comments are not allowed, but who cares?
38+ regex : "\\/\\*" ,
39+ next : "comment"
40+ } , {
41+ token : "paren.lparen" ,
42+ regex : "[[({]"
43+ } , {
44+ token : "paren.rparen" ,
45+ regex : "[\\])}]"
46+ } , {
47+ token : "punctuation.operator" ,
48+ regex : / [ , ] /
49+ } , {
50+ token : "text" ,
51+ regex : "\\s+"
52+ }
53+ ] ,
54+ "string" : [
55+ {
56+ token : "constant.language.escape" ,
57+ regex : / \\ (?: x [ 0 - 9 a - f A - F ] { 2 } | u [ 0 - 9 a - f A - F ] { 4 } | [ " \\ \/ b f n r t ] ) /
58+ } , {
59+ token : "string" ,
60+ regex : '"|$' ,
61+ next : "start"
62+ } , {
63+ defaultToken : "string"
64+ }
65+ ] ,
66+ "comment" : [
67+ {
68+ token : "comment.end" , // comments are not allowed, but who cares?
69+ regex : "\\*\\/" ,
70+ next : "start"
71+ } , {
72+ defaultToken : "comment"
73+ }
74+ ]
75+ } ;
76+ } ;
77+ oop . inherits ( JsonHighlightRules , TextHighlightRules ) ;
78+ exports . JsonHighlightRules = JsonHighlightRules ;
79+
80+ } ) ;
81+
82+ ace . define ( "ace/mode/matching_brace_outdent" , [ "require" , "exports" , "module" , "ace/range" ] , function ( require , exports , module ) { "use strict" ;
83+ var Range = require ( "../range" ) . Range ;
84+ var MatchingBraceOutdent = function ( ) { } ;
85+ ( function ( ) {
86+ this . checkOutdent = function ( line , input ) {
87+ if ( ! / ^ \s + $ / . test ( line ) )
88+ return false ;
89+ return / ^ \s * \} / . test ( input ) ;
90+ } ;
91+ this . autoOutdent = function ( doc , row ) {
92+ var line = doc . getLine ( row ) ;
93+ var match = line . match ( / ^ ( \s * \} ) / ) ;
94+ if ( ! match )
95+ return 0 ;
96+ var column = match [ 1 ] . length ;
97+ var openBracePos = doc . findMatchingBracket ( { row : row , column : column } ) ;
98+ if ( ! openBracePos || openBracePos . row == row )
99+ return 0 ;
100+ var indent = this . $getIndent ( doc . getLine ( openBracePos . row ) ) ;
101+ doc . replace ( new Range ( row , 0 , row , column - 1 ) , indent ) ;
102+ } ;
103+ this . $getIndent = function ( line ) {
104+ return line . match ( / ^ \s * / ) [ 0 ] ;
105+ } ;
106+ } ) . call ( MatchingBraceOutdent . prototype ) ;
107+ exports . MatchingBraceOutdent = MatchingBraceOutdent ;
108+
109+ } ) ;
110+
111+ ace . define ( "ace/mode/folding/cstyle" , [ "require" , "exports" , "module" , "ace/lib/oop" , "ace/range" , "ace/mode/folding/fold_mode" ] , function ( require , exports , module ) { "use strict" ;
112+ var oop = require ( "../../lib/oop" ) ;
113+ var Range = require ( "../../range" ) . Range ;
114+ var BaseFoldMode = require ( "./fold_mode" ) . FoldMode ;
115+ var FoldMode = exports . FoldMode = function ( commentRegex ) {
116+ if ( commentRegex ) {
117+ this . foldingStartMarker = new RegExp ( this . foldingStartMarker . source . replace ( / \| [ ^ | ] * ?$ / , "|" + commentRegex . start ) ) ;
118+ this . foldingStopMarker = new RegExp ( this . foldingStopMarker . source . replace ( / \| [ ^ | ] * ?$ / , "|" + commentRegex . end ) ) ;
119+ }
120+ } ;
121+ oop . inherits ( FoldMode , BaseFoldMode ) ;
122+ ( function ( ) {
123+ this . foldingStartMarker = / ( [ \{ \[ \( ] ) [ ^ \} \] \) ] * $ | ^ \s * ( \/ \* ) / ;
124+ this . foldingStopMarker = / ^ [ ^ \[ \{ \( ] * ( [ \} \] \) ] ) | ^ [ \s \* ] * ( \* \/ ) / ;
125+ this . singleLineBlockCommentRe = / ^ \s * ( \/ \* ) .* \* \/ \s * $ / ;
126+ this . tripleStarBlockCommentRe = / ^ \s * ( \/ \* \* \* ) .* \* \/ \s * $ / ;
127+ this . startRegionRe = / ^ \s * ( \/ \* | \/ \/ ) # ? r e g i o n \b / ;
128+ this . _getFoldWidgetBase = this . getFoldWidget ;
129+ this . getFoldWidget = function ( session , foldStyle , row ) {
130+ var line = session . getLine ( row ) ;
131+ if ( this . singleLineBlockCommentRe . test ( line ) ) {
132+ if ( ! this . startRegionRe . test ( line ) && ! this . tripleStarBlockCommentRe . test ( line ) )
133+ return "" ;
134+ }
135+ var fw = this . _getFoldWidgetBase ( session , foldStyle , row ) ;
136+ if ( ! fw && this . startRegionRe . test ( line ) )
137+ return "start" ; // lineCommentRegionStart
138+ return fw ;
139+ } ;
140+ this . getFoldWidgetRange = function ( session , foldStyle , row , forceMultiline ) {
141+ var line = session . getLine ( row ) ;
142+ if ( this . startRegionRe . test ( line ) )
143+ return this . getCommentRegionBlock ( session , line , row ) ;
144+ var match = line . match ( this . foldingStartMarker ) ;
145+ if ( match ) {
146+ var i = match . index ;
147+ if ( match [ 1 ] )
148+ return this . openingBracketBlock ( session , match [ 1 ] , row , i ) ;
149+ var range = session . getCommentFoldRange ( row , i + match [ 0 ] . length , 1 ) ;
150+ if ( range && ! range . isMultiLine ( ) ) {
151+ if ( forceMultiline ) {
152+ range = this . getSectionRange ( session , row ) ;
153+ }
154+ else if ( foldStyle != "all" )
155+ range = null ;
156+ }
157+ return range ;
158+ }
159+ if ( foldStyle === "markbegin" )
160+ return ;
161+ var match = line . match ( this . foldingStopMarker ) ;
162+ if ( match ) {
163+ var i = match . index + match [ 0 ] . length ;
164+ if ( match [ 1 ] )
165+ return this . closingBracketBlock ( session , match [ 1 ] , row , i ) ;
166+ return session . getCommentFoldRange ( row , i , - 1 ) ;
167+ }
168+ } ;
169+ this . getSectionRange = function ( session , row ) {
170+ var line = session . getLine ( row ) ;
171+ var startIndent = line . search ( / \S / ) ;
172+ var startRow = row ;
173+ var startColumn = line . length ;
174+ row = row + 1 ;
175+ var endRow = row ;
176+ var maxRow = session . getLength ( ) ;
177+ while ( ++ row < maxRow ) {
178+ line = session . getLine ( row ) ;
179+ var indent = line . search ( / \S / ) ;
180+ if ( indent === - 1 )
181+ continue ;
182+ if ( startIndent > indent )
183+ break ;
184+ var subRange = this . getFoldWidgetRange ( session , "all" , row ) ;
185+ if ( subRange ) {
186+ if ( subRange . start . row <= startRow ) {
187+ break ;
188+ }
189+ else if ( subRange . isMultiLine ( ) ) {
190+ row = subRange . end . row ;
191+ }
192+ else if ( startIndent == indent ) {
193+ break ;
194+ }
195+ }
196+ endRow = row ;
197+ }
198+ return new Range ( startRow , startColumn , endRow , session . getLine ( endRow ) . length ) ;
199+ } ;
200+ this . getCommentRegionBlock = function ( session , line , row ) {
201+ var startColumn = line . search ( / \s * $ / ) ;
202+ var maxRow = session . getLength ( ) ;
203+ var startRow = row ;
204+ var re = / ^ \s * (?: \/ \* | \/ \/ | - - ) # ? ( e n d ) ? r e g i o n \b / ;
205+ var depth = 1 ;
206+ while ( ++ row < maxRow ) {
207+ line = session . getLine ( row ) ;
208+ var m = re . exec ( line ) ;
209+ if ( ! m )
210+ continue ;
211+ if ( m [ 1 ] )
212+ depth -- ;
213+ else
214+ depth ++ ;
215+ if ( ! depth )
216+ break ;
217+ }
218+ var endRow = row ;
219+ if ( endRow > startRow ) {
220+ return new Range ( startRow , startColumn , endRow , line . length ) ;
221+ }
222+ } ;
223+ } ) . call ( FoldMode . prototype ) ;
224+
225+ } ) ;
226+
227+ ace . define ( "ace/mode/json" , [ "require" , "exports" , "module" , "ace/lib/oop" , "ace/mode/text" , "ace/mode/json_highlight_rules" , "ace/mode/matching_brace_outdent" , "ace/mode/folding/cstyle" , "ace/worker/worker_client" ] , function ( require , exports , module ) { "use strict" ;
228+ var oop = require ( "../lib/oop" ) ;
229+ var TextMode = require ( "./text" ) . Mode ;
230+ var HighlightRules = require ( "./json_highlight_rules" ) . JsonHighlightRules ;
231+ var MatchingBraceOutdent = require ( "./matching_brace_outdent" ) . MatchingBraceOutdent ;
232+ var CStyleFoldMode = require ( "./folding/cstyle" ) . FoldMode ;
233+ var WorkerClient = require ( "../worker/worker_client" ) . WorkerClient ;
234+ var Mode = function ( ) {
235+ this . HighlightRules = HighlightRules ;
236+ this . $outdent = new MatchingBraceOutdent ( ) ;
237+ this . $behaviour = this . $defaultBehaviour ;
238+ this . foldingRules = new CStyleFoldMode ( ) ;
239+ } ;
240+ oop . inherits ( Mode , TextMode ) ;
241+ ( function ( ) {
242+ this . lineCommentStart = "//" ;
243+ this . blockComment = { start : "/*" , end : "*/" } ;
244+ this . getNextLineIndent = function ( state , line , tab ) {
245+ var indent = this . $getIndent ( line ) ;
246+ if ( state == "start" ) {
247+ var match = line . match ( / ^ .* [ \{ \( \[ ] \s * $ / ) ;
248+ if ( match ) {
249+ indent += tab ;
250+ }
251+ }
252+ return indent ;
253+ } ;
254+ this . checkOutdent = function ( state , line , input ) {
255+ return this . $outdent . checkOutdent ( line , input ) ;
256+ } ;
257+ this . autoOutdent = function ( state , doc , row ) {
258+ this . $outdent . autoOutdent ( doc , row ) ;
259+ } ;
260+ this . createWorker = function ( session ) {
261+ var worker = new WorkerClient ( [ "ace" ] , "ace/mode/json_worker" , "JsonWorker" ) ;
262+ worker . attachToDocument ( session . getDocument ( ) ) ;
263+ worker . on ( "annotate" , function ( e ) {
264+ session . setAnnotations ( e . data ) ;
265+ } ) ;
266+ worker . on ( "terminate" , function ( ) {
267+ session . clearAnnotations ( ) ;
268+ } ) ;
269+ return worker ;
270+ } ;
271+ this . $id = "ace/mode/json" ;
272+ } ) . call ( Mode . prototype ) ;
273+ exports . Mode = Mode ;
274+
275+ } ) ; ( function ( ) {
276+ ace . require ( [ "ace/mode/json" ] , function ( m ) {
277+ if ( typeof module == "object" && typeof exports == "object" && module ) {
278+ module . exports = m ;
279+ }
280+ } ) ;
281+ } ) ( ) ;
282+
0 commit comments