void CBTCLStyler::StyleEmbeddedVariables ( const Token& token ) { emptyVariablePattern.SetSingleLine(); variablePattern.SetSingleLine(); const JString& text = GetText(); JFontStyle varStyle = GetTypeStyle(token.type - kWhitespace); varStyle.underlineCount++; if (varStyle == GetTypeStyle(kVariable - kWhitespace)) { varStyle.underlineCount++; } JFontStyle errStyle = GetTypeStyle(kError - kWhitespace); errStyle.underlineCount++; if (errStyle == GetTypeStyle(kVariable - kWhitespace)) { errStyle.underlineCount++; } JIndexRange r = token.range, r1, r2; while (!r.IsEmpty()) { const JCharacter c = text.GetCharacter(r.first); if (c == '\\') { r.first++; } else if (c == '$') { r1 = r - (r.first-1); if (emptyVariablePattern.MatchWithin(text.GetCString() + r.first-1, r1, &r2)) { r2 += r.first-1; AdjustStyle(r2, errStyle); r.first = r2.last; } else if (variablePattern.MatchWithin(text.GetCString() + r.first-1, r1, &r2)) { r2 += r.first-1; AdjustStyle(r2, varStyle); r.first = r2.last; } } r.first++; } }
void CBHTMLStyler::StyleEmbeddedVariables ( const Token& token ) { emptyVariablePattern.SetSingleLine(); variablePattern.SetSingleLine(); const JString& text = GetText(); JFontStyle varStyle = GetTypeStyle(token.type - kWhitespace); varStyle.underlineCount++; if (varStyle == GetTypeStyle(kPHPVariable - kWhitespace)) { varStyle.underlineCount++; } JFontStyle errStyle = GetTypeStyle(kError - kWhitespace); errStyle.underlineCount++; if (errStyle == GetTypeStyle(kPHPVariable - kWhitespace)) { errStyle.underlineCount++; } JIndexRange r = token.range, r1, r2; while (!r.IsEmpty()) { const JCharacter c = text.GetCharacter(r.first); if (c == '\\') { r.first++; } else if (c == '$') { r1 = r - (r.first-1); if (emptyVariablePattern.MatchWithin(text.GetCString() + r.first-1, r1, &r2)) { r2 += r.first-1; const JCharacter c1 = text.GetCharacter(r2.last); if (c1 != '}' && c1 != ']') { r2.last--; } AdjustStyle(r2, errStyle); r.first = r2.last; } else if (variablePattern.MatchWithin(text.GetCString() + r.first-1, r1, &r2)) { r2 += r.first-1; if (r2.first > 1 && text.GetCharacter(r2.first-1) == '{') { r2.first--; } AdjustStyle(r2, varStyle); r.first = r2.last; } } else if (c == '{' && r.first < r.last - 1 && text.GetCharacter(r.first+1) == '$' && text.GetCharacter(r.first+2) == '}') { r1.SetFirstAndLength(r.first, 3); AdjustStyle(r1, errStyle); r.first = r1.last; } r.first++; } }