Index: trunk/extensions/VisualEditor/modules/parser/ext.core.QuoteTransformer.js |
— | — | @@ -54,17 +54,15 @@ |
55 | 55 | // the length of quote string. Actual analysis and conversion to the |
56 | 56 | // appropriate tag tokens is deferred until the next NEWLINE token triggers |
57 | 57 | // onNewLine. |
58 | | -QuoteTransformer.prototype.onQuote = function ( token, cb, frame, prevToken ) { |
| 58 | +QuoteTransformer.prototype.onQuote = function ( token, frame, prevToken ) { |
59 | 59 | var qlen = token.value.length, |
60 | 60 | tokens = [], // output tokens |
61 | 61 | ctx = { |
62 | 62 | token: token, |
63 | | - cb: cb, |
64 | 63 | frame: frame, |
65 | 64 | prevToken: prevToken |
66 | 65 | }, |
67 | 66 | ctx2 = { |
68 | | - cb: cb, |
69 | 67 | frame: frame, |
70 | 68 | prevToken: prevToken |
71 | 69 | }; |
— | — | @@ -122,7 +120,7 @@ |
123 | 121 | return {}; |
124 | 122 | }; |
125 | 123 | |
126 | | -QuoteTransformer.prototype.onAny = function ( token, cb, frame, prevToken ) { |
| 124 | +QuoteTransformer.prototype.onAny = function ( token, frame, prevToken ) { |
127 | 125 | //console.log('qt onAny: ' + JSON.stringify(token, null, 2)); |
128 | 126 | this.currentChunk.push( token ); |
129 | 127 | return {}; |
— | — | @@ -130,7 +128,7 @@ |
131 | 129 | |
132 | 130 | // Handle NEWLINE tokens, which trigger the actual quote analysis on the |
133 | 131 | // collected quote tokens so far. |
134 | | -QuoteTransformer.prototype.onNewLine = function ( token, cb, frame, prevToken ) { |
| 132 | +QuoteTransformer.prototype.onNewLine = function ( token, frame, prevToken ) { |
135 | 133 | var res; |
136 | 134 | |
137 | 135 | if( ! this.isActive ) { |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js |
— | — | @@ -199,7 +199,7 @@ |
200 | 200 | * processed tokens. |
201 | 201 | * @returns {Object} Token(s) and async indication. |
202 | 202 | */ |
203 | | -TokenTransformManager.prototype._transformTagToken = function ( token, cb, phaseEndRank ) { |
| 203 | +TokenTransformManager.prototype._transformTagToken = function ( token, phaseEndRank, cbOrPrevToken ) { |
204 | 204 | // prepend 'any' transformers |
205 | 205 | var ts = this.transformers.any, |
206 | 206 | res = { token: token }, |
— | — | @@ -225,7 +225,7 @@ |
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | // Transform token with side effects |
229 | | - res = transformer.transform( res.token, cb, this, this.prevToken ); |
| 229 | + res = transformer.transform( res.token, this, cbOrPrevToken ); |
230 | 230 | // XXX: Sync transform: |
231 | 231 | // res = transformer.transform( res.token, this, this.prevToken ); |
232 | 232 | // XXX: Async transform: |
— | — | @@ -269,7 +269,7 @@ |
270 | 270 | * @param {Array} ts List of token transformers for this token type. |
271 | 271 | * @returns {Object} Token(s) and async indication. |
272 | 272 | */ |
273 | | -TokenTransformManager.prototype._transformToken = function ( token, cb, phaseEndRank, ts ) { |
| 273 | +TokenTransformManager.prototype._transformToken = function ( token, phaseEndRank, ts, cbOrPrevToken ) { |
274 | 274 | // prepend 'any' transformers |
275 | 275 | var anyTrans = this.transformers.any; |
276 | 276 | if ( anyTrans.length ) { |
— | — | @@ -290,7 +290,7 @@ |
291 | 291 | // XXX: consider moving the rank out of the token itself to avoid |
292 | 292 | // transformations messing with it in broken ways. Not sure if |
293 | 293 | // some transformations need to manipulate it though. gwicke |
294 | | - res = transformer.transform( res.token, cb, this, this.prevToken ); |
| 294 | + res = transformer.transform( res.token, this, cbOrPrevToken ); |
295 | 295 | if ( !res.token || |
296 | 296 | res.token.type !== token.type ) { |
297 | 297 | this._resetTokenRank ( res, transformer ); |
— | — | @@ -489,26 +489,26 @@ |
490 | 490 | |
491 | 491 | switch ( token.constructor ) { |
492 | 492 | case String: |
493 | | - res = this._transformToken( token, cb, phaseEndRank, ts.text ); |
| 493 | + res = this._transformToken( token, phaseEndRank, ts.text, cb ); |
494 | 494 | break; |
495 | 495 | case NlTk: |
496 | | - res = this._transformToken( token, cb, phaseEndRank, ts.newline ); |
| 496 | + res = this._transformToken( token, phaseEndRank, ts.newline, cb ); |
497 | 497 | break; |
498 | 498 | case TagTk: |
499 | 499 | case EndTagTk: |
500 | 500 | case SelfclosingTagTk: |
501 | | - res = this._transformTagToken( token, cb, phaseEndRank ); |
| 501 | + res = this._transformTagToken( token, phaseEndRank, cb ); |
502 | 502 | break; |
503 | 503 | default: |
504 | 504 | switch( token.type ) { |
505 | 505 | case 'COMMENT': |
506 | | - res = this._transformToken( token, cb, phaseEndRank, ts.comment); |
| 506 | + res = this._transformToken( token, phaseEndRank, ts.comment, cb ); |
507 | 507 | break; |
508 | 508 | case 'END': |
509 | | - res = this._transformToken( token, cb, phaseEndRank, ts.end ); |
| 509 | + res = this._transformToken( token, phaseEndRank, ts.end, cb ); |
510 | 510 | break; |
511 | 511 | default: |
512 | | - res = this._transformToken( token, cb, phaseEndRank, ts.martian ); |
| 512 | + res = this._transformToken( token, phaseEndRank, ts.martian, cb ); |
513 | 513 | break; |
514 | 514 | } |
515 | 515 | break; |
— | — | @@ -670,27 +670,27 @@ |
671 | 671 | |
672 | 672 | switch( token.constructor ) { |
673 | 673 | case String: |
674 | | - res = this._transformToken( token, cb, this.phaseEndRank, |
675 | | - ts.text ); |
| 674 | + res = this._transformToken( token, this.phaseEndRank, |
| 675 | + ts.text, this.prevToken ); |
676 | 676 | break; |
677 | 677 | case NlTk: |
678 | | - res = this._transformToken( token, cb, this.phaseEndRank, ts.newline ); |
| 678 | + res = this._transformToken( token, this.phaseEndRank, ts.newline, this.prevToken ); |
679 | 679 | break; |
680 | 680 | case TagTk: |
681 | 681 | case EndTagTk: |
682 | 682 | case SelfclosingTagTk: |
683 | | - res = this._transformTagToken( token, cb, this.phaseEndRank ); |
| 683 | + res = this._transformTagToken( token, this.phaseEndRank, this.prevToken ); |
684 | 684 | break; |
685 | 685 | default: |
686 | 686 | switch( token.type ) { |
687 | 687 | case 'COMMENT': |
688 | | - res = this._transformToken( token, cb, this.phaseEndRank, ts.comment ); |
| 688 | + res = this._transformToken( token, this.phaseEndRank, ts.comment, this.prevToken ); |
689 | 689 | break; |
690 | 690 | case 'END': |
691 | | - res = this._transformToken( token, cb, this.phaseEndRank, ts.end ); |
| 691 | + res = this._transformToken( token, this.phaseEndRank, ts.end, this.prevToken ); |
692 | 692 | break; |
693 | 693 | default: |
694 | | - res = this._transformToken( token, cb, this.phaseEndRank, ts.martian ); |
| 694 | + res = this._transformToken( token, this.phaseEndRank, ts.martian, this.prevToken ); |
695 | 695 | break; |
696 | 696 | } |
697 | 697 | } |
Index: trunk/extensions/VisualEditor/modules/parser/ext.core.TemplateHandler.js |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | * calls or sets up the callback to _expandTemplate, which then fetches and |
55 | 55 | * processes the template. |
56 | 56 | */ |
57 | | -TemplateHandler.prototype.onTemplate = function ( token, cb ) { |
| 57 | +TemplateHandler.prototype.onTemplate = function ( token, frame, cb ) { |
58 | 58 | //console.log('onTemplate! ' + JSON.stringify( token, null, 2 ) + |
59 | 59 | // ' args: ' + JSON.stringify( this.manager.args )); |
60 | 60 | |
— | — | @@ -353,7 +353,7 @@ |
354 | 354 | /** |
355 | 355 | * Expand template arguments with tokens from the containing frame. |
356 | 356 | */ |
357 | | -TemplateHandler.prototype.onTemplateArg = function ( token, cb, frame ) { |
| 357 | +TemplateHandler.prototype.onTemplateArg = function ( token, frame, cb ) { |
358 | 358 | |
359 | 359 | var attributes = [{k: token.argname, v: token.defaultvalue}]; |
360 | 360 | |
Index: trunk/extensions/VisualEditor/modules/parser/ext.core.PostExpandParagraphHandler.js |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | this.newlineRank, 'end' ); |
33 | 33 | }; |
34 | 34 | |
35 | | -PostExpandParagraphHandler.prototype.reset = function ( token, cb, frame, prevToken ) { |
| 35 | +PostExpandParagraphHandler.prototype.reset = function ( token, frame, cb ) { |
36 | 36 | //console.log( 'PostExpandParagraphHandler.reset ' + JSON.stringify( this.tokens ) ); |
37 | 37 | if ( this.newLines ) { |
38 | 38 | return { tokens: this._finish() }; |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | |
57 | 57 | // Handle NEWLINE tokens, which trigger the actual quote analysis on the |
58 | 58 | // collected quote tokens so far. |
59 | | -PostExpandParagraphHandler.prototype.onNewLine = function ( token, cb, frame, prevToken ) { |
| 59 | +PostExpandParagraphHandler.prototype.onNewLine = function ( token, frame, cb ) { |
60 | 60 | //console.log( 'PostExpandParagraphHandler.onNewLine: ' + JSON.stringify( token, null , 2 ) ); |
61 | 61 | var res; |
62 | 62 | this.tokens.push( token ); |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | }; |
72 | 72 | |
73 | 73 | |
74 | | -PostExpandParagraphHandler.prototype.onAny = function ( token, cb, frame, prevToken ) { |
| 74 | +PostExpandParagraphHandler.prototype.onAny = function ( token, frame, cb ) { |
75 | 75 | //console.log( 'PostExpandParagraphHandler.onAny' ); |
76 | 76 | this.tokens.push( token ); |
77 | 77 | if ( token.type === 'COMMENT' || |
Index: trunk/extensions/VisualEditor/modules/parser/ext.util.TokenCollector.js |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | * Handle the delimiter token. |
52 | 52 | * XXX: Adjust to sync phase callback when that is modified! |
53 | 53 | */ |
54 | | -TokenCollector.prototype._onDelimiterToken = function ( token, cb, frame ) { |
| 54 | +TokenCollector.prototype._onDelimiterToken = function ( token, frame, cb ) { |
55 | 55 | var res; |
56 | 56 | if ( this.isActive ) { |
57 | 57 | // finish processing |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | * encountering the delimiter token, and collects all tokens until the end |
95 | 95 | * token is reached. |
96 | 96 | */ |
97 | | -TokenCollector.prototype._onAnyToken = function ( token, cb, frame ) { |
| 97 | +TokenCollector.prototype._onAnyToken = function ( token, frame, cb ) { |
98 | 98 | // Simply collect anything ordinary in between |
99 | 99 | this.tokens.push( token ); |
100 | 100 | return { }; |