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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/* global ace */
ace.define( 'ace/mode/abusefilter_highlight_rules', [ 'require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text_highlight_rules' ], function ( require, exports ) {
'use strict';
var oop = require( 'ace/lib/oop' ),
TextHighlightRules = require( './text_highlight_rules' ).TextHighlightRules,
AFHighlightRules = function () {
var cfg = mw.config.get( 'aceConfig' ),
constants = ( 'true|false|null' ),
keywords = this.createKeywordMapper(
{
keyword: cfg.keywords,
'support.function': cfg.functions,
'constant.language': constants
},
// Null as default used in isKeywordOrVariable
null
),
variables = this.createKeywordMapper(
{
'variable.language': cfg.variables,
'invalid.deprecated': cfg.deprecated,
'invalid.illegal': cfg.disabled
},
'identifier',
true
),
isKeywordOrVariable = function ( value ) {
if ( keywords( value ) !== null ) {
return keywords( value );
} else {
return variables( value );
}
},
integer = '(?:(?:[1-9]\\d*)|(?:0))',
fraction = '(?:\\.\\d+)',
intPart = '(?:\\d+)',
pointFloat = '(?:(?:' + intPart + '?' + fraction + ')|(?:' + intPart + '\\.))',
floatNumber = '(?:' + pointFloat + ')',
singleQuoteString = '\'(?:[^\\\\]|\\\\.)*?\'',
doubleQuoteString = '"(?:[^\\\\]|\\\\.)*?"';
this.$rules = {
start: [ {
token: 'comment',
regex: '\\/\\*',
next: 'comment'
}, {
token: 'string',
regex: doubleQuoteString
}, {
token: 'string',
regex: singleQuoteString
}, {
token: 'constant.numeric',
regex: floatNumber
}, {
token: 'constant.numeric',
regex: integer + '\\b'
}, {
token: isKeywordOrVariable,
regex: '[a-zA-Z_][a-zA-Z0-9_]*\\b'
}, {
token: 'keyword.operator',
regex: cfg.operators
}, {
token: 'paren.lparen',
regex: '[\\[\\(]'
}, {
token: 'paren.rparen',
regex: '[\\]\\)]'
}, {
token: 'text',
regex: '\\s+|\\w+'
} ],
comment: [ {
token: 'comment',
regex: '\\*\\/',
next: 'start'
}, {
defaultToken: 'comment'
} ]
};
this.normalizeRules();
};
oop.inherits( AFHighlightRules, TextHighlightRules );
exports.AFHighlightRules = AFHighlightRules;
} );
ace.define( 'ace/mode/abusefilter', [ 'require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text', 'ace/mode/abusefilter_highlight_rules' ], function ( require, exports ) {
'use strict';
var oop = require( 'ace/lib/oop' ),
TextMode = require( './text' ).Mode,
AFHighlightRules = require( './abusefilter_highlight_rules' ).AFHighlightRules,
MatchingBraceOutdent = require( './matching_brace_outdent' ).MatchingBraceOutdent,
Mode = function () {
this.HighlightRules = AFHighlightRules;
this.$behaviour = this.$defaultBehaviour;
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits( Mode, TextMode );
( function () {
this.blockComment = {
start: '/*',
end: '*/'
};
this.getNextLineIndent = function ( state, line ) {
var indent = this.$getIndent( line );
return indent;
};
this.checkOutdent = function ( state, line, input ) {
return this.$outdent.checkOutdent( line, input );
};
this.autoOutdent = function ( state, doc, row ) {
this.$outdent.autoOutdent( doc, row );
};
this.$id = 'ace/mode/abusefilter';
} )
.call( Mode.prototype );
exports.Mode = Mode;
} );
|