QmlJS indenter: Never touch indent of multi-line strings.

Task-number: QTCREATORBUG-6368
Change-Id: Iae68427e429e625214bc0729aaaf313dc3371570
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Christian Kamm
2011-10-24 12:29:54 +02:00
parent f3774d0a6f
commit a9553c494e
7 changed files with 43 additions and 14 deletions

View File

@@ -517,10 +517,10 @@ int CodeFormatter::indentForNewLineAfter(const QTextBlock &block)
{
restoreCurrentState(block);
int lexerState = loadLexerState(block);
m_tokens.clear();
m_currentLine.clear();
adjustIndent(m_tokens, lexerState, &m_indentDepth);
const int startLexerState = loadLexerState(block.previous());
adjustIndent(m_tokens, startLexerState, &m_indentDepth);
return m_indentDepth;
}
@@ -665,10 +665,11 @@ void CodeFormatter::leave(bool statementDone)
void CodeFormatter::correctIndentation(const QTextBlock &block)
{
const int lexerState = tokenizeBlock(block);
tokenizeBlock(block);
Q_ASSERT(m_currentState.size() >= 1);
adjustIndent(m_tokens, lexerState, &m_indentDepth);
const int startLexerState = loadLexerState(block.previous());
adjustIndent(m_tokens, startLexerState, &m_indentDepth);
}
bool CodeFormatter::tryInsideExpression(bool alsoExpression)

View File

@@ -71,7 +71,7 @@ public:
protected:
virtual void onEnter(int newState, int *indentDepth, int *savedIndentDepth) const = 0;
virtual void adjustIndent(const QList<Token> &tokens, int lexerState, int *indentDepth) const = 0;
virtual void adjustIndent(const QList<Token> &tokens, int startLexerState, int *indentDepth) const = 0;
struct State;
class QMLJS_EXPORT BlockData