summaryrefslogtreecommitdiff
path: root/src/libs/qmljs/qmljscodeformatter.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@nokia.com>2011-11-01 18:16:38 +0100
committerEike Ziller <eike.ziller@nokia.com>2011-11-01 18:16:38 +0100
commit912cd548c0b0950b3a1e80f2597c99b3bf898c83 (patch)
treec9eeb5ac857dcabcfb404f60356ad4522471d9ed /src/libs/qmljs/qmljscodeformatter.cpp
parentddde938174f03544182adb79179d192502b50e51 (diff)
parent002820867cc0f4f5c67c5ae976eec26157275d4f (diff)
downloadqt-creator-912cd548c0b0950b3a1e80f2597c99b3bf898c83.tar.gz
Merge remote-tracking branch 'origin/2.4'
Conflicts: src/libs/qmljs/qmljsinterpreter.cpp src/libs/qmljs/qmljsinterpreter.h src/plugins/madde/maemopackagecreationstep.cpp src/plugins/projectexplorer/buildmanager.cpp src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp src/plugins/qmljstools/qmljsqtstylecodeformatter.h tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp Change-Id: I63ab2ba5dac006c37ccfbae55b023396a4676ff7
Diffstat (limited to 'src/libs/qmljs/qmljscodeformatter.cpp')
-rw-r--r--src/libs/qmljs/qmljscodeformatter.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/libs/qmljs/qmljscodeformatter.cpp b/src/libs/qmljs/qmljscodeformatter.cpp
index fa5ef50eea..9d2ceb69f3 100644
--- a/src/libs/qmljs/qmljscodeformatter.cpp
+++ b/src/libs/qmljs/qmljscodeformatter.cpp
@@ -523,10 +523,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;
}
@@ -671,10 +671,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)
@@ -1211,10 +1212,8 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
}
}
-void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int lexerState, int *indentDepth) const
+void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int startLexerState, int *indentDepth) const
{
- Q_UNUSED(lexerState)
-
State topState = state();
State previousState = state(1);
@@ -1226,6 +1225,12 @@ void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int lexerSta
return;
}
}
+ // don't touch multi-line strings at all
+ if ((startLexerState & Scanner::MultiLineMask) == Scanner::MultiLineStringDQuote
+ || (startLexerState & Scanner::MultiLineMask) == Scanner::MultiLineStringSQuote) {
+ *indentDepth = -1;
+ return;
+ }
const int kind = extendedTokenKind(tokenAt(0));
switch (kind) {