2019-07-31 13:52:09 +00:00
|
|
|
/* global ace */
|
2018-08-22 09:11:44 +00:00
|
|
|
ace.define( 'ace/mode/abusefilter_highlight_rules', [ 'require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text_highlight_rules' ], function ( require, exports ) {
|
2018-03-30 06:55:03 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var oop = require( 'ace/lib/oop' ),
|
|
|
|
TextHighlightRules = require( './text_highlight_rules' ).TextHighlightRules,
|
|
|
|
AFHighlightRules = function () {
|
2018-06-27 18:05:52 +00:00
|
|
|
var cfg = mw.config.get( 'aceConfig' ),
|
2018-03-30 06:55:03 +00:00
|
|
|
constants = ( 'true|false|null' ),
|
2019-01-02 10:30:38 +00:00
|
|
|
keywords = this.createKeywordMapper(
|
2018-03-30 06:55:03 +00:00
|
|
|
{
|
2018-06-27 18:05:52 +00:00
|
|
|
keyword: cfg.keywords,
|
|
|
|
'support.function': cfg.functions,
|
2019-01-02 10:30:38 +00:00
|
|
|
'constant.language': constants
|
|
|
|
},
|
2019-03-29 09:44:02 +00:00
|
|
|
// Null as default used in isKeywordOrVariable
|
|
|
|
null
|
2019-01-02 10:30:38 +00:00
|
|
|
),
|
|
|
|
variables = this.createKeywordMapper(
|
|
|
|
{
|
2018-06-27 18:05:52 +00:00
|
|
|
'variable.language': cfg.variables,
|
|
|
|
'invalid.deprecated': cfg.deprecated,
|
|
|
|
'invalid.illegal': cfg.disabled
|
2018-03-30 06:55:03 +00:00
|
|
|
},
|
2019-01-02 10:30:38 +00:00
|
|
|
'identifier',
|
|
|
|
true
|
2018-03-30 06:55:03 +00:00
|
|
|
),
|
2019-03-29 09:44:02 +00:00
|
|
|
isKeywordOrVariable = function ( value ) {
|
|
|
|
if ( keywords( value ) !== null ) {
|
|
|
|
return keywords( value );
|
|
|
|
} else {
|
|
|
|
return variables( value );
|
|
|
|
}
|
|
|
|
},
|
2018-08-23 10:23:16 +00:00
|
|
|
integer = '(?:(?:[1-9]\\d*)|(?:0))',
|
2018-03-30 06:55:03 +00:00
|
|
|
fraction = '(?:\\.\\d+)',
|
|
|
|
intPart = '(?:\\d+)',
|
|
|
|
pointFloat = '(?:(?:' + intPart + '?' + fraction + ')|(?:' + intPart + '\\.))',
|
2018-06-27 18:05:52 +00:00
|
|
|
floatNumber = '(?:' + pointFloat + ')',
|
|
|
|
singleQuoteString = '\'(?:[^\\\\]|\\\\.)*?\'',
|
|
|
|
doubleQuoteString = '"(?:[^\\\\]|\\\\.)*?"';
|
2018-03-30 06:55:03 +00:00
|
|
|
|
|
|
|
this.$rules = {
|
2018-08-22 09:11:44 +00:00
|
|
|
start: [ {
|
2018-03-30 06:55:03 +00:00
|
|
|
token: 'comment',
|
|
|
|
regex: '\\/\\*',
|
|
|
|
next: 'comment'
|
|
|
|
}, {
|
2018-06-27 18:05:52 +00:00
|
|
|
token: 'string',
|
|
|
|
regex: doubleQuoteString
|
2018-03-30 06:55:03 +00:00
|
|
|
}, {
|
2018-06-27 18:05:52 +00:00
|
|
|
token: 'string',
|
|
|
|
regex: singleQuoteString
|
2018-03-30 06:55:03 +00:00
|
|
|
}, {
|
2018-08-23 10:23:16 +00:00
|
|
|
token: 'constant.numeric',
|
2018-03-30 06:55:03 +00:00
|
|
|
regex: floatNumber
|
|
|
|
}, {
|
2018-08-23 10:23:16 +00:00
|
|
|
token: 'constant.numeric',
|
2018-03-30 06:55:03 +00:00
|
|
|
regex: integer + '\\b'
|
|
|
|
}, {
|
2019-03-29 09:44:02 +00:00
|
|
|
token: isKeywordOrVariable,
|
2018-06-27 18:05:52 +00:00
|
|
|
regex: '[a-zA-Z_][a-zA-Z0-9_]*\\b'
|
2018-03-30 06:55:03 +00:00
|
|
|
}, {
|
|
|
|
token: 'keyword.operator',
|
2018-06-27 18:05:52 +00:00
|
|
|
regex: cfg.operators
|
2018-03-30 06:55:03 +00:00
|
|
|
}, {
|
|
|
|
token: 'paren.lparen',
|
|
|
|
regex: '[\\[\\(]'
|
|
|
|
}, {
|
|
|
|
token: 'paren.rparen',
|
|
|
|
regex: '[\\]\\)]'
|
|
|
|
}, {
|
|
|
|
token: 'text',
|
|
|
|
regex: '\\s+|\\w+'
|
|
|
|
} ],
|
2018-08-22 09:11:44 +00:00
|
|
|
comment: [ {
|
2018-03-30 06:55:03 +00:00
|
|
|
token: 'comment',
|
|
|
|
regex: '\\*\\/',
|
|
|
|
next: 'start'
|
|
|
|
}, {
|
|
|
|
defaultToken: 'comment'
|
|
|
|
} ]
|
|
|
|
};
|
|
|
|
|
|
|
|
this.normalizeRules();
|
|
|
|
};
|
|
|
|
|
|
|
|
oop.inherits( AFHighlightRules, TextHighlightRules );
|
|
|
|
|
|
|
|
exports.AFHighlightRules = AFHighlightRules;
|
|
|
|
} );
|
|
|
|
|
2018-08-22 09:11:44 +00:00
|
|
|
ace.define( 'ace/mode/abusefilter', [ 'require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text', 'ace/mode/abusefilter_highlight_rules' ], function ( require, exports ) {
|
2018-03-30 06:55:03 +00:00
|
|
|
'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: '*/'
|
|
|
|
};
|
2018-08-22 09:11:44 +00:00
|
|
|
this.getNextLineIndent = function ( state, line ) {
|
2018-03-30 06:55:03 +00:00
|
|
|
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;
|
|
|
|
} );
|