Commit fca108c3 authored by Eike Ziller's avatar Eike Ziller
Browse files

Remove dead code from GLSL highlighter



Change-Id: I43734e16ee0972906666629dc822e19982980d0e
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 51996e9a
......@@ -325,88 +325,5 @@ bool GlslHighlighter::isPPKeyword(const QStringRef &text) const
return false;
}
#if 0
void Highlighter::highlightBlock(const QString &text)
{
const int previousState = previousBlockState();
int state = 0, initialBraceDepth = 0;
if (previousState != -1) {
state = previousState & 0xff;
initialBraceDepth = previousState >> 8;
}
int braceDepth = initialBraceDepth;
Parentheses parentheses;
parentheses.reserve(20); // assume wizard level ;-)
const QByteArray data = text.toLatin1();
GLSL::Lexer lex(/*engine=*/ 0, data.constData(), data.size());
lex.setState(qMax(0, previousState));
lex.setScanKeywords(false);
lex.setScanComments(true);
const int variant = m_editor->languageVariant();
lex.setVariant(variant);
int foldingIndent = initialBraceDepth;
if (TextBlockUserData *userData = BaseTextDocumentLayout::testUserData(currentBlock())) {
userData->setFoldingIndent(0);
userData->setFoldingStartIncluded(false);
userData->setFoldingEndIncluded(false);
}
QList<GLSL::Token> tokens;
GLSL::Token tk;
do {
lex.yylex(&tk);
tokens.append(tk);
} while (tk.isNot(GLSL::Parser::EOF_SYMBOL));
for (int i = 0; i < tokens.size(); ++i) {
const GLSL::Token &tk = tokens.at(i);
if (tk.is(GLSL::Parser::T_NUMBER)) {
setFormat(tk.position, tk.length, formatForCategory(GLSLNumberFormat));
} else if (tk.is(GLSL::Parser::T_COMMENT)) {
setFormat(tk.position, tk.length, Qt::darkGreen); // ### FIXME: formatForCategory(GLSLCommentFormat);
} else if (tk.is(GLSL::Parser::T_IDENTIFIER)) {
int kind = lex.findKeyword(data.constData() + tk.position, tk.length);
if (kind == GLSL::Parser::T_RESERVED)
setFormat(tk.position, tk.length, formatForCategory(GLSLReservedKeyword));
else if (kind != GLSL::Parser::T_IDENTIFIER)
setFormat(tk.position, tk.length, formatForCategory(GLSLKeywordFormat));
} else if (tk.is(GLSL::Parser::T_LEFT_PAREN) || tk.is(GLSL::Parser::T_LEFT_BRACE) || tk.is(GLSL::Parser::T_LEFT_BRACKET)) {
const QChar c = text.at(tk.begin());
parentheses.append(Parenthesis(Parenthesis::Opened, c, tk.begin()));
if (tk.is(GLSL::Parser::T_LEFT_BRACE)) {
++braceDepth;
// if a folding block opens at the beginning of a line, treat the entire line
// as if it were inside the folding block
// if (tk.begin() == firstNonSpace) {
// ++foldingIndent;
// BaseTextDocumentLayout::userData(currentBlock())->setFoldingStartIncluded(true);
// }
}
} else if (tk.is(GLSL::Parser::T_RIGHT_PAREN) || tk.is(GLSL::Parser::T_RIGHT_BRACE) || tk.is(GLSL::Parser::T_RIGHT_BRACKET)) {
const QChar c = text.at(tk.begin());
parentheses.append(Parenthesis(Parenthesis::Closed, c, tk.begin()));
if (tk.is(GLSL::Parser::T_RIGHT_BRACE)) {
--braceDepth;
if (braceDepth < foldingIndent) {
// unless we are at the end of the block, we reduce the folding indent
if (i == tokens.size()-1 || tokens.at(i+1).is(GLSL::Parser::T_SEMICOLON))
BaseTextDocumentLayout::userData(currentBlock())->setFoldingEndIncluded(true);
else
foldingIndent = qMin(braceDepth, foldingIndent);
}
}
}
} while (tk.isNot(GLSL::Parser::EOF_SYMBOL));
setCurrentBlockState((braceDepth << 8) | lex.state());
}
#endif
} // namespace Internal
} // namespace GlslEditor
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment