In the AF language,
```
foo := "abc
def"
```
declares a valid string with a linebreak inside. This wasn't previously
highlighted by ace, since normal rules are scanned line-by-line. The
code added here is essentially copied from the PHP highlighter [1],
whose rules should be almost the same as AF.
This new syntax also highlights escape sequences inside strings, e.g. in
"foo\\bar" see how the backslashes have a different color.
[1] - https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/php_highlight_rules.js#L1058
Change-Id: Idb51001af00ff2ef118741cd686dc1adf19aebee
The worker itself is essentially a wrapper around the
abusefilterchecksyntax API.
NOTE: As written in code comments, basically the whole
worker-abusefilter.js script consists of boilerplate code. You can
verify this by diffing this file and 6cb8a9cae1/modules/ace/worker-json.js
This means that there are only ~60 lines of code to review in that file.
Bug: T187686
Change-Id: I8950fcd5917ba226dda80b47b2bb713e685fad36
Short explanation on phab. Ace stops at the first regex match, so we
must use a function to specify the token type.
Bug: T219593
Change-Id: If7e6e98de81ce7e1be334732518425c8115e4aea
The uppercase is just a leftover from a long time ago. Currently,
variables are case-insensitive, and we already perform a strtolower when
saving them. Since most parts of the code already use lowercase, the
uppercase leftovers only make it harder to grep the code to find
variables. As a bonus, make Ace recognize variables in a
case-insensitive fashion.
Change-Id: I72933fcc9952fc1aabf6464b2fc0b04ec39c024b
Fixed some comments adding explanations, fixing syntax, and parameter types
for docblocks. Also fixed some whitespace mess, and added a missing use
statement.
Change-Id: I3547c90bdaa2cab5443e8bf0c63b217fe6ba663f
Several improvements, this is the list:
*Added highlighting for disabled and deprecated variables
*Simplified a bit Ace's keyword mapper
*Added highlighting for ternary operator
*Added logic to retrieve operators from AF tokenizer
*Removed $ symbol since it's not usable in declaring stuff
*Customized highlighting via CSS
Depends-On: I5c370b54e6516889624088e27928ad3a1f48a821
Change-Id: If95e34fc7260413c4fb39c18a1ef44f5a93e1a68
We already do it for variables and functions, so that any new feature
won't need the ace files to be edited. I originally didn't implement it
for keywords too, but it's actually much better this way.
Change-Id: I1ee81feace2ea90d5dbb2e443f01bc0f6cf74eb7
Replace the conditions textarea with Ace editor for editing and testing
filter. This uses a soft dependency on CodeEditor; if the latter isn't
installed, the classic textarea is used. The user is still able to
switch between the editors on the go; the new buttons may look a bit
ugly now, but after switching to OOUI they should get much better.
Finally, added a custom syntax highlight for AbuseFilter rules.
Bug: T39192
Change-Id: If3d6a994142e34686bb7fc9f09093f751b599485