forked from qt-creator/qt-creator
		
	Indenters: Move style setup into the QtStyleCodeFormatter constructors.
This makes sure styles are consistent for the editor and the quick fix engine.
This commit is contained in:
		@@ -118,7 +118,6 @@ public:
 | 
			
		||||
        changes.replace(start, end, m_componentName + QLatin1String(" {\n"));
 | 
			
		||||
        currentFile->change(changes);
 | 
			
		||||
        currentFile->indent(range(start, end + 1));
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1276,21 +1276,13 @@ bool QmlJSTextEditor::isClosingBrace(const QList<Token> &tokens) const
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static QmlJSEditor::QtStyleCodeFormatter setupCodeFormatter(const TextEditor::TabSettings &ts)
 | 
			
		||||
{
 | 
			
		||||
    QmlJSEditor::QtStyleCodeFormatter codeFormatter;
 | 
			
		||||
    codeFormatter.setIndentSize(ts.m_indentSize);
 | 
			
		||||
    codeFormatter.setTabSize(ts.m_tabSize);
 | 
			
		||||
    return codeFormatter;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QmlJSTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(doc)
 | 
			
		||||
    Q_UNUSED(typedChar)
 | 
			
		||||
 | 
			
		||||
    const TextEditor::TabSettings &ts = tabSettings();
 | 
			
		||||
    QmlJSEditor::QtStyleCodeFormatter codeFormatter = setupCodeFormatter(ts);
 | 
			
		||||
    QmlJSEditor::QtStyleCodeFormatter codeFormatter(ts);
 | 
			
		||||
 | 
			
		||||
    codeFormatter.updateStateUntil(block);
 | 
			
		||||
    const int depth = codeFormatter.indentFor(block);
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,8 @@
 | 
			
		||||
 | 
			
		||||
#include "qmljseditorcodeformatter.h"
 | 
			
		||||
 | 
			
		||||
#include <texteditor/tabsettings.h>
 | 
			
		||||
 | 
			
		||||
#include <QtCore/QDebug>
 | 
			
		||||
 | 
			
		||||
using namespace QmlJS;
 | 
			
		||||
@@ -40,6 +42,12 @@ QtStyleCodeFormatter::QtStyleCodeFormatter()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QtStyleCodeFormatter::QtStyleCodeFormatter(const TextEditor::TabSettings &tabSettings)
 | 
			
		||||
    : m_indentSize(tabSettings.m_indentSize)
 | 
			
		||||
{
 | 
			
		||||
    setTabSize(tabSettings.m_tabSize);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QtStyleCodeFormatter::setIndentSize(int size)
 | 
			
		||||
{
 | 
			
		||||
    m_indentSize = size;
 | 
			
		||||
 
 | 
			
		||||
@@ -35,12 +35,17 @@
 | 
			
		||||
#include <texteditor/basetextdocumentlayout.h>
 | 
			
		||||
#include <qmljs/qmljscodeformatter.h>
 | 
			
		||||
 | 
			
		||||
namespace TextEditor {
 | 
			
		||||
    class TabSettings;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace QmlJSEditor {
 | 
			
		||||
 | 
			
		||||
class QMLJSEDITOR_EXPORT QtStyleCodeFormatter : public QmlJS::CodeFormatter
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    QtStyleCodeFormatter();
 | 
			
		||||
    explicit QtStyleCodeFormatter(const TextEditor::TabSettings &tabSettings);
 | 
			
		||||
 | 
			
		||||
    void setIndentSize(int size);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ void QmlJSRefactoringChanges::indentSelection(const QTextCursor &selection) cons
 | 
			
		||||
    const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
 | 
			
		||||
 | 
			
		||||
    const TextEditor::TabSettings &tabSettings(TextEditor::TextEditorSettings::instance()->tabSettings());
 | 
			
		||||
    QtStyleCodeFormatter codeFormatter;
 | 
			
		||||
    QtStyleCodeFormatter codeFormatter(tabSettings);
 | 
			
		||||
    codeFormatter.updateStateUntil(block);
 | 
			
		||||
 | 
			
		||||
    do {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user