Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Wed, 26 Nov 2014 18:52:20 UTC Commit: 7ce24941421a8305b37a372f1bcda4038ff539fa https://github.com/geany/geany/commit/7ce24941421a8305b37a372f1bcda4038ff539...
Log Message: ----------- coffeescript: Import last lexer version from Scintilla HG
This fixes handling of "/*" and removes dead code.
Modified Paths: -------------- scintilla/lexers/LexCoffeeScript.cxx
Modified: scintilla/lexers/LexCoffeeScript.cxx 180 lines changed, 13 insertions(+), 167 deletions(-) =================================================================== @@ -31,11 +31,8 @@ using namespace Scintilla; #endif
static bool IsSpaceEquiv(int state) { - return (state <= SCE_COFFEESCRIPT_COMMENTDOC - // including SCE_COFFEESCRIPT_DEFAULT, SCE_COFFEESCRIPT_COMMENT, SCE_COFFEESCRIPT_COMMENTLINE - || state == SCE_COFFEESCRIPT_COMMENTLINEDOC - || state == SCE_COFFEESCRIPT_COMMENTDOCKEYWORD - || state == SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR + return (state == SCE_COFFEESCRIPT_DEFAULT + || state == SCE_COFFEESCRIPT_COMMENTLINE || state == SCE_COFFEESCRIPT_COMMENTBLOCK || state == SCE_COFFEESCRIPT_VERBOSE_REGEX || state == SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT @@ -88,51 +85,16 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init
WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; - WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3];
- // property styling.within.preprocessor - // For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default) - // or only from the initial # to the end of the command word(1). - bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0; - CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-"); CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-");
- CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\&<>#{}[]"); - - CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); - CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true); - - // property lexer.cpp.allow.dollars - // Set to 0 to disallow the '$' character in identifiers with the cpp lexer. - if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) { - setWordStart.Add('$'); - setWord.Add('$'); - } + CharacterSet setWordStart(CharacterSet::setAlpha, "_$@", 0x80, true); + CharacterSet setWord(CharacterSet::setAlphaNum, "._$", 0x80, true);
int chPrevNonWhite = ' '; int visibleChars = 0; - bool lastWordWasUUID = false; - int styleBeforeDCKeyword = SCE_COFFEESCRIPT_DEFAULT; - bool continuationLine = false; - bool isIncludePreprocessor = false; - - if (initStyle == SCE_COFFEESCRIPT_PREPROCESSOR) { - // Set continuationLine if last character of previous line is '' - int lineCurrent = styler.GetLine(startPos); - if (lineCurrent > 0) { - int chBack = styler.SafeGetCharAt(startPos-1, 0); - int chBack2 = styler.SafeGetCharAt(startPos-2, 0); - int lineEndChar = '!'; - if (chBack2 == '\r' && chBack == '\n') { - lineEndChar = styler.SafeGetCharAt(startPos-3, 0); - } else if (chBack == '\n' || chBack == '\r') { - lineEndChar = chBack2; - } - continuationLine = lineEndChar == '\'; - } - }
// look back to set chPrevNonWhite properly for better regex colouring int endPos = startPos + length; @@ -158,23 +120,9 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) { - // Reset states to begining of colourise so no surprises + // Reset states to beginning of colourise so no surprises // if different sets of lines lexed. visibleChars = 0; - lastWordWasUUID = false; - isIncludePreprocessor = false; - } - - // Handle line continuation generically. - if (sc.ch == '\') { - if (sc.chNext == '\n' || sc.chNext == '\r') { - sc.Forward(); - if (sc.ch == '\r' && sc.chNext == '\n') { - sc.Forward(); - } - continuationLine = true; - continue; - } }
// Determine if the current state should terminate. @@ -193,7 +141,6 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init char s[1000]; sc.GetCurrent(s, sizeof(s)); if (keywords.InList(s)) { - lastWordWasUUID = strcmp(s, "uuid") == 0; sc.ChangeState(SCE_COFFEESCRIPT_WORD); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_COFFEESCRIPT_WORD2); @@ -210,74 +157,13 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init sc.SetState(SCE_COFFEESCRIPT_DEFAULT); } break; - case SCE_COFFEESCRIPT_PREPROCESSOR: - if (sc.atLineStart && !continuationLine) { - sc.SetState(SCE_COFFEESCRIPT_DEFAULT); - } else if (stylingWithinPreprocessor) { - if (IsASpace(sc.ch)) { - sc.SetState(SCE_COFFEESCRIPT_DEFAULT); - } - } else { - if (sc.Match('/', '*') || sc.Match('/', '/')) { - sc.SetState(SCE_COFFEESCRIPT_DEFAULT); - } - } - break; - case SCE_COFFEESCRIPT_COMMENT: - if (sc.Match('*', '/')) { - sc.Forward(); - sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); - } - break; - case SCE_COFFEESCRIPT_COMMENTDOC: - if (sc.Match('*', '/')) { - sc.Forward(); - sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); - } else if (sc.ch == '@' || sc.ch == '\') { // JavaDoc and Doxygen support - // Verify that we have the conditions to mark a comment-doc-keyword - if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { - styleBeforeDCKeyword = SCE_COFFEESCRIPT_COMMENTDOC; - sc.SetState(SCE_COFFEESCRIPT_COMMENTDOCKEYWORD); - } - } - break; case SCE_COFFEESCRIPT_COMMENTLINE: if (sc.atLineStart) { sc.SetState(SCE_COFFEESCRIPT_DEFAULT); } break; - case SCE_COFFEESCRIPT_COMMENTLINEDOC: - if (sc.atLineStart) { - sc.SetState(SCE_COFFEESCRIPT_DEFAULT); - } else if (sc.ch == '@' || sc.ch == '\') { // JavaDoc and Doxygen support - // Verify that we have the conditions to mark a comment-doc-keyword - if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { - styleBeforeDCKeyword = SCE_COFFEESCRIPT_COMMENTLINEDOC; - sc.SetState(SCE_COFFEESCRIPT_COMMENTDOCKEYWORD); - } - } - break; - case SCE_COFFEESCRIPT_COMMENTDOCKEYWORD: - if ((styleBeforeDCKeyword == SCE_COFFEESCRIPT_COMMENTDOC) && sc.Match('*', '/')) { - sc.ChangeState(SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR); - sc.Forward(); - sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); - } else if (!setDoxygen.Contains(sc.ch)) { - char s[100]; - sc.GetCurrent(s, sizeof(s)); - if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) { - sc.ChangeState(SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR); - } - sc.SetState(styleBeforeDCKeyword); - } - break; case SCE_COFFEESCRIPT_STRING: - if (isIncludePreprocessor) { - if (sc.ch == '>') { - sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); - isIncludePreprocessor = false; - } - } else if (sc.ch == '\') { + if (sc.ch == '\') { if (sc.chNext == '"' || sc.chNext == ''' || sc.chNext == '\') { sc.Forward(); } @@ -314,20 +200,6 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init sc.SetState(SCE_COFFEESCRIPT_DEFAULT); } break; - case SCE_COFFEESCRIPT_VERBATIM: - if (sc.ch == '"') { - if (sc.chNext == '"') { - sc.Forward(); - } else { - sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); - } - } - break; - case SCE_COFFEESCRIPT_UUID: - if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') { - sc.SetState(SCE_COFFEESCRIPT_DEFAULT); - } - break; case SCE_COFFEESCRIPT_COMMENTBLOCK: if (sc.Match("###")) { sc.Forward(); @@ -357,30 +229,10 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init
// Determine if a new state should be entered. if (sc.state == SCE_COFFEESCRIPT_DEFAULT) { - if (sc.Match('@', '"')) { - sc.SetState(SCE_COFFEESCRIPT_VERBATIM); - sc.Forward(); - } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { - if (lastWordWasUUID) { - sc.SetState(SCE_COFFEESCRIPT_UUID); - lastWordWasUUID = false; - } else { - sc.SetState(SCE_COFFEESCRIPT_NUMBER); - } - } else if (setWordStart.Contains(sc.ch) || (sc.ch == '@') || (sc.ch == '$')) { - if (lastWordWasUUID) { - sc.SetState(SCE_COFFEESCRIPT_UUID); - lastWordWasUUID = false; - } else { - sc.SetState(SCE_COFFEESCRIPT_IDENTIFIER); - } - } else if (sc.Match('/', '*')) { - if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style - sc.SetState(SCE_COFFEESCRIPT_COMMENTDOC); - } else { - sc.SetState(SCE_COFFEESCRIPT_COMMENT); - } - sc.Forward(); // Eat the * so it isn't used for the end of the comment + if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { + sc.SetState(SCE_COFFEESCRIPT_NUMBER); + } else if (setWordStart.Contains(sc.ch)) { + sc.SetState(SCE_COFFEESCRIPT_IDENTIFIER); } else if (sc.Match("///")) { sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX); sc.Forward(); @@ -393,9 +245,6 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init sc.SetState(SCE_COFFEESCRIPT_REGEX); // JavaScript's RegEx } else if (sc.ch == '"') { sc.SetState(SCE_COFFEESCRIPT_STRING); - isIncludePreprocessor = false; // ensure that '>' won't end the string - } else if (isIncludePreprocessor && sc.ch == '<') { - sc.SetState(SCE_COFFEESCRIPT_STRING); } else if (sc.ch == ''') { sc.SetState(SCE_COFFEESCRIPT_CHARACTER); } else if (sc.ch == '#') { @@ -403,7 +252,6 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init sc.SetState(SCE_COFFEESCRIPT_COMMENTBLOCK); sc.Forward(); sc.Forward(); - } else { sc.SetState(SCE_COFFEESCRIPT_COMMENTLINE); } @@ -416,7 +264,6 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init chPrevNonWhite = sc.ch; visibleChars++; } - continuationLine = false; } sc.Complete(); } @@ -428,10 +275,6 @@ static bool IsCommentLine(int line, Accessor &styler) { char ch = styler[i]; if (ch == '#') return true; - else if (ch == '/' - && i < eol_pos - 1 - && styler[i + 1] == '*') - return true; else if (ch != ' ' && ch != '\t') return false; } @@ -563,6 +406,9 @@ static void FoldCoffeeScriptDoc(unsigned int startPos, int length, int,
static const char *const csWordLists[] = { "Keywords", + "Secondary keywords", + "Unused" + "Global classes", 0, };
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).