aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexers/LexRuby.cxx
diff options
context:
space:
mode:
authorColomban Wendling <ban@herbesfolles.org>2014-07-29 15:10:52 +0200
committerColomban Wendling <ban@herbesfolles.org>2014-07-29 15:10:52 +0200
commitcb6f0efb028b1d30198ac1ae58ce89e581e17768 (patch)
tree35d07773e954c08b69cc71adc8f6b00aa1434d4c /lexers/LexRuby.cxx
parent932a9ff8d406af31d3db0161ca0fad5148d6f0a7 (diff)
downloadscintilla-mirror-cb6f0efb028b1d30198ac1ae58ce89e581e17768.tar.gz
Allow global/class/instance variables as Ruby symbol literals
See comments in bug [#1627] for some details.
Diffstat (limited to 'lexers/LexRuby.cxx')
-rw-r--r--lexers/LexRuby.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/lexers/LexRuby.cxx b/lexers/LexRuby.cxx
index 0fdbab7d1..b0b52fd77 100644
--- a/lexers/LexRuby.cxx
+++ b/lexers/LexRuby.cxx
@@ -882,6 +882,31 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
preferRE = false;
} else if (isSafeWordcharOrHigh(chNext)) {
state = SCE_RB_SYMBOL;
+ } else if ((chNext == '@' || chNext == '$') &&
+ isSafeWordcharOrHigh(chNext2)) {
+ // instance and global variable followed by an identifier
+ advance_char(i, ch, chNext, chNext2);
+ state = SCE_RB_SYMBOL;
+ } else if (((chNext == '@' && chNext2 == '@') ||
+ (chNext == '$' && chNext2 == '-')) &&
+ isSafeWordcharOrHigh(styler.SafeGetCharAt(i+3))) {
+ // class variables and special global variable "$-IDENTCHAR"
+ state = SCE_RB_SYMBOL;
+ // $-IDENTCHAR doesn't continue past the IDENTCHAR
+ if (chNext == '$') {
+ styler.ColourTo(i+3, SCE_RB_SYMBOL);
+ state = SCE_RB_DEFAULT;
+ }
+ i += 3;
+ chNext = styler.SafeGetCharAt(i+1);
+ chNext2 = styler.SafeGetCharAt(i+2);
+ } else if (chNext == '$' && strchr("_~*$?!@/\\;,.=:<>\"&`'+", chNext2)) {
+ // single-character special global variables
+ i += 2;
+ ch = chNext2;
+ chNext = styler.SafeGetCharAt(i+1);
+ styler.ColourTo(i, SCE_RB_SYMBOL);
+ state = SCE_RB_DEFAULT;
} else if (strchr("[*!~+-*/%=<>&^|", chNext)) {
// Do the operator analysis in-line, looking ahead
// Based on the table in pickaxe 2nd ed., page 339