initialBraceDepth = previousBlockState_ >> 8; } int braceDepth = initialBraceDepth; // FIXME: Check defaults or get from document. LanguageFeatures features; features.cxx11Enabled = true; features.c99Enabled = true; SimpleLexer tokenize; tokenize.setLanguageFeatures(features); int initialLexerState = lexerState; const QList<Token> tokens = tokenize(text, initialLexerState); lexerState = tokenize.state(); // refresh lexer state initialLexerState &= ~0x80; // discard newline expected bit int foldingIndent = initialBraceDepth; if (TextBlockUserData *userData = BaseTextDocumentLayout::testUserData(currentBlock())) { userData->setFoldingIndent(0); userData->setFoldingStartIncluded(false); userData->setFoldingEndIncluded(false); } if (tokens.isEmpty()) { setCurrentBlockState((braceDepth << 8) | lexerState); BaseTextDocumentLayout::clearParentheses(currentBlock()); if (text.length()) {// the empty line can still contain whitespace if (initialLexerState == T_COMMENT) highlightLine(text, 0, text.length(), formatForCategory(CppCommentFormat));
int state = 0, initialBraceDepth = 0; if (previousState != -1) { state = previousState & 0xff; initialBraceDepth = previousState >> 8; } int braceDepth = initialBraceDepth; SimpleLexer tokenize; tokenize.setQtMocRunEnabled(false); tokenize.setObjCEnabled(false); tokenize.setCxx0xEnabled(true); int initialState = state; const QList<Token> tokens = tokenize(text, initialState); state = tokenize.state(); // refresh the state int foldingIndent = initialBraceDepth; if (TextBlockUserData *userData = BaseTextDocumentLayout::testUserData(currentBlock())) { userData->setFoldingIndent(0); userData->setFoldingStartIncluded(false); userData->setFoldingEndIncluded(false); } if (tokens.isEmpty()) { setCurrentBlockState(previousState); BaseTextDocumentLayout::clearParentheses(currentBlock()); if (text.length()) // the empty line can still contain whitespace setFormat(0, text.length(), m_formats[CppVisualWhitespace]); BaseTextDocumentLayout::setFoldingIndent(currentBlock(), foldingIndent); return;