summaryrefslogtreecommitdiffstats
path: root/scintilla/lexers/LexRuby.cxx
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2015-03-07 12:05:41 +0200
committerXhmikosR <xhmikosr@gmail.com>2015-03-09 08:44:41 +0200
commit4ac30880a3dd4769bb5f1287e90aa0db9ede212c (patch)
tree7d237930bb68fc714efc6945eae98ae7df3f6dbe /scintilla/lexers/LexRuby.cxx
parent12949f79fc6487022b0ffea17dd9eadd43d5b1c0 (diff)
downloadnotepad2-mod-4ac30880a3dd4769bb5f1287e90aa0db9ede212c.zip
notepad2-mod-4ac30880a3dd4769bb5f1287e90aa0db9ede212c.tar.gz
notepad2-mod-4ac30880a3dd4769bb5f1287e90aa0db9ede212c.tar.bz2
Update Scintilla to v3.5.4.4.2.25.945
Diffstat (limited to 'scintilla/lexers/LexRuby.cxx')
-rw-r--r--scintilla/lexers/LexRuby.cxx805
1 files changed, 415 insertions, 390 deletions
diff --git a/scintilla/lexers/LexRuby.cxx b/scintilla/lexers/LexRuby.cxx
index bb45c75..7918d4b 100644
--- a/scintilla/lexers/LexRuby.cxx
+++ b/scintilla/lexers/LexRuby.cxx
@@ -29,7 +29,7 @@ using namespace Scintilla;
//XXX Identical to Perl, put in common area
static inline bool isEOLChar(char ch) {
- return (ch == '\r') || (ch == '\n');
+ return (ch == '\r') || (ch == '\n');
}
#define isSafeASCII(ch) ((unsigned int)(ch) <= 127)
@@ -60,7 +60,7 @@ static inline bool isSafeWordcharOrHigh(char ch) {
}
static bool inline iswhitespace(char ch) {
- return ch == ' ' || ch == '\t';
+ return ch == ' ' || ch == '\t';
}
#define MAX_KEYWORD_LENGTH 200
@@ -74,20 +74,20 @@ static bool followsDot(unsigned int pos, Accessor &styler) {
int style = actual_style(styler.StyleAt(pos));
char ch;
switch (style) {
- case SCE_RB_DEFAULT:
- ch = styler[pos];
- if (ch == ' ' || ch == '\t') {
- //continue
- } else {
- return false;
- }
- break;
+ case SCE_RB_DEFAULT:
+ ch = styler[pos];
+ if (ch == ' ' || ch == '\t') {
+ //continue
+ } else {
+ return false;
+ }
+ break;
- case SCE_RB_OPERATOR:
- return styler[pos] == '.';
+ case SCE_RB_OPERATOR:
+ return styler[pos] == '.';
- default:
- return false;
+ default:
+ return false;
}
}
return false;
@@ -102,26 +102,26 @@ static bool keywordIsModifier(const char *word,
Accessor &styler);
static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
- char s[MAX_KEYWORD_LENGTH];
+ char s[MAX_KEYWORD_LENGTH];
unsigned int i, j;
- unsigned int lim = end - start + 1; // num chars to copy
- if (lim >= MAX_KEYWORD_LENGTH) {
- lim = MAX_KEYWORD_LENGTH - 1;
- }
- for (i = start, j = 0; j < lim; i++, j++) {
- s[j] = styler[i];
- }
+ unsigned int lim = end - start + 1; // num chars to copy
+ if (lim >= MAX_KEYWORD_LENGTH) {
+ lim = MAX_KEYWORD_LENGTH - 1;
+ }
+ for (i = start, j = 0; j < lim; i++, j++) {
+ s[j] = styler[i];
+ }
s[j] = '\0';
- int chAttr;
- if (0 == strcmp(prevWord, "class"))
- chAttr = SCE_RB_CLASSNAME;
- else if (0 == strcmp(prevWord, "module"))
- chAttr = SCE_RB_MODULE_NAME;
- else if (0 == strcmp(prevWord, "def"))
- chAttr = SCE_RB_DEFNAME;
+ int chAttr;
+ if (0 == strcmp(prevWord, "class"))
+ chAttr = SCE_RB_CLASSNAME;
+ else if (0 == strcmp(prevWord, "module"))
+ chAttr = SCE_RB_MODULE_NAME;
+ else if (0 == strcmp(prevWord, "def"))
+ chAttr = SCE_RB_DEFNAME;
else if (keywords.InList(s) && ((start == 0) || !followsDot(start - 1, styler))) {
if (keywordIsAmbiguous(s)
- && keywordIsModifier(s, start, styler)) {
+ && keywordIsModifier(s, start, styler)) {
// Demoted keywords are colored as keywords,
// but do not affect changes in indentation.
@@ -136,37 +136,37 @@ static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywor
} else {
chAttr = SCE_RB_WORD;
}
- } else
+ } else
chAttr = SCE_RB_IDENTIFIER;
- styler.ColourTo(end, chAttr);
- if (chAttr == SCE_RB_WORD) {
- strcpy(prevWord, s);
- } else {
- prevWord[0] = 0;
- }
+ styler.ColourTo(end, chAttr);
+ if (chAttr == SCE_RB_WORD) {
+ strcpy(prevWord, s);
+ } else {
+ prevWord[0] = 0;
+ }
return chAttr;
}
//XXX Identical to Perl, put in common area
static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
- if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
- return false;
- }
- while (*val) {
- if (*val != styler[pos++]) {
- return false;
- }
- val++;
- }
- return true;
+ if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
+ return false;
+ }
+ while (*val) {
+ if (*val != styler[pos++]) {
+ return false;
+ }
+ val++;
+ }
+ return true;
}
// Do Ruby better -- find the end of the line, work back,
// and then check for leading white space
// Precondition: the here-doc target can be indented
-static bool lookingAtHereDocDelim(Accessor &styler,
+static bool lookingAtHereDocDelim(Accessor &styler,
int pos,
int lengthDoc,
const char *HereDocDelim)
@@ -187,15 +187,15 @@ static bool lookingAtHereDocDelim(Accessor &styler,
//XXX Identical to Perl, put in common area
static char opposite(char ch) {
- if (ch == '(')
- return ')';
- if (ch == '[')
- return ']';
- if (ch == '{')
- return '}';
- if (ch == '<')
- return '>';
- return ch;
+ if (ch == '(')
+ return ')';
+ if (ch == '[')
+ return ']';
+ if (ch == '{')
+ return '}';
+ if (ch == '<')
+ return '>';
+ return ch;
}
// Null transitions when we see we've reached the end
@@ -216,7 +216,7 @@ static void advance_char(int &i, char &ch, char &chNext, char &chNext2) {
}
// precondition: startPos points to one after the EOL char
-static bool currLineContainsHereDelims(int& startPos,
+static bool currLineContainsHereDelims(int &startPos,
Accessor &styler) {
if (startPos <= 1)
return false;
@@ -249,7 +249,7 @@ static bool currLineContainsHereDelims(int& startPos,
// to be hoisted out of the function.
class QuoteCls {
- public:
+public:
int Count;
char Up;
char Down;
@@ -266,19 +266,19 @@ class QuoteCls {
Up = u;
Down = opposite(Up);
}
- QuoteCls(const QuoteCls& q) {
+ QuoteCls(const QuoteCls &q) {
// copy constructor -- use this for copying in
Count = q.Count;
Up = q.Up;
Down = q.Down;
}
- QuoteCls& operator=(const QuoteCls& q) { // assignment constructor
+ QuoteCls &operator=(const QuoteCls &q) { // assignment constructor
if (this != &q) {
Count = q.Count;
Up = q.Up;
Down = q.Down;
}
- return *this;
+ return *this;
}
};
@@ -287,11 +287,11 @@ class QuoteCls {
static void enterInnerExpression(int *p_inner_string_types,
int *p_inner_expn_brace_counts,
QuoteCls *p_inner_quotes,
- int& inner_string_count,
- int& state,
- int& brace_counts,
+ int &inner_string_count,
+ int &state,
+ int &brace_counts,
QuoteCls curr_quote
- ) {
+ ) {
p_inner_string_types[inner_string_count] = state;
state = SCE_RB_DEFAULT;
p_inner_expn_brace_counts[inner_string_count] = brace_counts;
@@ -301,13 +301,13 @@ static void enterInnerExpression(int *p_inner_string_types,
}
static void exitInnerExpression(int *p_inner_string_types,
- int *p_inner_expn_brace_counts,
- QuoteCls *p_inner_quotes,
- int& inner_string_count,
- int& state,
- int& brace_counts,
- QuoteCls& curr_quote
- ) {
+ int *p_inner_expn_brace_counts,
+ QuoteCls *p_inner_quotes,
+ int &inner_string_count,
+ int &state,
+ int &brace_counts,
+ QuoteCls &curr_quote
+ ) {
--inner_string_count;
state = p_inner_string_types[inner_string_count];
brace_counts = p_inner_expn_brace_counts[inner_string_count];
@@ -316,28 +316,28 @@ static void exitInnerExpression(int *p_inner_string_types,
static bool isEmptyLine(int pos,
Accessor &styler) {
- int spaceFlags = 0;
- int lineCurrent = styler.GetLine(pos);
- int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
+ int spaceFlags = 0;
+ int lineCurrent = styler.GetLine(pos);
+ int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
return (indentCurrent & SC_FOLDLEVELWHITEFLAG) != 0;
}
static bool RE_CanFollowKeyword(const char *keyword) {
if (!strcmp(keyword, "and")
- || !strcmp(keyword, "begin")
- || !strcmp(keyword, "break")
- || !strcmp(keyword, "case")
- || !strcmp(keyword, "do")
- || !strcmp(keyword, "else")
- || !strcmp(keyword, "elsif")
- || !strcmp(keyword, "if")
- || !strcmp(keyword, "next")
- || !strcmp(keyword, "return")
- || !strcmp(keyword, "when")
- || !strcmp(keyword, "unless")
- || !strcmp(keyword, "until")
- || !strcmp(keyword, "not")
- || !strcmp(keyword, "or")) {
+ || !strcmp(keyword, "begin")
+ || !strcmp(keyword, "break")
+ || !strcmp(keyword, "case")
+ || !strcmp(keyword, "do")
+ || !strcmp(keyword, "else")
+ || !strcmp(keyword, "elsif")
+ || !strcmp(keyword, "if")
+ || !strcmp(keyword, "next")
+ || !strcmp(keyword, "return")
+ || !strcmp(keyword, "when")
+ || !strcmp(keyword, "unless")
+ || !strcmp(keyword, "until")
+ || !strcmp(keyword, "not")
+ || !strcmp(keyword, "or")) {
return true;
}
return false;
@@ -347,8 +347,8 @@ static bool RE_CanFollowKeyword(const char *keyword) {
// Don't look at styles in case we're looking forward
static int skipWhitespace(int startPos,
- int endPos,
- Accessor &styler) {
+ int endPos,
+ Accessor &styler) {
for (int i = startPos; i < endPos; i++) {
if (!iswhitespace(styler[i])) {
return i;
@@ -378,8 +378,8 @@ static bool sureThisIsHeredoc(int iPrev,
int firstWordPosn = skipWhitespace(lineStartPosn, iPrev, styler);
if (firstWordPosn >= iPrev) {
// Have something like {^ <<}
- //XXX Look at the first previous non-comment non-white line
- // to establish the context. Not too likely though.
+ //XXX Look at the first previous non-comment non-white line
+ // to establish the context. Not too likely though.
return true;
} else {
switch (prevStyle = styler.StyleAt(firstWordPosn)) {
@@ -395,7 +395,7 @@ static bool sureThisIsHeredoc(int iPrev,
char *dst = prevWord;
for (;;) {
if (firstWordEndPosn >= iPrev ||
- styler.StyleAt(firstWordEndPosn) != prevStyle) {
+ styler.StyleAt(firstWordEndPosn) != prevStyle) {
*dst = 0;
break;
}
@@ -404,8 +404,8 @@ static bool sureThisIsHeredoc(int iPrev,
}
//XXX Write a style-aware thing to regex scintilla buffer objects
if (!strcmp(prevWord, "undef")
- || !strcmp(prevWord, "def")
- || !strcmp(prevWord, "alias")) {
+ || !strcmp(prevWord, "def")
+ || !strcmp(prevWord, "alias")) {
// These keywords are what we were looking for
return false;
}
@@ -424,8 +424,8 @@ static bool haveTargetMatch(int currPos,
}
int i, j;
for (i = targetStartPos, j = currPos;
- i < targetEndPos && j < lengthDoc;
- i++, j++) {
+ i < targetEndPos && j < lengthDoc;
+ i++, j++) {
if (styler[i] != styler[j]) {
return false;
}
@@ -450,7 +450,7 @@ static bool haveTargetMatch(int currPos,
static bool sureThisIsNotHeredoc(int lt2StartPos,
Accessor &styler) {
int prevStyle;
- // Use full document, not just part we're styling
+ // Use full document, not just part we're styling
int lengthDoc = styler.Length();
int lineStart = styler.GetLine(lt2StartPos);
int lineStartPosn = styler.LineStart(lineStart);
@@ -466,8 +466,8 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
prevStyle = styler.StyleAt(firstWordPosn);
// If we have '<<' following a keyword, it's not a heredoc
if (prevStyle != SCE_RB_IDENTIFIER
- && prevStyle != SCE_RB_INSTANCE_VAR
- && prevStyle != SCE_RB_CLASS_VAR) {
+ && prevStyle != SCE_RB_INSTANCE_VAR
+ && prevStyle != SCE_RB_CLASS_VAR) {
return definitely_not_a_here_doc;
}
int newStyle = prevStyle;
@@ -508,7 +508,7 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
return definitely_not_a_here_doc;
}
// OK, now 'j' will point to the current spot moving ahead
- int j = firstWordPosn + 1;
+ int j = firstWordPosn + 1;
if (styler.StyleAt(j) != SCE_RB_OPERATOR || styler[j] != '<') {
// This shouldn't happen
return definitely_not_a_here_doc;
@@ -560,10 +560,10 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
// don't handle arbitrary expressions yet
target_end = j;
- if (target_quote) {
- // Now we can move to the character after the string delimiter.
- j += 1;
- }
+ if (target_quote) {
+ // Now we can move to the character after the string delimiter.
+ j += 1;
+ }
j = skipWhitespace(j, lengthDoc, styler);
if (j >= lengthDoc) {
return definitely_not_a_here_doc;
@@ -604,7 +604,7 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
// move to the start of the first line that is not in a
// multi-line construct
-static void synchronizeDocStart(unsigned int& startPos,
+static void synchronizeDocStart(unsigned int &startPos,
int &length,
int &initStyle,
Accessor &styler,
@@ -613,11 +613,11 @@ static void synchronizeDocStart(unsigned int& startPos,
styler.Flush();
int style = actual_style(styler.StyleAt(startPos));
switch (style) {
- case SCE_RB_STDIN:
- case SCE_RB_STDOUT:
- case SCE_RB_STDERR:
- // Don't do anything else with these.
- return;
+ case SCE_RB_STDIN:
+ case SCE_RB_STDOUT:
+ case SCE_RB_STDERR:
+ // Don't do anything else with these.
+ return;
}
int pos = startPos;
@@ -655,66 +655,67 @@ static void synchronizeDocStart(unsigned int& startPos,
}
static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler) {
- // Lexer for Ruby often has to backtrack to start of current style to determine
- // which characters are being used as quotes, how deeply nested is the
- // start position and what the termination string is for here documents
+ // Lexer for Ruby often has to backtrack to start of current style to determine
+ // which characters are being used as quotes, how deeply nested is the
+ // start position and what the termination string is for here documents
- WordList &keywords = *keywordlists[0];
+ WordList &keywords = *keywordlists[0];
- class HereDocCls {
- public:
- int State;
+ class HereDocCls {
+ public:
+ int State;
// States
// 0: '<<' encountered
- // 1: collect the delimiter
+ // 1: collect the delimiter
// 1b: text between the end of the delimiter and the EOL
- // 2: here doc text (lines after the delimiter)
- char Quote; // the char after '<<'
- bool Quoted; // true if Quote in ('\'','"','`')
- int DelimiterLength; // strlen(Delimiter)
- char Delimiter[256]; // the Delimiter, limit of 256: from Perl
+ // 2: here doc text (lines after the delimiter)
+ char Quote; // the char after '<<'
+ bool Quoted; // true if Quote in ('\'','"','`')
+ int DelimiterLength; // strlen(Delimiter)
+ char Delimiter[256]; // the Delimiter, limit of 256: from Perl
bool CanBeIndented;
- HereDocCls() {
- State = 0;
- DelimiterLength = 0;
- Delimiter[0] = '\0';
+ HereDocCls() {
+ State = 0;
+ DelimiterLength = 0;
+ Delimiter[0] = '\0';
CanBeIndented = false;
- }
- };
- HereDocCls HereDoc;
+ }
+ };
+ HereDocCls HereDoc;
- QuoteCls Quote;
+ QuoteCls Quote;
int numDots = 0; // For numbers --
- // Don't start lexing in the middle of a num
+ // Don't start lexing in the middle of a num
synchronizeDocStart(startPos, length, initStyle, styler, // ref args
false);
- bool preferRE = true;
+ bool preferRE = true;
int state = initStyle;
- int lengthDoc = startPos + length;
+ int lengthDoc = startPos + length;
- char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
- prevWord[0] = '\0';
- if (length == 0)
- return;
+ char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
+ prevWord[0] = '\0';
+ if (length == 0)
+ return;
- char chPrev = styler.SafeGetCharAt(startPos - 1);
- char chNext = styler.SafeGetCharAt(startPos);
- bool is_real_number = true; // Differentiate between constants and ?-sequences.
- styler.StartAt(startPos);
- styler.StartSegment(startPos);
+ char chPrev = styler.SafeGetCharAt(startPos - 1);
+ char chNext = styler.SafeGetCharAt(startPos);
+ bool is_real_number = true; // Differentiate between constants and ?-sequences.
+ styler.StartAt(startPos);
+ styler.StartSegment(startPos);
static int q_states[] = {SCE_RB_STRING_Q,
SCE_RB_STRING_QQ,
SCE_RB_STRING_QR,
SCE_RB_STRING_QW,
SCE_RB_STRING_QW,
- SCE_RB_STRING_QX};
- static const char* q_chars = "qQrwWx";
+ SCE_RB_STRING_QX
+ };
+ static const char *q_chars = "qQrwWx";
// In most cases a value of 2 should be ample for the code in the
// Ruby library, and the code the user is likely to enter.
@@ -743,113 +744,113 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
int brace_counts = 0; // Number of #{ ... } things within an expression
int i;
- for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) {
+ for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) {
inner_string_types[i] = 0;
inner_expn_brace_counts[i] = 0;
}
- for (i = startPos; i < lengthDoc; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
- char chNext2 = styler.SafeGetCharAt(i + 2);
+ for (i = startPos; i < lengthDoc; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ char chNext2 = styler.SafeGetCharAt(i + 2);
if (styler.IsLeadByte(ch)) {
- chNext = chNext2;
- chPrev = ' ';
- i += 1;
- continue;
- }
+ chNext = chNext2;
+ chPrev = ' ';
+ i += 1;
+ continue;
+ }
// skip on DOS/Windows
//No, don't, because some things will get tagged on,
// so we won't recognize keywords, for example
#if 0
- if (ch == '\r' && chNext == '\n') {
- continue;
+ if (ch == '\r' && chNext == '\n') {
+ continue;
}
#endif
if (HereDoc.State == 1 && isEOLChar(ch)) {
- // Begin of here-doc (the line after the here-doc delimiter):
- HereDoc.State = 2;
- styler.ColourTo(i-1, state);
+ // Begin of here-doc (the line after the here-doc delimiter):
+ HereDoc.State = 2;
+ styler.ColourTo(i-1, state);
// Don't check for a missing quote, just jump into
// the here-doc state
state = SCE_RB_HERE_Q;
}
// Regular transitions
- if (state == SCE_RB_DEFAULT) {
+ if (state == SCE_RB_DEFAULT) {
if (isSafeDigit(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_NUMBER;
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_NUMBER;
is_real_number = true;
numDots = 0;
} else if (isHighBitChar(ch) || iswordstart(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_WORD;
- } else if (ch == '#') {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_COMMENTLINE;
- } else if (ch == '=') {
- // =begin indicates the start of a comment (doc) block
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_WORD;
+ } else if (ch == '#') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_COMMENTLINE;
+ } else if (ch == '=') {
+ // =begin indicates the start of a comment (doc) block
if ((i == 0 || isEOLChar(chPrev))
- && chNext == 'b'
- && styler.SafeGetCharAt(i + 2) == 'e'
- && styler.SafeGetCharAt(i + 3) == 'g'
- && styler.SafeGetCharAt(i + 4) == 'i'
- && styler.SafeGetCharAt(i + 5) == 'n'
- && !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6))) {
+ && chNext == 'b'
+ && styler.SafeGetCharAt(i + 2) == 'e'
+ && styler.SafeGetCharAt(i + 3) == 'g'
+ && styler.SafeGetCharAt(i + 4) == 'i'
+ && styler.SafeGetCharAt(i + 5) == 'n'
+ && !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6))) {
styler.ColourTo(i - 1, state);
state = SCE_RB_POD;
- } else {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_RB_OPERATOR);
- preferRE = true;
- }
- } else if (ch == '"') {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_STRING;
- Quote.New();
- Quote.Open(ch);
- } else if (ch == '\'') {
+ } else {
+ styler.ColourTo(i - 1, state);
+ styler.ColourTo(i, SCE_RB_OPERATOR);
+ preferRE = true;
+ }
+ } else if (ch == '"') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_STRING;
+ Quote.New();
+ Quote.Open(ch);
+ } else if (ch == '\'') {
styler.ColourTo(i - 1, state);
state = SCE_RB_CHARACTER;
Quote.New();
Quote.Open(ch);
- } else if (ch == '`') {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_BACKTICKS;
- Quote.New();
- Quote.Open(ch);
- } else if (ch == '@') {
+ } else if (ch == '`') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_BACKTICKS;
+ Quote.New();
+ Quote.Open(ch);
+ } else if (ch == '@') {
// Instance or class var
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
if (chNext == '@') {
state = SCE_RB_CLASS_VAR;
advance_char(i, ch, chNext, chNext2); // pass by ref
} else {
state = SCE_RB_INSTANCE_VAR;
}
- } else if (ch == '$') {
+ } else if (ch == '$') {
// Check for a builtin global
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
// Recognize it bit by bit
state = SCE_RB_GLOBAL;
} else if (ch == '/' && preferRE) {
// Ambigous operator
- styler.ColourTo(i - 1, state);
- state = SCE_RB_REGEX;
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_REGEX;
Quote.New();
Quote.Open(ch);
- } else if (ch == '<' && chNext == '<' && chNext2 != '=') {
+ } else if (ch == '<' && chNext == '<' && chNext2 != '=') {
// Recognise the '<<' symbol - either a here document or a binary op
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
i++;
chNext = chNext2;
- styler.ColourTo(i, SCE_RB_OPERATOR);
+ styler.ColourTo(i, SCE_RB_OPERATOR);
- if (! (strchr("\"\'`_-", chNext2) || isSafeAlpha(chNext2))) {
+ if (!(strchr("\"\'`_-", chNext2) || isSafeAlpha(chNext2))) {
// It's definitely not a here-doc,
// based on Ruby's lexer/parser in the
// heredoc_identifier routine.
@@ -873,17 +874,17 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
}
preferRE = (state != SCE_RB_HERE_DELIM);
} else if (ch == ':') {
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
if (chNext == ':') {
// Mark "::" as an operator, not symbol start
styler.ColourTo(i + 1, SCE_RB_OPERATOR);
advance_char(i, ch, chNext, chNext2); // pass by ref
state = SCE_RB_DEFAULT;
- preferRE = false;
+ preferRE = false;
} else if (isSafeWordcharOrHigh(chNext)) {
- state = SCE_RB_SYMBOL;
+ state = SCE_RB_SYMBOL;
} else if ((chNext == '@' || chNext == '$') &&
- isSafeWordcharOrHigh(chNext2)) {
+ isSafeWordcharOrHigh(chNext2)) {
// instance and global variable followed by an identifier
advance_char(i, ch, chNext, chNext2);
state = SCE_RB_SYMBOL;
@@ -913,7 +914,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
bool doColoring = true;
switch (chNext) {
case '[':
- if (chNext2 == ']' ) {
+ if (chNext2 == ']') {
char ch_tmp = styler.SafeGetCharAt(i + 3);
if (ch_tmp == '=') {
i += 3;
@@ -979,11 +980,11 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
styler.ColourTo(i, SCE_RB_SYMBOL);
state = SCE_RB_DEFAULT;
}
- } else if (!preferRE) {
- // Don't color symbol strings (yet)
- // Just color the ":" and color rest as string
- styler.ColourTo(i, SCE_RB_SYMBOL);
- state = SCE_RB_DEFAULT;
+ } else if (!preferRE) {
+ // Don't color symbol strings (yet)
+ // Just color the ":" and color rest as string
+ styler.ColourTo(i, SCE_RB_SYMBOL);
+ state = SCE_RB_DEFAULT;
} else {
styler.ColourTo(i, SCE_RB_OPERATOR);
state = SCE_RB_DEFAULT;
@@ -1000,7 +1001,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
Quote.Open(chNext2);
i += 2;
ch = chNext2;
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = styler.SafeGetCharAt(i + 1);
have_string = true;
}
} else if (preferRE && !isSafeWordcharOrHigh(chNext)) {
@@ -1036,8 +1037,8 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
is_real_number = false;
}
} else if (isoperator(ch) || ch == '.') {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_RB_OPERATOR);
+ styler.ColourTo(i - 1, state);
+ styler.ColourTo(i, SCE_RB_OPERATOR);
// If we're ending an expression or block,
// assume it ends an object, and the ambivalent
// constructs are binary operators
@@ -1064,7 +1065,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
} else if (isEOLChar(ch)) {
// Make sure it's a true line-end, with no backslash
if ((ch == '\r' || (ch == '\n' && chPrev != '\r'))
- && chPrev != '\\') {
+ && chPrev != '\\') {
// Assume we've hit the end of the statement.
preferRE = true;
}
@@ -1079,11 +1080,11 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// but we don't for now.
if (ch == '='
- && isSafeWordcharOrHigh(chPrev)
- && (chNext == '('
- || strchr(" \t\n\r", chNext) != NULL)
- && (!strcmp(prevWord, "def")
- || followsDot(styler.GetStartSegment(), styler))) {
+ && isSafeWordcharOrHigh(chPrev)
+ && (chNext == '('
+ || strchr(" \t\n\r", chNext) != NULL)
+ && (!strcmp(prevWord, "def")
+ || followsDot(styler.GetStartSegment(), styler))) {
// <name>= is a name only when being def'd -- Get it the next time
// This means that <name>=<name> is always lexed as
// <name>, (op, =), <name>
@@ -1102,28 +1103,28 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// No need to handle this state -- we'll just move to the end
preferRE = false;
} else {
- int wordStartPos = styler.GetStartSegment();
+ int wordStartPos = styler.GetStartSegment();
int word_style = ClassifyWordRb(wordStartPos, i - 1, keywords, styler, prevWord);
switch (word_style) {
- case SCE_RB_WORD:
- preferRE = RE_CanFollowKeyword(prevWord);
- break;
+ case SCE_RB_WORD:
+ preferRE = RE_CanFollowKeyword(prevWord);
+ break;
- case SCE_RB_WORD_DEMOTED:
- preferRE = true;
- break;
+ case SCE_RB_WORD_DEMOTED:
+ preferRE = true;
+ break;
- case SCE_RB_IDENTIFIER:
- if (isMatch(styler, lengthDoc, wordStartPos, "print")) {
- preferRE = true;
- } else if (isEOLChar(ch)) {
- preferRE = true;
- } else {
- preferRE = false;
- }
- break;
- default:
+ case SCE_RB_IDENTIFIER:
+ if (isMatch(styler, lengthDoc, wordStartPos, "print")) {
+ preferRE = true;
+ } else if (isEOLChar(ch)) {
+ preferRE = true;
+ } else {
preferRE = false;
+ }
+ break;
+ default:
+ preferRE = false;
}
if (ch == '.') {
// We might be redefining an operator-method
@@ -1178,7 +1179,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
preferRE = false;
}
} else if (state == SCE_RB_COMMENTLINE) {
- if (isEOLChar(ch)) {
+ if (isEOLChar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_RB_DEFAULT;
// Use whatever setting we had going into the comment
@@ -1188,8 +1189,8 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// Slightly different: if we find an immediate '-',
// the target can appear indented.
- if (HereDoc.State == 0) { // '<<' encountered
- HereDoc.State = 1;
+ if (HereDoc.State == 0) { // '<<' encountered
+ HereDoc.State = 1;
HereDoc.DelimiterLength = 0;
if (ch == '-') {
HereDoc.CanBeIndented = true;
@@ -1214,7 +1215,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
HereDoc.DelimiterLength = 1;
}
}
- } else if (HereDoc.State == 1) { // collect the delimiter
+ } else if (HereDoc.State == 1) { // collect the delimiter
if (isEOLChar(ch)) {
// End the quote now, and go back for more
styler.ColourTo(i - 1, state);
@@ -1223,32 +1224,32 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
chNext = ch;
preferRE = false;
} else if (HereDoc.Quoted) {
- if (ch == HereDoc.Quote) { // closing quote => end of delimiter
- styler.ColourTo(i, state);
- state = SCE_RB_DEFAULT;
+ if (ch == HereDoc.Quote) { // closing quote => end of delimiter
+ styler.ColourTo(i, state);
+ state = SCE_RB_DEFAULT;
preferRE = false;
} else {
- if (ch == '\\' && !isEOLChar(chNext)) {
+ if (ch == '\\' && !isEOLChar(chNext)) {
advance_char(i, ch, chNext, chNext2);
- }
- HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
- HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+ }
+ HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
+ HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
}
} else { // an unquoted here-doc delimiter
- if (isSafeAlnumOrHigh(ch) || ch == '_') {
- HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
- HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
- } else {
- styler.ColourTo(i - 1, state);
+ if (isSafeAlnumOrHigh(ch) || ch == '_') {
+ HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
+ HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+ } else {
+ styler.ColourTo(i - 1, state);
redo_char(i, ch, chNext, chNext2, state);
preferRE = false;
- }
+ }
}
- if (HereDoc.DelimiterLength >= static_cast<int>(sizeof(HereDoc.Delimiter)) - 1) {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_ERROR;
+ if (HereDoc.DelimiterLength >= static_cast<int>(sizeof(HereDoc.Delimiter)) - 1) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_ERROR;
preferRE = false;
- }
+ }
}
} else if (state == SCE_RB_HERE_Q) {
// Not needed: HereDoc.State == 2
@@ -1259,7 +1260,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
if (!HereDoc.CanBeIndented) {
if (isEOLChar(chPrev)
- && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
+ && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
styler.ColourTo(i - 1, state);
i += HereDoc.DelimiterLength - 1;
chNext = styler.SafeGetCharAt(i + 1);
@@ -1286,11 +1287,11 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
|| state == SCE_RB_INSTANCE_VAR
|| state == SCE_RB_SYMBOL) {
if (state == SCE_RB_SYMBOL &&
- // FIDs suffices '?' and '!'
- (((ch == '!' || ch == '?') && chNext != '=') ||
- // identifier suffix '='
- (ch == '=' && (chNext != '~' && chNext != '>' &&
- (chNext != '=' || chNext2 == '>'))))) {
+ // FIDs suffices '?' and '!'
+ (((ch == '!' || ch == '?') && chNext != '=') ||
+ // identifier suffix '='
+ (ch == '=' && (chNext != '~' && chNext != '>' &&
+ (chNext != '=' || chNext2 == '>'))))) {
styler.ColourTo(i, state);
state = SCE_RB_DEFAULT;
preferRE = false;
@@ -1318,9 +1319,9 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
} else if (state == SCE_RB_POD) {
// PODs end with ^=end\s, -- any whitespace can follow =end
if (strchr(" \t\n\r", ch) != NULL
- && i > 5
- && isEOLChar(styler[i - 5])
- && isMatch(styler, lengthDoc, i - 4, "=end")) {
+ && i > 5
+ && isEOLChar(styler[i - 5])
+ && isMatch(styler, lengthDoc, i - 4, "=end")) {
styler.ColourTo(i - 1, state);
state = SCE_RB_DEFAULT;
preferRE = false;
@@ -1335,7 +1336,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// Include the options
while (isSafeAlpha(chNext)) {
i++;
- ch = chNext;
+ ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
styler.ColourTo(i, state);
@@ -1346,9 +1347,9 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// Only if close quoter != open quoter
Quote.Count++;
- } else if (ch == '#' ) {
+ } else if (ch == '#') {
if (chNext == '{'
- && inner_string_count < INNER_STRINGS_MAX_COUNT) {
+ && inner_string_count < INNER_STRINGS_MAX_COUNT) {
// process #{ ... }
styler.ColourTo(i - 1, state);
styler.ColourTo(i + 1, SCE_RB_OPERATOR);
@@ -1388,7 +1389,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
chNext = styler.SafeGetCharAt(i + 1);
}
}
- // Quotes of all kinds...
+ // Quotes of all kinds...
} else if (state == SCE_RB_STRING_Q || state == SCE_RB_STRING_QQ ||
state == SCE_RB_STRING_QX || state == SCE_RB_STRING_QW ||
state == SCE_RB_STRING || state == SCE_RB_CHARACTER ||
@@ -1463,7 +1464,7 @@ static void getPrevWord(int pos,
for (; i <= pos; i++) {
*dst++ = styler[i];
}
- *dst = 0;
+ *dst = 0;
}
static bool keywordIsAmbiguous(const char *prevWord)
@@ -1471,11 +1472,11 @@ static bool keywordIsAmbiguous(const char *prevWord)
// Order from most likely used to least likely
// Lots of ways to do a loop in Ruby besides 'while/until'
if (!strcmp(prevWord, "if")
- || !strcmp(prevWord, "do")
- || !strcmp(prevWord, "while")
- || !strcmp(prevWord, "unless")
- || !strcmp(prevWord, "until")
- || !strcmp(prevWord, "for")) {
+ || !strcmp(prevWord, "do")
+ || !strcmp(prevWord, "while")
+ || !strcmp(prevWord, "unless")
+ || !strcmp(prevWord, "until")
+ || !strcmp(prevWord, "for")) {
return true;
} else {
return false;
@@ -1495,7 +1496,7 @@ static bool keywordIsModifier(const char *word,
}
char ch, chPrev, chPrev2;
int style = SCE_RB_DEFAULT;
- int lineStart = styler.GetLine(pos);
+ int lineStart = styler.GetLine(pos);
int lineStartPosn = styler.LineStart(lineStart);
// We want to step backwards until we don't care about the current
// position. But first move lineStartPosn back behind any
@@ -1515,20 +1516,20 @@ static bool keywordIsModifier(const char *word,
break;
}
} else {
- break;
+ break;
}
}
styler.Flush();
while (--pos >= lineStartPosn) {
style = actual_style(styler.StyleAt(pos));
- if (style == SCE_RB_DEFAULT) {
- if (iswhitespace(ch = styler[pos])) {
- //continue
- } else if (ch == '\r' || ch == '\n') {
- // Scintilla's LineStart() and GetLine() routines aren't
- // platform-independent, so if we have text prepared with
- // a different system we can't rely on it.
+ if (style == SCE_RB_DEFAULT) {
+ if (iswhitespace(ch = styler[pos])) {
+ //continue
+ } else if (ch == '\r' || ch == '\n') {
+ // Scintilla's LineStart() and GetLine() routines aren't
+ // platform-independent, so if we have text prepared with
+ // a different system we can't rely on it.
// Also, lineStartPosn may have been moved to more than one
// line above word's line while pushing past continuations.
@@ -1541,40 +1542,40 @@ static bool keywordIsModifier(const char *word,
pos-=2; // gloss over the "\\\r"
//continue
} else {
- return false;
+ return false;
}
- }
- } else {
+ }
+ } else {
break;
- }
+ }
}
if (pos < lineStartPosn) {
return false;
}
// First things where the action is unambiguous
switch (style) {
- case SCE_RB_DEFAULT:
- case SCE_RB_COMMENTLINE:
- case SCE_RB_POD:
- case SCE_RB_CLASSNAME:
- case SCE_RB_DEFNAME:
- case SCE_RB_MODULE_NAME:
- return false;
- case SCE_RB_OPERATOR:
- break;
- case SCE_RB_WORD:
- // Watch out for uses of 'else if'
- //XXX: Make a list of other keywords where 'if' isn't a modifier
- // and can appear legitimately
- // Formulate this to avoid warnings from most compilers
- if (strcmp(word, "if") == 0) {
- char prevWord[MAX_KEYWORD_LENGTH + 1];
- getPrevWord(pos, prevWord, styler, SCE_RB_WORD);
- return strcmp(prevWord, "else") != 0;
- }
- return true;
- default:
- return true;
+ case SCE_RB_DEFAULT:
+ case SCE_RB_COMMENTLINE:
+ case SCE_RB_POD:
+ case SCE_RB_CLASSNAME:
+ case SCE_RB_DEFNAME:
+ case SCE_RB_MODULE_NAME:
+ return false;
+ case SCE_RB_OPERATOR:
+ break;
+ case SCE_RB_WORD:
+ // Watch out for uses of 'else if'
+ //XXX: Make a list of other keywords where 'if' isn't a modifier
+ // and can appear legitimately
+ // Formulate this to avoid warnings from most compilers
+ if (strcmp(word, "if") == 0) {
+ char prevWord[MAX_KEYWORD_LENGTH + 1];
+ getPrevWord(pos, prevWord, styler, SCE_RB_WORD);
+ return strcmp(prevWord, "else") != 0;
+ }
+ return true;
+ default:
+ return true;
}
// Assume that if the keyword follows an operator,
// usually it's a block assignment, like
@@ -1582,12 +1583,12 @@ static bool keywordIsModifier(const char *word,
ch = styler[pos];
switch (ch) {
- case ')':
- case ']':
- case '}':
- return true;
- default:
- return false;
+ case ')':
+ case ']':
+ case '}':
+ return true;
+ default:
+ return false;
}
}
@@ -1603,27 +1604,27 @@ static bool keywordDoStartsLoop(int pos,
{
char ch;
int style;
- int lineStart = styler.GetLine(pos);
+ int lineStart = styler.GetLine(pos);
int lineStartPosn = styler.LineStart(lineStart);
styler.Flush();
while (--pos >= lineStartPosn) {
style = actual_style(styler.StyleAt(pos));
- if (style == SCE_RB_DEFAULT) {
- if ((ch = styler[pos]) == '\r' || ch == '\n') {
- // Scintilla's LineStart() and GetLine() routines aren't
- // platform-independent, so if we have text prepared with
- // a different system we can't rely on it.
- return false;
- }
- } else if (style == SCE_RB_WORD) {
+ if (style == SCE_RB_DEFAULT) {
+ if ((ch = styler[pos]) == '\r' || ch == '\n') {
+ // Scintilla's LineStart() and GetLine() routines aren't
+ // platform-independent, so if we have text prepared with
+ // a different system we can't rely on it.
+ return false;
+ }
+ } else if (style == SCE_RB_WORD) {
// Check for while or until, but write the word in backwards
char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
char *dst = prevWord;
int wordLen = 0;
int start_word;
for (start_word = pos;
- start_word >= lineStartPosn && actual_style(styler.StyleAt(start_word)) == SCE_RB_WORD;
- start_word--) {
+ start_word >= lineStartPosn && actual_style(styler.StyleAt(start_word)) == SCE_RB_WORD;
+ start_word--) {
if (++wordLen < MAX_KEYWORD_LENGTH) {
*dst++ = styler[start_word];
}
@@ -1631,8 +1632,8 @@ static bool keywordDoStartsLoop(int pos,
*dst = 0;
// Did we see our keyword?
if (!strcmp(prevWord, WHILE_BACKWARDS)
- || !strcmp(prevWord, UNTIL_BACKWARDS)
- || !strcmp(prevWord, FOR_BACKWARDS)) {
+ || !strcmp(prevWord, UNTIL_BACKWARDS)
+ || !strcmp(prevWord, FOR_BACKWARDS)) {
return true;
}
// We can move pos to the beginning of the keyword, and then
@@ -1650,6 +1651,19 @@ static bool keywordDoStartsLoop(int pos,
return false;
}
+static bool IsCommentLine(int line, Accessor &styler) {
+ int pos = styler.LineStart(line);
+ int eol_pos = styler.LineStart(line + 1) - 1;
+ for (int i = pos; i < eol_pos; i++) {
+ char ch = styler[i];
+ if (ch == '#')
+ return true;
+ else if (ch != ' ' && ch != '\t')
+ return false;
+ }
+ return false;
+}
+
/*
* Folding Ruby
*
@@ -1706,44 +1720,55 @@ static bool keywordDoStartsLoop(int pos,
static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
- const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
- bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+ const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
synchronizeDocStart(startPos, length, initStyle, styler, // ref args
false);
- unsigned int endPos = startPos + length;
- int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
- int levelPrev = startPos == 0 ? 0 : (styler.LevelAt(lineCurrent)
+ unsigned int endPos = startPos + length;
+ int visibleChars = 0;
+ int lineCurrent = styler.GetLine(startPos);
+ int levelPrev = startPos == 0 ? 0 : (styler.LevelAt(lineCurrent)
& SC_FOLDLEVELNUMBERMASK
& ~SC_FOLDLEVELBASE);
- int levelCurrent = levelPrev;
- char chNext = styler[startPos];
- int styleNext = styler.StyleAt(startPos);
- int stylePrev = startPos <= 1 ? SCE_RB_DEFAULT : styler.StyleAt(startPos - 1);
+ int levelCurrent = levelPrev;
+ char chNext = styler[startPos];
+ int styleNext = styler.StyleAt(startPos);
+ int stylePrev = startPos <= 1 ? SCE_RB_DEFAULT : styler.StyleAt(startPos - 1);
bool buffer_ends_with_eol = false;
- for (unsigned int i = startPos; i < endPos; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
- int style = styleNext;
- styleNext = styler.StyleAt(i + 1);
- bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+ for (unsigned int i = startPos; i < endPos; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ int style = styleNext;
+ styleNext = styler.StyleAt(i + 1);
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+ /*Mutiline comment patch*/
+ if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) {
+ if (!IsCommentLine(lineCurrent - 1, styler)
+ && IsCommentLine(lineCurrent + 1, styler))
+ levelCurrent++;
+ else if (IsCommentLine(lineCurrent - 1, styler)
+ && !IsCommentLine(lineCurrent + 1, styler))
+ levelCurrent--;
+ }
+
if (style == SCE_RB_COMMENTLINE) {
if (foldComment && stylePrev != SCE_RB_COMMENTLINE) {
if (chNext == '{') {
- levelCurrent++;
- } else if (chNext == '}' && levelCurrent > 0) {
- levelCurrent--;
- }
+ levelCurrent++;
+ } else if (chNext == '}' && levelCurrent > 0) {
+ levelCurrent--;
+ }
}
} else if (style == SCE_RB_OPERATOR) {
- if (strchr("[{(", ch)) {
- levelCurrent++;
- } else if (strchr(")}]", ch)) {
+ if (strchr("[{(", ch)) {
+ levelCurrent++;
+ } else if (strchr(")}]", ch)) {
// Don't decrement below 0
if (levelCurrent > 0)
levelCurrent--;
- }
+ }
} else if (style == SCE_RB_WORD && styleNext != SCE_RB_WORD) {
// Look at the keyword on the left and decide what to do
char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
@@ -1753,7 +1778,7 @@ static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
// Don't decrement below 0
if (levelCurrent > 0)
levelCurrent--;
- } else if ( !strcmp(prevWord, "if")
+ } else if (!strcmp(prevWord, "if")
|| !strcmp(prevWord, "def")
|| !strcmp(prevWord, "class")
|| !strcmp(prevWord, "module")
@@ -1764,49 +1789,49 @@ static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
|| !strcmp(prevWord, "unless")
|| !strcmp(prevWord, "until")
|| !strcmp(prevWord, "for")
- ) {
- levelCurrent++;
+ ) {
+ levelCurrent++;
+ }
+ } else if (style == SCE_RB_HERE_DELIM) {
+ if (styler.SafeGetCharAt(i-2) == '<' && styler.SafeGetCharAt(i-1) == '<') {
+ levelCurrent++;
+ } else if (styleNext == SCE_RB_DEFAULT) {
+ levelCurrent--;
}
- } else if (style == SCE_RB_HERE_DELIM) {
- if (styler.SafeGetCharAt(i-2) == '<' && styler.SafeGetCharAt(i-1) == '<') {
- levelCurrent++;
- } else if (styleNext == SCE_RB_DEFAULT) {
- levelCurrent--;
- }
- }
- if (atEOL) {
- int lev = levelPrev;
- if (visibleChars == 0 && foldCompact)
- lev |= SC_FOLDLEVELWHITEFLAG;
- if ((levelCurrent > levelPrev) && (visibleChars > 0))
- lev |= SC_FOLDLEVELHEADERFLAG;
+ }
+ if (atEOL) {
+ int lev = levelPrev;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(lineCurrent, lev|SC_FOLDLEVELBASE);
- lineCurrent++;
- levelPrev = levelCurrent;
- visibleChars = 0;
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ visibleChars = 0;
buffer_ends_with_eol = true;
- } else if (!isspacechar(ch)) {
- visibleChars++;
+ } else if (!isspacechar(ch)) {
+ visibleChars++;
buffer_ends_with_eol = false;
}
- stylePrev = style;
+ stylePrev = style;
}
- // Fill in the real level of the next line, keeping the current flags as they will be filled in later
+ // Fill in the real level of the next line, keeping the current flags as they will be filled in later
if (!buffer_ends_with_eol) {
lineCurrent++;
int new_lev = levelCurrent;
if (visibleChars == 0 && foldCompact)
new_lev |= SC_FOLDLEVELWHITEFLAG;
- if ((levelCurrent > levelPrev) && (visibleChars > 0))
- new_lev |= SC_FOLDLEVELHEADERFLAG;
- levelCurrent = new_lev;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ new_lev |= SC_FOLDLEVELHEADERFLAG;
+ levelCurrent = new_lev;
}
- styler.SetLevel(lineCurrent, levelCurrent|SC_FOLDLEVELBASE);
+ styler.SetLevel(lineCurrent, levelCurrent|SC_FOLDLEVELBASE);
}
-static const char * const rubyWordListDesc[] = {
- "Keywords",
- 0
+static const char *const rubyWordListDesc[] = {
+ "Keywords",
+ 0
};
LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc, rubyWordListDesc);