Commit b729d4b9 authored by Christian Kamm's avatar Christian Kamm Committed by Joerg Bornemann

QmlJS: Fix uses of Scanner::state().

Change-Id: I5195fc43e8a6653bf52c0eaa6cddb8dfd25b6217
Reviewed-on: http://codereview.qt.nokia.com/319Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@nokia.com>
parent 362aef67
......@@ -463,7 +463,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
leave();
continue;
} else if (m_tokenIndex == m_tokens.size() - 1
&& lexerState == Scanner::Normal) {
&& (lexerState & Scanner::MultiLineMask) == Scanner::Normal) {
leave();
} else if (m_tokenIndex == 0) {
// to allow enter/leave to update the indentDepth
......@@ -488,7 +488,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
}
if (topState != multiline_comment_start
&& topState != multiline_comment_cont
&& lexerState == Scanner::MultiLineComment) {
&& (lexerState & Scanner::MultiLineMask) == Scanner::MultiLineComment) {
enter(multiline_comment_start);
}
......
......@@ -166,22 +166,22 @@ static int findRegExpEnd(const QString &text, int start)
static inline int multiLineState(int state)
{
return state & 0x3;
return state & Scanner::MultiLineMask;
}
static inline void setMultiLineState(int *state, int s)
{
*state = s | (*state & ~0x3);
*state = s | (*state & ~Scanner::MultiLineMask);
}
static inline bool regexpMayFollow(int state)
{
return state & 0x4;
return state & Scanner::RegexpMayFollow;
}
static inline void setRegexpMayFollow(int *state, bool on)
{
*state = (on << 2) | (*state & 0x3);
*state = (on ? Scanner::RegexpMayFollow : 0) | (*state & ~Scanner::RegexpMayFollow);
}
QList<Token> Scanner::operator()(const QString &text, int startState)
......@@ -189,8 +189,6 @@ QList<Token> Scanner::operator()(const QString &text, int startState)
_state = startState;
QList<Token> tokens;
// ### handle multi line comment state.
int index = 0;
if (multiLineState(_state) == MultiLineComment) {
......
......@@ -84,6 +84,8 @@ public:
MultiLineComment = 1,
MultiLineStringDQuote = 2,
MultiLineStringSQuote = 3,
MultiLineMask = 3,
RegexpMayFollow = 4 // flag that may be combined with the above
};
......
......@@ -188,9 +188,9 @@ bool AutoCompleter::contextAllowsAutoParentheses(const QTextCursor &cursor,
// if a string literal doesn't start with a quote, it must be multiline
if (quote != QLatin1Char('"') && quote != QLatin1Char('\'')) {
const int startState = blockStartState(cursor.block());
if (startState == Scanner::MultiLineStringDQuote)
if ((startState & Scanner::MultiLineMask) == Scanner::MultiLineStringDQuote)
quote = QLatin1Char('"');
else if (startState == Scanner::MultiLineStringSQuote)
else if ((startState & Scanner::MultiLineMask) == Scanner::MultiLineStringSQuote)
quote = QLatin1Char('\'');
}
......
......@@ -108,7 +108,7 @@ void Highlighter::highlightBlock(const QString &text)
onClosingParenthesis('-', token.end() - 1, index == tokens.size()-1);
m_inMultilineComment = false;
} else if (!m_inMultilineComment
&& m_scanner.state() == Scanner::MultiLineComment
&& (m_scanner.state() & Scanner::MultiLineMask) == Scanner::MultiLineComment
&& index == tokens.size() - 1) {
onOpeningParenthesis('+', token.offset, index == 0);
m_inMultilineComment = true;
......@@ -337,7 +337,7 @@ int Highlighter::onBlockStart()
if (previousState != -1) {
state = previousState & 0xff;
m_braceDepth = (previousState >> 8);
m_inMultilineComment = (state == Scanner::MultiLineComment);
m_inMultilineComment = ((state & Scanner::MultiLineMask) == Scanner::MultiLineComment);
}
m_foldingIndent = m_braceDepth;
......
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