forked from qt-creator/qt-creator
TextEditor: Fix failure in cpptools autotest
The issue only appeared in the test due to the different editor construction there. Now use the same factory access. Change-Id: I3a8534fbe683bb88f04ad68850cecdfe32b11433 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
#include <texteditor/plaintexteditorfactory.h>
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
@@ -102,23 +103,20 @@ public:
|
|||||||
QVERIFY(ast);
|
QVERIFY(ast);
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
TextEditor::BaseTextDocumentPtr textDocument(new TextEditor::BaseTextDocument);
|
TextEditor::BaseTextEditor *editor = TextEditor::PlainTextEditorFactory::createPlainTextEditor();
|
||||||
textDocument->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
TextEditor::BaseTextEditorWidget *editorWidget = editor->editorWidget();
|
||||||
TextEditor::BaseTextEditorWidget editorWidget(0);
|
|
||||||
editorWidget.setTextDocument(textDocument);
|
|
||||||
editorWidget.setupAsPlainEditor();
|
|
||||||
QString error;
|
QString error;
|
||||||
editorWidget.open(&error, document->fileName(), document->fileName());
|
editor->open(&error, document->fileName(), document->fileName());
|
||||||
QVERIFY(error.isEmpty());
|
QVERIFY(error.isEmpty());
|
||||||
|
|
||||||
// Set cursor position
|
// Set cursor position
|
||||||
QTextCursor cursor = editorWidget.textCursor();
|
QTextCursor cursor = editorWidget->textCursor();
|
||||||
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
|
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
|
||||||
editorWidget.setTextCursor(cursor);
|
editorWidget->setTextCursor(cursor);
|
||||||
|
|
||||||
QTextDocument *qtextDocument = editorWidget.document();
|
QTextDocument *qtextDocument = editorWidget->document();
|
||||||
CppRefactoringFilePtr cppRefactoringFile
|
CppRefactoringFilePtr cppRefactoringFile
|
||||||
= CppRefactoringChanges::file(&editorWidget, document);
|
= CppRefactoringChanges::file(editorWidget, document);
|
||||||
|
|
||||||
// Prepare for formatting
|
// Prepare for formatting
|
||||||
Overview overview;
|
Overview overview;
|
||||||
|
|||||||
@@ -77,19 +77,21 @@ namespace Internal {
|
|||||||
class TextEditorOverlay;
|
class TextEditorOverlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
class BaseTextEditorWidget;
|
class AutoCompleter;
|
||||||
|
class BaseTextEditor;
|
||||||
class BaseTextEditorFactory;
|
class BaseTextEditorFactory;
|
||||||
class FontSettings;
|
class BaseTextEditorWidget;
|
||||||
|
class PlainTextEditorFactory;
|
||||||
|
|
||||||
class BehaviorSettings;
|
class BehaviorSettings;
|
||||||
class CompletionSettings;
|
class CompletionSettings;
|
||||||
class DisplaySettings;
|
class DisplaySettings;
|
||||||
class MarginSettings;
|
|
||||||
class TypingSettings;
|
|
||||||
class StorageSettings;
|
|
||||||
class Indenter;
|
|
||||||
class AutoCompleter;
|
|
||||||
class ExtraEncodingSettings;
|
class ExtraEncodingSettings;
|
||||||
class BaseTextEditor;
|
class FontSettings;
|
||||||
|
class Indenter;
|
||||||
|
class MarginSettings;
|
||||||
|
class StorageSettings;
|
||||||
|
class TypingSettings;
|
||||||
|
|
||||||
class TEXTEDITOR_EXPORT BlockRange
|
class TEXTEDITOR_EXPORT BlockRange
|
||||||
{
|
{
|
||||||
@@ -640,6 +642,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class BaseTextEditor;
|
friend class BaseTextEditor;
|
||||||
|
friend class PlainTextEditorFactory;
|
||||||
|
|
||||||
Core::IEditor *createEditor();
|
Core::IEditor *createEditor();
|
||||||
BaseTextEditor *createEditorHelper(const BaseTextDocumentPtr &doc);
|
BaseTextEditor *createEditorHelper(const BaseTextDocumentPtr &doc);
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
#include "highlightersettings.h"
|
#include "highlightersettings.h"
|
||||||
#include <texteditor/plaintexteditorfactory.h>
|
#include <texteditor/plaintexteditorfactory.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
#include <texteditor/texteditorplugin.h>
|
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -359,7 +358,7 @@ void Manager::registerMimeTypesFinished()
|
|||||||
const QPair<RegisterData, QList<MimeType> > &result = m_registeringWatcher.result();
|
const QPair<RegisterData, QList<MimeType> > &result = m_registeringWatcher.result();
|
||||||
m_register = result.first;
|
m_register = result.first;
|
||||||
|
|
||||||
PlainTextEditorFactory *factory = TextEditorPlugin::editorFactory();
|
PlainTextEditorFactory *factory = PlainTextEditorFactory::instance();
|
||||||
const QSet<QString> &inFactory = factory->mimeTypes().toSet();
|
const QSet<QString> &inFactory = factory->mimeTypes().toSet();
|
||||||
foreach (const MimeType &mimeType, result.second) {
|
foreach (const MimeType &mimeType, result.second) {
|
||||||
MimeDatabase::addMimeType(mimeType);
|
MimeDatabase::addMimeType(mimeType);
|
||||||
|
|||||||
@@ -41,10 +41,10 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
namespace Internal {
|
|
||||||
|
static PlainTextEditorFactory *m_instance = 0;
|
||||||
|
|
||||||
class PlainTextEditorWidget : public BaseTextEditorWidget
|
class PlainTextEditorWidget : public BaseTextEditorWidget
|
||||||
{
|
{
|
||||||
@@ -55,6 +55,8 @@ public:
|
|||||||
|
|
||||||
PlainTextEditorFactory::PlainTextEditorFactory()
|
PlainTextEditorFactory::PlainTextEditorFactory()
|
||||||
{
|
{
|
||||||
|
QTC_CHECK(!m_instance);
|
||||||
|
m_instance = this;
|
||||||
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||||
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
|
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
|
||||||
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
|
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
|
||||||
@@ -69,5 +71,14 @@ PlainTextEditorFactory::PlainTextEditorFactory()
|
|||||||
TextEditorActionHandler::UnCollapseAll);
|
TextEditorActionHandler::UnCollapseAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
PlainTextEditorFactory *PlainTextEditorFactory::instance()
|
||||||
|
{
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseTextEditor *PlainTextEditorFactory::createPlainTextEditor()
|
||||||
|
{
|
||||||
|
return qobject_cast<BaseTextEditor *>(m_instance->createEditor());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|||||||
@@ -33,17 +33,17 @@
|
|||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class PlainTextEditorFactory : public TextEditor::BaseTextEditorFactory
|
class TEXTEDITOR_EXPORT PlainTextEditorFactory : public TextEditor::BaseTextEditorFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlainTextEditorFactory();
|
PlainTextEditorFactory();
|
||||||
|
static PlainTextEditorFactory *instance();
|
||||||
|
static BaseTextEditor *createPlainTextEditor();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|
||||||
#endif // PLAINTEXTEDITORFACTORY_H
|
#endif // PLAINTEXTEDITORFACTORY_H
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ static TextEditorPlugin *m_instance = 0;
|
|||||||
|
|
||||||
TextEditorPlugin::TextEditorPlugin()
|
TextEditorPlugin::TextEditorPlugin()
|
||||||
: m_settings(0),
|
: m_settings(0),
|
||||||
m_editorFactory(0),
|
|
||||||
m_lineNumberFilter(0),
|
m_lineNumberFilter(0),
|
||||||
m_searchResultWindow(0)
|
m_searchResultWindow(0)
|
||||||
{
|
{
|
||||||
@@ -154,8 +153,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
|||||||
m_settings = new TextEditorSettings(this);
|
m_settings = new TextEditorSettings(this);
|
||||||
|
|
||||||
// Add plain text editor factory
|
// Add plain text editor factory
|
||||||
m_editorFactory = new PlainTextEditorFactory;
|
addAutoReleasedObject(new PlainTextEditorFactory);
|
||||||
addAutoReleasedObject(m_editorFactory);
|
|
||||||
|
|
||||||
// Goto line functionality for quick open
|
// Goto line functionality for quick open
|
||||||
m_lineNumberFilter = new LineNumberFilter;
|
m_lineNumberFilter = new LineNumberFilter;
|
||||||
@@ -261,11 +259,6 @@ void TextEditorPlugin::extensionsInitialized()
|
|||||||
this, SLOT(updateCurrentSelection(QString)));
|
this, SLOT(updateCurrentSelection(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
PlainTextEditorFactory *TextEditorPlugin::editorFactory()
|
|
||||||
{
|
|
||||||
return m_instance->m_editorFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
LineNumberFilter *TextEditorPlugin::lineNumberFilter()
|
LineNumberFilter *TextEditorPlugin::lineNumberFilter()
|
||||||
{
|
{
|
||||||
return m_instance->m_lineNumberFilter;
|
return m_instance->m_lineNumberFilter;
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class TextEditorSettings;
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class LineNumberFilter;
|
class LineNumberFilter;
|
||||||
class PlainTextEditorFactory;
|
|
||||||
class OutlineFactory;
|
class OutlineFactory;
|
||||||
class TextMarkRegistry;
|
class TextMarkRegistry;
|
||||||
|
|
||||||
@@ -59,7 +58,6 @@ public:
|
|||||||
bool initialize(const QStringList &arguments, QString *errorMessage);
|
bool initialize(const QStringList &arguments, QString *errorMessage);
|
||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
|
|
||||||
static PlainTextEditorFactory *editorFactory();
|
|
||||||
static LineNumberFilter *lineNumberFilter();
|
static LineNumberFilter *lineNumberFilter();
|
||||||
static TextMarkRegistry *baseTextMarkRegistry();
|
static TextMarkRegistry *baseTextMarkRegistry();
|
||||||
|
|
||||||
@@ -71,7 +69,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TextEditorSettings *m_settings;
|
TextEditorSettings *m_settings;
|
||||||
PlainTextEditorFactory *m_editorFactory;
|
|
||||||
LineNumberFilter *m_lineNumberFilter;
|
LineNumberFilter *m_lineNumberFilter;
|
||||||
Core::SearchResultWindow *m_searchResultWindow;
|
Core::SearchResultWindow *m_searchResultWindow;
|
||||||
OutlineFactory *m_outlineFactory;
|
OutlineFactory *m_outlineFactory;
|
||||||
|
|||||||
Reference in New Issue
Block a user