CppEditor: Rename CPPEditor{,Document} to CppEditor{,Document}

Better in line with the rest.

Change-Id: I692c8b6b9bebf22f059709fb60e53ea04fcb7d53
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hjk
2014-08-27 10:01:27 +02:00
parent 7b67701dea
commit d2c243464e
21 changed files with 157 additions and 131 deletions

View File

@@ -1373,8 +1373,7 @@ void CppCodeModelInspectorDialog::refresh()
dumper.dumpSnapshot(editorSnapshot, editorSnapshotTitle); dumper.dumpSnapshot(editorSnapshot, editorSnapshotTitle);
m_ui->snapshotSelector->addItem(editorSnapshotTitle); m_ui->snapshotSelector->addItem(editorSnapshotTitle);
} }
CppEditor::Internal::CppEditorWidget *cppEditorWidget CppEditorWidget *cppEditorWidget = qobject_cast<CppEditorWidget *>(editor->editorWidget());
= qobject_cast<CppEditor::Internal::CppEditorWidget *>(editor->editorWidget());
if (cppEditorWidget) { if (cppEditorWidget) {
SemanticInfo semanticInfo = cppEditorWidget->semanticInfo(); SemanticInfo semanticInfo = cppEditorWidget->semanticInfo();
CPlusPlus::Snapshot snapshot; CPlusPlus::Snapshot snapshot;

View File

@@ -90,15 +90,15 @@ using namespace CppEditor::Internal;
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
CPPEditor::CPPEditor() CppEditor::CppEditor()
{ {
m_context.add(CppEditor::Constants::C_CPPEDITOR); m_context.add(Constants::C_CPPEDITOR);
m_context.add(ProjectExplorer::Constants::LANG_CXX); m_context.add(ProjectExplorer::Constants::LANG_CXX);
m_context.add(TextEditor::Constants::C_TEXTEDITOR); m_context.add(TextEditor::Constants::C_TEXTEDITOR);
setDuplicateSupported(true); setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle); setCommentStyle(Utils::CommentDefinition::CppStyle);
setCompletionAssistProvider([this] () -> TextEditor::CompletionAssistProvider * { setCompletionAssistProvider([this] () -> TextEditor::CompletionAssistProvider * {
if (CPPEditorDocument *document = qobject_cast<CPPEditorDocument *>(textDocument())) if (CppEditorDocument *document = qobject_cast<CppEditorDocument *>(textDocument()))
return document->completionAssistProvider(); return document->completionAssistProvider();
return 0; return 0;
}); });
@@ -114,7 +114,7 @@ public:
public: public:
QPointer<CppTools::CppModelManagerInterface> m_modelManager; QPointer<CppTools::CppModelManagerInterface> m_modelManager;
CPPEditorDocument *m_cppEditorDocument; CppEditorDocument *m_cppEditorDocument;
CppEditorOutline *m_cppEditorOutline; CppEditorOutline *m_cppEditorOutline;
CppDocumentationCommentHelper m_cppDocumentationCommentHelper; CppDocumentationCommentHelper m_cppDocumentationCommentHelper;
@@ -137,7 +137,7 @@ public:
CppEditorWidgetPrivate::CppEditorWidgetPrivate(CppEditorWidget *q) CppEditorWidgetPrivate::CppEditorWidgetPrivate(CppEditorWidget *q)
: m_modelManager(CppModelManagerInterface::instance()) : m_modelManager(CppModelManagerInterface::instance())
, m_cppEditorDocument(qobject_cast<CPPEditorDocument *>(q->textDocument())) , m_cppEditorDocument(qobject_cast<CppEditorDocument *>(q->textDocument()))
, m_cppEditorOutline(new CppEditorOutline(q)) , m_cppEditorOutline(new CppEditorOutline(q))
, m_cppDocumentationCommentHelper(q) , m_cppDocumentationCommentHelper(q)
, m_localRenaming(q) , m_localRenaming(q)
@@ -148,7 +148,7 @@ CppEditorWidgetPrivate::CppEditorWidgetPrivate(CppEditorWidget *q)
{ {
} }
CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc, CPPEditor *editor) CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc, CppEditor *editor)
{ {
qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo"); qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo");
@@ -163,9 +163,9 @@ CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc, CPPEditor
setParenthesesMatchingEnabled(true); setParenthesesMatchingEnabled(true);
setRevisionsVisible(true); setRevisionsVisible(true);
connect(d->m_cppEditorDocument, &CPPEditorDocument::codeWarningsUpdated, connect(d->m_cppEditorDocument, &CppEditorDocument::codeWarningsUpdated,
this, &CppEditorWidget::onCodeWarningsUpdated); this, &CppEditorWidget::onCodeWarningsUpdated);
connect(d->m_cppEditorDocument, &CPPEditorDocument::ifdefedOutBlocksUpdated, connect(d->m_cppEditorDocument, &CppEditorDocument::ifdefedOutBlocksUpdated,
this, &CppEditorWidget::onIfdefedOutBlocksUpdated); this, &CppEditorWidget::onIfdefedOutBlocksUpdated);
connect(d->m_cppEditorDocument, SIGNAL(cppDocumentUpdated(CPlusPlus::Document::Ptr)), connect(d->m_cppEditorDocument, SIGNAL(cppDocumentUpdated(CPlusPlus::Document::Ptr)),
this, SLOT(onCppDocumentUpdated())); this, SLOT(onCppDocumentUpdated()));
@@ -229,7 +229,7 @@ CppEditorWidget::~CppEditorWidget()
// non-inline destructor, see section "Forward Declared Pointers" of QScopedPointer. // non-inline destructor, see section "Forward Declared Pointers" of QScopedPointer.
} }
CppEditorWidget *CppEditorWidget::duplicate(CPPEditor *editor) const CppEditorWidget *CppEditorWidget::duplicate(CppEditor *editor) const
{ {
QTC_ASSERT(editor, return 0); QTC_ASSERT(editor, return 0);
@@ -243,7 +243,7 @@ CppEditorWidget *CppEditorWidget::duplicate(CPPEditor *editor) const
return widget; return widget;
} }
CPPEditorDocument *CppEditorWidget::cppEditorDocument() const CppEditorDocument *CppEditorWidget::cppEditorDocument() const
{ {
return d->m_cppEditorDocument; return d->m_cppEditorDocument;
} }
@@ -564,16 +564,16 @@ void CppEditorWidget::keyPressEvent(QKeyEvent *e)
TextEditor::BaseTextEditorWidget::keyPressEvent(e); TextEditor::BaseTextEditorWidget::keyPressEvent(e);
} }
Core::IEditor *CPPEditor::duplicate() Core::IEditor *CppEditor::duplicate()
{ {
CPPEditor *editor = new CPPEditor; CppEditor *editor = new CppEditor;
CppEditorWidget *widget = qobject_cast<CppEditorWidget *>(editorWidget())->duplicate(editor); CppEditorWidget *widget = qobject_cast<CppEditorWidget *>(editorWidget())->duplicate(editor);
CppEditorPlugin::instance()->initializeEditor(widget); CppEditorPlugin::instance()->initializeEditor(widget);
editor->configureCodeAssistant(); editor->configureCodeAssistant();
return editor; return editor;
} }
bool CPPEditor::open(QString *errorString, const QString &fileName, const QString &realFileName) bool CppEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{ {
if (!TextEditor::BaseTextEditor::open(errorString, fileName, realFileName)) if (!TextEditor::BaseTextEditor::open(errorString, fileName, realFileName))
return false; return false;

View File

@@ -44,18 +44,18 @@ namespace CppTools { class SemanticInfo; }
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
class CPPEditorDocument; class CppEditorDocument;
class CppEditorOutline; class CppEditorOutline;
class CppEditorWidgetPrivate; class CppEditorWidgetPrivate;
class FollowSymbolUnderCursor; class FollowSymbolUnderCursor;
class FunctionDeclDefLink; class FunctionDeclDefLink;
class CPPEditor : public TextEditor::BaseTextEditor class CppEditor : public TextEditor::BaseTextEditor
{ {
Q_OBJECT Q_OBJECT
public: public:
CPPEditor(); CppEditor();
Core::IEditor *duplicate() QTC_OVERRIDE; Core::IEditor *duplicate() QTC_OVERRIDE;
@@ -72,12 +72,12 @@ public:
static Link linkToSymbol(CPlusPlus::Symbol *symbol); static Link linkToSymbol(CPlusPlus::Symbol *symbol);
public: public:
CppEditorWidget(TextEditor::BaseTextDocumentPtr doc, CPPEditor *editor); CppEditorWidget(TextEditor::BaseTextDocumentPtr doc, CppEditor *editor);
~CppEditorWidget(); ~CppEditorWidget();
CppEditorWidget *duplicate(CPPEditor *editor) const; CppEditorWidget *duplicate(CppEditor *editor) const;
CPPEditorDocument *cppEditorDocument() const; CppEditorDocument *cppEditorDocument() const;
CppEditorOutline *outline() const; CppEditorOutline *outline() const;
CppTools::SemanticInfo semanticInfo() const; CppTools::SemanticInfo semanticInfo() const;

View File

@@ -62,7 +62,7 @@ enum { processDocumentIntervalInMs = 150 };
class CppEditorDocumentHandle : public CppTools::EditorDocumentHandle class CppEditorDocumentHandle : public CppTools::EditorDocumentHandle
{ {
public: public:
CppEditorDocumentHandle(CppEditor::Internal::CPPEditorDocument *cppEditorDocument) CppEditorDocumentHandle(CppEditor::Internal::CppEditorDocument *cppEditorDocument)
: m_cppEditorDocument(cppEditorDocument) : m_cppEditorDocument(cppEditorDocument)
, m_registrationFilePath(cppEditorDocument->filePath()) , m_registrationFilePath(cppEditorDocument->filePath())
{ {
@@ -79,13 +79,13 @@ public:
{ return m_cppEditorDocument->processor(); } { return m_cppEditorDocument->processor(); }
private: private:
CppEditor::Internal::CPPEditorDocument * const m_cppEditorDocument; CppEditor::Internal::CppEditorDocument * const m_cppEditorDocument;
// The file path of the editor document can change (e.g. by "Save As..."), so make sure // The file path of the editor document can change (e.g. by "Save As..."), so make sure
// that un-registration happens with the path the document was registered. // that un-registration happens with the path the document was registered.
const QString m_registrationFilePath; const QString m_registrationFilePath;
}; };
CPPEditorDocument::CPPEditorDocument() CppEditorDocument::CppEditorDocument()
: m_fileIsBeingReloaded(false) : m_fileIsBeingReloaded(false)
, m_isObjCEnabled(false) , m_isObjCEnabled(false)
, m_cachedContentsRevision(-1) , m_cachedContentsRevision(-1)
@@ -111,35 +111,35 @@ CPPEditorDocument::CPPEditorDocument()
// See also onFilePathChanged() for more initialization // See also onFilePathChanged() for more initialization
} }
CPPEditorDocument::~CPPEditorDocument() CppEditorDocument::~CppEditorDocument()
{ {
} }
bool CPPEditorDocument::isObjCEnabled() const bool CppEditorDocument::isObjCEnabled() const
{ {
return m_isObjCEnabled; return m_isObjCEnabled;
} }
CppTools::CppCompletionAssistProvider *CPPEditorDocument::completionAssistProvider() const CppTools::CppCompletionAssistProvider *CppEditorDocument::completionAssistProvider() const
{ {
return m_completionAssistProvider; return m_completionAssistProvider;
} }
void CPPEditorDocument::semanticRehighlight() void CppEditorDocument::semanticRehighlight()
{ {
CppTools::BaseEditorDocumentProcessor *p = processor(); CppTools::BaseEditorDocumentProcessor *p = processor();
QTC_ASSERT(p, return); QTC_ASSERT(p, return);
p->semanticRehighlight(true); p->semanticRehighlight(true);
} }
CppTools::SemanticInfo CPPEditorDocument::recalculateSemanticInfo() CppTools::SemanticInfo CppEditorDocument::recalculateSemanticInfo()
{ {
CppTools::BaseEditorDocumentProcessor *p = processor(); CppTools::BaseEditorDocumentProcessor *p = processor();
QTC_ASSERT(p, CppTools::SemanticInfo()); QTC_ASSERT(p, CppTools::SemanticInfo());
return p->recalculateSemanticInfo(); return p->recalculateSemanticInfo();
} }
QByteArray CPPEditorDocument::contentsText() const QByteArray CppEditorDocument::contentsText() const
{ {
QMutexLocker locker(&m_cachedContentsLock); QMutexLocker locker(&m_cachedContentsLock);
@@ -152,7 +152,7 @@ QByteArray CPPEditorDocument::contentsText() const
return m_cachedContents; return m_cachedContents;
} }
void CPPEditorDocument::applyFontSettings() void CppEditorDocument::applyFontSettings()
{ {
if (TextEditor::SyntaxHighlighter *highlighter = syntaxHighlighter()) { if (TextEditor::SyntaxHighlighter *highlighter = syntaxHighlighter()) {
// Clear all additional formats since they may have changed // Clear all additional formats since they may have changed
@@ -166,13 +166,13 @@ void CPPEditorDocument::applyFontSettings()
BaseTextDocument::applyFontSettings(); // rehighlights and updates additional formats BaseTextDocument::applyFontSettings(); // rehighlights and updates additional formats
} }
void CPPEditorDocument::invalidateFormatterCache() void CppEditorDocument::invalidateFormatterCache()
{ {
CppTools::QtStyleCodeFormatter formatter; CppTools::QtStyleCodeFormatter formatter;
formatter.invalidateCache(document()); formatter.invalidateCache(document());
} }
void CPPEditorDocument::onMimeTypeChanged() void CppEditorDocument::onMimeTypeChanged()
{ {
const QString &mt = mimeType(); const QString &mt = mimeType();
m_isObjCEnabled = (mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE) m_isObjCEnabled = (mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
@@ -180,19 +180,19 @@ void CPPEditorDocument::onMimeTypeChanged()
m_completionAssistProvider = mm()->completionAssistProvider(mt); m_completionAssistProvider = mm()->completionAssistProvider(mt);
} }
void CPPEditorDocument::onAboutToReload() void CppEditorDocument::onAboutToReload()
{ {
QTC_CHECK(!m_fileIsBeingReloaded); QTC_CHECK(!m_fileIsBeingReloaded);
m_fileIsBeingReloaded = true; m_fileIsBeingReloaded = true;
} }
void CPPEditorDocument::onReloadFinished() void CppEditorDocument::onReloadFinished()
{ {
QTC_CHECK(m_fileIsBeingReloaded); QTC_CHECK(m_fileIsBeingReloaded);
m_fileIsBeingReloaded = false; m_fileIsBeingReloaded = false;
} }
void CPPEditorDocument::onFilePathChanged(const QString &oldPath, const QString &newPath) void CppEditorDocument::onFilePathChanged(const QString &oldPath, const QString &newPath)
{ {
Q_UNUSED(oldPath); Q_UNUSED(oldPath);
@@ -211,13 +211,13 @@ void CPPEditorDocument::onFilePathChanged(const QString &oldPath, const QString
} }
} }
void CPPEditorDocument::scheduleProcessDocument() void CppEditorDocument::scheduleProcessDocument()
{ {
m_processorRevision = document()->revision(); m_processorRevision = document()->revision();
m_processorTimer.start(processDocumentIntervalInMs); m_processorTimer.start(processDocumentIntervalInMs);
} }
void CPPEditorDocument::processDocument() void CppEditorDocument::processDocument()
{ {
if (processor()->isParserRunning() || m_processorRevision != contentsRevision()) { if (processor()->isParserRunning() || m_processorRevision != contentsRevision()) {
m_processorTimer.start(); m_processorTimer.start();
@@ -231,36 +231,36 @@ void CPPEditorDocument::processDocument()
processor()->run(); processor()->run();
} }
void CPPEditorDocument::resetProcessor() void CppEditorDocument::resetProcessor()
{ {
releaseResources(); releaseResources();
processor(); // creates a new processor processor(); // creates a new processor
} }
unsigned CPPEditorDocument::contentsRevision() const unsigned CppEditorDocument::contentsRevision() const
{ {
return document()->revision(); return document()->revision();
} }
void CPPEditorDocument::releaseResources() void CppEditorDocument::releaseResources()
{ {
if (m_processor) if (m_processor)
disconnect(m_processor.data(), 0, this, 0); disconnect(m_processor.data(), 0, this, 0);
m_processor.reset(); m_processor.reset();
} }
CppTools::BaseEditorDocumentProcessor *CPPEditorDocument::processor() CppTools::BaseEditorDocumentProcessor *CppEditorDocument::processor()
{ {
if (!m_processor) { if (!m_processor) {
m_processor.reset(mm()->editorDocumentProcessor(this)); m_processor.reset(mm()->editorDocumentProcessor(this));
connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::codeWarningsUpdated, connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::codeWarningsUpdated,
this, &CPPEditorDocument::codeWarningsUpdated); this, &CppEditorDocument::codeWarningsUpdated);
connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::ifdefedOutBlocksUpdated, connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::ifdefedOutBlocksUpdated,
this, &CPPEditorDocument::ifdefedOutBlocksUpdated); this, &CppEditorDocument::ifdefedOutBlocksUpdated);
connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::cppDocumentUpdated, connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::cppDocumentUpdated,
this, &CPPEditorDocument::cppDocumentUpdated); this, &CppEditorDocument::cppDocumentUpdated);
connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::semanticInfoUpdated, connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::semanticInfoUpdated,
this, &CPPEditorDocument::semanticInfoUpdated); this, &CppEditorDocument::semanticInfoUpdated);
} }
return m_processor.data(); return m_processor.data();

View File

@@ -44,15 +44,15 @@
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
class CPPEditorDocument : public TextEditor::BaseTextDocument class CppEditorDocument : public TextEditor::BaseTextDocument
{ {
Q_OBJECT Q_OBJECT
friend class CppEditorDocumentHandle; friend class CppEditorDocumentHandle;
public: public:
explicit CPPEditorDocument(); explicit CppEditorDocument();
~CPPEditorDocument(); ~CppEditorDocument();
bool isObjCEnabled() const; bool isObjCEnabled() const;
CppTools::CppCompletionAssistProvider *completionAssistProvider() const; CppTools::CppCompletionAssistProvider *completionAssistProvider() const;

View File

@@ -63,8 +63,9 @@
#include <QStringList> #include <QStringList>
using namespace Core; using namespace Core;
using namespace CppEditor;
using namespace CppEditor::Internal; namespace CppEditor {
namespace Internal {
void registerQuickFixes(ExtensionSystem::IPlugin *plugIn); void registerQuickFixes(ExtensionSystem::IPlugin *plugIn);
@@ -75,30 +76,30 @@ enum { QUICKFIX_INTERVAL = 20 };
CppEditorFactory::CppEditorFactory(CppEditorPlugin *owner) : CppEditorFactory::CppEditorFactory(CppEditorPlugin *owner) :
m_owner(owner) m_owner(owner)
{ {
setId(CppEditor::Constants::CPPEDITOR_ID); setId(Constants::CPPEDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", CppEditor::Constants::CPPEDITOR_DISPLAY_NAME)); setDisplayName(qApp->translate("OpenWith::Editors", Constants::CPPEDITOR_DISPLAY_NAME));
addMimeType(CppEditor::Constants::C_SOURCE_MIMETYPE); addMimeType(Constants::C_SOURCE_MIMETYPE);
addMimeType(CppEditor::Constants::C_HEADER_MIMETYPE); addMimeType(Constants::C_HEADER_MIMETYPE);
addMimeType(CppEditor::Constants::CPP_SOURCE_MIMETYPE); addMimeType(Constants::CPP_SOURCE_MIMETYPE);
addMimeType(CppEditor::Constants::CPP_HEADER_MIMETYPE); addMimeType(Constants::CPP_HEADER_MIMETYPE);
new TextEditor::TextEditorActionHandler(this, CppEditor::Constants::C_CPPEDITOR, new TextEditor::TextEditorActionHandler(this, Constants::C_CPPEDITOR,
TextEditor::TextEditorActionHandler::Format TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection | TextEditor::TextEditorActionHandler::UnCommentSelection
| TextEditor::TextEditorActionHandler::UnCollapseAll | TextEditor::TextEditorActionHandler::UnCollapseAll
| TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor); | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
if (!Utils::HostOsInfo::isMacHost() && !Utils::HostOsInfo::isWindowsHost()) { if (!Utils::HostOsInfo::isMacHost() && !Utils::HostOsInfo::isWindowsHost()) {
FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_cpp.png", CppEditor::Constants::CPP_SOURCE_MIMETYPE); FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_cpp.png", Constants::CPP_SOURCE_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_c.png", CppEditor::Constants::C_SOURCE_MIMETYPE); FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_c.png", Constants::C_SOURCE_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_h.png", CppEditor::Constants::CPP_HEADER_MIMETYPE); FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_h.png", Constants::CPP_HEADER_MIMETYPE);
} }
} }
IEditor *CppEditorFactory::createEditor() IEditor *CppEditorFactory::createEditor()
{ {
CPPEditor *editor = new CPPEditor; CppEditor *editor = new CppEditor;
CppEditorWidget *widget = new CppEditorWidget(BaseTextDocumentPtr(new CPPEditorDocument), editor); CppEditorWidget *widget = new CppEditorWidget(BaseTextDocumentPtr(new CppEditorDocument), editor);
m_owner->initializeEditor(widget); m_owner->initializeEditor(widget);
editor->configureCodeAssistant(); editor->configureCodeAssistant();
return editor; return editor;
@@ -167,16 +168,16 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
auto hf = new TextEditor::HighlighterFactory; auto hf = new TextEditor::HighlighterFactory;
hf->setProductType<CppHighlighter>(); hf->setProductType<CppHighlighter>();
hf->setId(CppEditor::Constants::CPPEDITOR_ID); hf->setId(Constants::CPPEDITOR_ID);
hf->addMimeType(CppEditor::Constants::C_SOURCE_MIMETYPE); hf->addMimeType(Constants::C_SOURCE_MIMETYPE);
hf->addMimeType(CppEditor::Constants::C_HEADER_MIMETYPE); hf->addMimeType(Constants::C_HEADER_MIMETYPE);
hf->addMimeType(CppEditor::Constants::CPP_SOURCE_MIMETYPE); hf->addMimeType(Constants::CPP_SOURCE_MIMETYPE);
hf->addMimeType(CppEditor::Constants::CPP_HEADER_MIMETYPE); hf->addMimeType(Constants::CPP_HEADER_MIMETYPE);
addAutoReleasedObject(hf); addAutoReleasedObject(hf);
m_quickFixProvider = new CppQuickFixAssistProvider; m_quickFixProvider = new CppQuickFixAssistProvider;
addAutoReleasedObject(m_quickFixProvider); addAutoReleasedObject(m_quickFixProvider);
CppEditor::Internal::registerQuickFixes(this); registerQuickFixes(this);
QString trCat = QCoreApplication::translate(Constants::WIZARD_CATEGORY, Constants::WIZARD_TR_CATEGORY); QString trCat = QCoreApplication::translate(Constants::WIZARD_CATEGORY, Constants::WIZARD_TR_CATEGORY);
@@ -208,9 +209,9 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
wizard->setId(QLatin1String("C.Header")); wizard->setId(QLatin1String("C.Header"));
addAutoReleasedObject(wizard); addAutoReleasedObject(wizard);
Context context(CppEditor::Constants::C_CPPEDITOR); Context context(Constants::C_CPPEDITOR);
ActionContainer *contextMenu = ActionManager::createMenu(CppEditor::Constants::M_CONTEXT); ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_CONTEXT);
Command *cmd; Command *cmd;
ActionContainer *cppToolsMenu = ActionManager::actionContainer(CppTools::Constants::M_TOOLS_CPP); ActionContainer *cppToolsMenu = ActionManager::actionContainer(CppTools::Constants::M_TOOLS_CPP);
@@ -425,3 +426,6 @@ void CppEditorPlugin::openIncludeHierarchy()
emit includeHierarchyRequested(); emit includeHierarchyRequested();
} }
} }
} // namespace Internal
} // namespace CppEditor

View File

@@ -40,6 +40,8 @@
#include <QDir> #include <QDir>
using namespace CppEditor::Internal;
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
namespace Tests { namespace Tests {
@@ -63,12 +65,9 @@ TestCase::~TestCase()
{ {
} }
bool TestCase::openCppEditor(const QString &fileName, bool TestCase::openCppEditor(const QString &fileName, CppEditor **editor, CppEditorWidget **editorWidget)
Internal::CPPEditor **editor,
Internal::CppEditorWidget **editorWidget)
{ {
using namespace CppEditor::Internal; if (CppEditor *e = dynamic_cast<CppEditor *>(Core::EditorManager::openEditor(fileName))) {
if (CPPEditor *e = dynamic_cast<CPPEditor *>(Core::EditorManager::openEditor(fileName))) {
if (editor) if (editor)
*editor = e; *editor = e;
if (editorWidget) { if (editorWidget) {
@@ -87,7 +86,7 @@ bool TestCase::openCppEditor(const QString &fileName,
} }
CPlusPlus::Document::Ptr TestCase::waitForRehighlightedSemanticDocument( CPlusPlus::Document::Ptr TestCase::waitForRehighlightedSemanticDocument(
Internal::CppEditorWidget *editorWidget) CppEditorWidget *editorWidget)
{ {
const QString filePath = editorWidget->textDocument()->filePath(); const QString filePath = editorWidget->textDocument()->filePath();
auto processor = CppTools::BaseEditorDocumentProcessor::get(filePath); auto processor = CppTools::BaseEditorDocumentProcessor::get(filePath);

View File

@@ -36,9 +36,9 @@
#include <cpptools/cpptoolstestcase.h> #include <cpptools/cpptoolstestcase.h>
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
class CPPEditor;
class CppEditor;
class CppEditorWidget; class CppEditorWidget;
namespace Tests { namespace Tests {
@@ -52,8 +52,8 @@ public:
public: public:
int m_cursorPosition; int m_cursorPosition;
Internal::CPPEditor *m_editor; CppEditor *m_editor;
Internal::CppEditorWidget *m_editorWidget; CppEditorWidget *m_editorWidget;
}; };
class TestCase : public CppTools::Tests::TestCase class TestCase : public CppTools::Tests::TestCase
@@ -63,11 +63,11 @@ public:
~TestCase(); ~TestCase();
static bool openCppEditor(const QString &fileName, static bool openCppEditor(const QString &fileName,
Internal::CPPEditor **editor, CppEditor **editor,
Internal::CppEditorWidget **editorWidget = 0); CppEditorWidget **editorWidget = 0);
static CPlusPlus::Document::Ptr waitForRehighlightedSemanticDocument( static CPlusPlus::Document::Ptr waitForRehighlightedSemanticDocument(
Internal::CppEditorWidget *editorWidget); CppEditorWidget *editorWidget);
}; };
} // namespace Tests } // namespace Tests

View File

@@ -43,22 +43,22 @@
#include <QSet> #include <QSet>
#include <QQueue> #include <QQueue>
using namespace CppEditor;
using namespace CppEditor::Internal;
using namespace CPlusPlus; using namespace CPlusPlus;
namespace { namespace CppEditor {
QStringList stripName(const QString &name) { namespace Internal {
QStringList all;
all << name; static QStringList stripName(const QString &name)
int colonColon = 0; {
const int size = name.size(); QStringList all;
while ((colonColon = name.indexOf(QLatin1String("::"), colonColon)) != -1) { all << name;
all << name.right(size - colonColon - 2); int colonColon = 0;
colonColon += 2; const int size = name.size();
} while ((colonColon = name.indexOf(QLatin1String("::"), colonColon)) != -1) {
return all; all << name.right(size - colonColon - 2);
colonColon += 2;
} }
return all;
} }
CppElementEvaluator::CppElementEvaluator(TextEditor::BaseTextEditorWidget *editor) : CppElementEvaluator::CppElementEvaluator(TextEditor::BaseTextEditorWidget *editor) :
@@ -78,7 +78,7 @@ void CppElementEvaluator::setLookupBaseClasses(const bool lookup)
void CppElementEvaluator::setLookupDerivedClasses(const bool lookup) void CppElementEvaluator::setLookupDerivedClasses(const bool lookup)
{ m_lookupDerivedClasses = lookup; } { m_lookupDerivedClasses = lookup; }
// @todo: Consider refactoring code from CPPEditor::findLinkAt into here. // @todo: Consider refactoring code from CppEditor::findLinkAt into here.
void CppElementEvaluator::execute() void CppElementEvaluator::execute()
{ {
clear(); clear();
@@ -235,7 +235,7 @@ const QString &CppElementEvaluator::diagnosis() const
return m_diagnosis; return m_diagnosis;
} }
void CppEditor::Internal::CppElementEvaluator::clear() void CppElementEvaluator::clear()
{ {
m_element.clear(); m_element.clear();
m_diagnosis.clear(); m_diagnosis.clear();
@@ -470,3 +470,6 @@ CppEnumerator::CppEnumerator(CPlusPlus::EnumeratorDeclaration *declaration)
if (!enumeratorValue.isEmpty()) if (!enumeratorValue.isEmpty())
tooltip.append(QLatin1String(" = ") + enumeratorValue); tooltip.append(QLatin1String(" = ") + enumeratorValue);
} }
} // namespace Internal
} // namespace CppEditor

View File

@@ -136,7 +136,7 @@ void CppIncludeHierarchyWidget::perform()
{ {
showNoIncludeHierarchyLabel(); showNoIncludeHierarchyLabel();
m_editor = qobject_cast<CPPEditor *>(Core::EditorManager::currentEditor()); m_editor = qobject_cast<CppEditor *>(Core::EditorManager::currentEditor());
if (!m_editor) if (!m_editor)
return; return;

View File

@@ -54,7 +54,7 @@ class FileName;
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
class CPPEditor; class CppEditor;
class CppEditorWidget; class CppEditorWidget;
class CppInclude; class CppInclude;
class CppIncludeLabel; class CppIncludeLabel;

View File

@@ -42,9 +42,11 @@
Q_DECLARE_METATYPE(QList<QByteArray>) Q_DECLARE_METATYPE(QList<QByteArray>)
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppEditor::Internal;
using namespace CppTools; using namespace CppTools;
namespace CppEditor {
namespace Internal {
namespace { namespace {
QString toString(CppIncludeHierarchyModel &model, const QModelIndex &index, int indent = 0) QString toString(CppIncludeHierarchyModel &model, const QModelIndex &index, int indent = 0)
@@ -69,7 +71,7 @@ QString toString(CppIncludeHierarchyModel &model)
+ toString(model, model.index(1, 0)); + toString(model, model.index(1, 0));
} }
class IncludeHierarchyTestCase: public CppEditor::Internal::Tests::TestCase class IncludeHierarchyTestCase : public Tests::TestCase
{ {
public: public:
IncludeHierarchyTestCase(const QList<QByteArray> &sourceList, IncludeHierarchyTestCase(const QList<QByteArray> &sourceList,
@@ -95,7 +97,7 @@ public:
// Open Editor // Open Editor
const QString fileName = QDir::tempPath() + QLatin1String("/file1.h"); const QString fileName = QDir::tempPath() + QLatin1String("/file1.h");
CPPEditor *editor; CppEditor *editor;
QVERIFY(openCppEditor(fileName, &editor)); QVERIFY(openCppEditor(fileName, &editor));
closeEditorAtEndOfTestCase(editor); closeEditorAtEndOfTestCase(editor);
@@ -182,3 +184,6 @@ void CppEditorPlugin::test_includehierarchy()
IncludeHierarchyTestCase(documents, expectedHierarchy); IncludeHierarchyTestCase(documents, expectedHierarchy);
} }
} // namespace CppEditor
} // namespace Internal

View File

@@ -47,7 +47,7 @@ namespace TextEditor { class BaseTextEditor; }
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
class CPPEditor; class CppEditor;
class CppIncludeHierarchyItem; class CppIncludeHierarchyItem;
class CppIncludeHierarchyModel : public QAbstractItemModel class CppIncludeHierarchyModel : public QAbstractItemModel

View File

@@ -40,7 +40,8 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QMenu> #include <QMenu>
using namespace CppEditor::Internal; namespace CppEditor {
namespace Internal {
enum { enum {
debug = false debug = false
@@ -185,14 +186,14 @@ bool CppOutlineWidget::syncCursor()
bool CppOutlineWidgetFactory::supportsEditor(Core::IEditor *editor) const bool CppOutlineWidgetFactory::supportsEditor(Core::IEditor *editor) const
{ {
if (qobject_cast<CPPEditor*>(editor)) if (qobject_cast<CppEditor*>(editor))
return true; return true;
return false; return false;
} }
TextEditor::IOutlineWidget *CppOutlineWidgetFactory::createWidget(Core::IEditor *editor) TextEditor::IOutlineWidget *CppOutlineWidgetFactory::createWidget(Core::IEditor *editor)
{ {
CPPEditor *cppEditor = qobject_cast<CPPEditor*>(editor); CppEditor *cppEditor = qobject_cast<CppEditor*>(editor);
CppEditorWidget *cppEditorWidget = qobject_cast<CppEditorWidget*>(cppEditor->widget()); CppEditorWidget *cppEditorWidget = qobject_cast<CppEditorWidget*>(cppEditor->widget());
QTC_ASSERT(cppEditorWidget, return 0); QTC_ASSERT(cppEditorWidget, return 0);
@@ -200,3 +201,6 @@ TextEditor::IOutlineWidget *CppOutlineWidgetFactory::createWidget(Core::IEditor
return widget; return widget;
} }
} // namespace Internal
} // namespace CppEditor

View File

@@ -68,6 +68,6 @@ private:
}; };
} // namespace Internal } // namespace Internal
} // namespace CPPEditor } // namespace CppEditor
#endif // CPPPREPROCESSORDIALOG_H #endif // CPPPREPROCESSORDIALOG_H

View File

@@ -37,12 +37,13 @@
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
using namespace CppEditor;
using namespace CppEditor::Internal;
using namespace TextEditor; using namespace TextEditor;
using namespace CppTools; using namespace CppTools;
using namespace CPlusPlus; using namespace CPlusPlus;
namespace CppEditor {
namespace Internal {
// ------------------------- // -------------------------
// CppQuickFixAssistProvider // CppQuickFixAssistProvider
// ------------------------- // -------------------------
@@ -53,7 +54,7 @@ bool CppQuickFixAssistProvider::isAsynchronous() const
bool CppQuickFixAssistProvider::supportsEditor(Core::Id editorId) const bool CppQuickFixAssistProvider::supportsEditor(Core::Id editorId) const
{ {
return editorId == CppEditor::Constants::CPPEDITOR_ID; return editorId == Constants::CPPEDITOR_ID;
} }
IAssistProcessor *CppQuickFixAssistProvider::createProcessor() const IAssistProcessor *CppQuickFixAssistProvider::createProcessor() const
@@ -64,7 +65,7 @@ IAssistProcessor *CppQuickFixAssistProvider::createProcessor() const
QList<TextEditor::QuickFixFactory *> CppQuickFixAssistProvider::quickFixFactories() const QList<TextEditor::QuickFixFactory *> CppQuickFixAssistProvider::quickFixFactories() const
{ {
QList<TextEditor::QuickFixFactory *> results; QList<TextEditor::QuickFixFactory *> results;
foreach (CppQuickFixFactory *f, ExtensionSystem::PluginManager::getObjects<CppEditor::CppQuickFixFactory>()) foreach (CppQuickFixFactory *f, ExtensionSystem::PluginManager::getObjects<CppQuickFixFactory>())
results.append(f); results.append(f);
return results; return results;
} }
@@ -140,3 +141,6 @@ bool CppQuickFixAssistInterface::isCursorOn(const CPlusPlus::AST *ast) const
{ {
return currentFile()->isCursorOn(ast); return currentFile()->isCursorOn(ast);
} }
} // namespace Internal
} // namespace CppEditor

View File

@@ -70,13 +70,14 @@
#include <cctype> #include <cctype>
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppEditor;
using namespace CppEditor::Internal;
using namespace CppTools; using namespace CppTools;
using namespace TextEditor; using namespace TextEditor;
using Utils::ChangeSet; using Utils::ChangeSet;
void CppEditor::Internal::registerQuickFixes(ExtensionSystem::IPlugin *plugIn) namespace CppEditor {
namespace Internal {
void registerQuickFixes(ExtensionSystem::IPlugin *plugIn)
{ {
plugIn->addAutoReleasedObject(new AddIncludeForUndefinedIdentifier); plugIn->addAutoReleasedObject(new AddIncludeForUndefinedIdentifier);
plugIn->addAutoReleasedObject(new AddIncludeForForwardDeclaration); plugIn->addAutoReleasedObject(new AddIncludeForForwardDeclaration);
@@ -5342,3 +5343,6 @@ void EscapeStringLiteral::match(const CppQuickFixInterface &interface, QuickFixO
result.append(op); result.append(op);
} }
} }
} // namespace Internal
} // namespace CppEditor

View File

@@ -170,7 +170,7 @@ void CppTypeHierarchyWidget::perform()
{ {
showNoTypeHierarchyLabel(); showNoTypeHierarchyLabel();
CPPEditor *editor = qobject_cast<CPPEditor *>(Core::EditorManager::currentEditor()); CppEditor *editor = qobject_cast<CppEditor *>(Core::EditorManager::currentEditor());
if (!editor) if (!editor)
return; return;

View File

@@ -216,7 +216,7 @@ bool VirtualFunctionAssistProvider::isAsynchronous() const
bool VirtualFunctionAssistProvider::supportsEditor(Core::Id editorId) const bool VirtualFunctionAssistProvider::supportsEditor(Core::Id editorId) const
{ {
return editorId == CppEditor::Constants::CPPEDITOR_ID; return editorId == Constants::CPPEDITOR_ID;
} }
IAssistProcessor *VirtualFunctionAssistProvider::createProcessor() const IAssistProcessor *VirtualFunctionAssistProvider::createProcessor() const

View File

@@ -79,14 +79,15 @@
using namespace Core; using namespace Core;
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppEditor;
using namespace CppEditor::Internal;
using namespace CppTools; using namespace CppTools;
using namespace TextEditor; using namespace TextEditor;
namespace CppEditor {
namespace Internal {
namespace { namespace {
class TestActionsTestCase : public CppEditor::Internal::Tests::TestCase class TestActionsTestCase : public Tests::TestCase
{ {
public: public:
class AbstractAction class AbstractAction
@@ -120,7 +121,7 @@ private:
/// Move word camel case wise from current cursor position until given token (not included) /// Move word camel case wise from current cursor position until given token (not included)
/// and execute the tokenActions for each new position. /// and execute the tokenActions for each new position.
static void moveWordCamelCaseToToken(TranslationUnit *translationUnit, const Token &token, static void moveWordCamelCaseToToken(TranslationUnit *translationUnit, const Token &token,
CPPEditor *editor, const Actions &tokenActions); CppEditor *editor, const Actions &tokenActions);
static void undoAllChangesAndCloseAllEditors(); static void undoAllChangesAndCloseAllEditors();
@@ -143,7 +144,7 @@ Actions singleAction(const ActionPointer &action)
} }
TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Actions &fileActions) TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Actions &fileActions)
: CppEditor::Internal::Tests::TestCase(/*runGarbageCollector=*/false) : Tests::TestCase(/*runGarbageCollector=*/false)
{ {
QVERIFY(succeededSoFar()); QVERIFY(succeededSoFar());
@@ -187,7 +188,7 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
// Open editor // Open editor
QCOMPARE(DocumentModel::openedDocuments().size(), 0); QCOMPARE(DocumentModel::openedDocuments().size(), 0);
CPPEditor *editor; CppEditor *editor;
CppEditorWidget *editorWidget; CppEditorWidget *editorWidget;
QVERIFY(openCppEditor(filePath, &editor, &editorWidget)); QVERIFY(openCppEditor(filePath, &editor, &editorWidget));
@@ -287,7 +288,7 @@ void TestActionsTestCase::executeActionsOnEditorWidget(CppEditorWidget *editorWi
void TestActionsTestCase::moveWordCamelCaseToToken(TranslationUnit *translationUnit, void TestActionsTestCase::moveWordCamelCaseToToken(TranslationUnit *translationUnit,
const Token &token, const Token &token,
CPPEditor *editor, CppEditor *editor,
const Actions &tokenActions) const Actions &tokenActions)
{ {
QVERIFY(translationUnit); QVERIFY(translationUnit);
@@ -373,7 +374,7 @@ void SwitchDeclarationDefinitionTokenAction::run(CppEditorWidget *)
IEditor *editorBefore = EditorManager::currentEditor(); IEditor *editorBefore = EditorManager::currentEditor();
const int originalLine = editorBefore->currentLine(); const int originalLine = editorBefore->currentLine();
const int originalColumn = editorBefore->currentColumn(); const int originalColumn = editorBefore->currentColumn();
CppEditor::Internal::CppEditorPlugin::instance()->switchDeclarationDefinition(); CppEditorPlugin::instance()->switchDeclarationDefinition();
QApplication::processEvents(); QApplication::processEvents();
// Go back // Go back
@@ -394,7 +395,7 @@ public:
void FindUsagesTokenAction::run(CppEditorWidget *) void FindUsagesTokenAction::run(CppEditorWidget *)
{ {
CppEditor::Internal::CppEditorPlugin::instance()->findUsages(); CppEditorPlugin::instance()->findUsages();
QApplication::processEvents(); QApplication::processEvents();
} }
@@ -407,7 +408,7 @@ public:
void RenameSymbolUnderCursorTokenAction::run(CppEditorWidget *) void RenameSymbolUnderCursorTokenAction::run(CppEditorWidget *)
{ {
CppEditor::Internal::CppEditorPlugin::instance()->renameSymbolUnderCursor(); CppEditorPlugin::instance()->renameSymbolUnderCursor();
QApplication::processEvents(); QApplication::processEvents();
} }
@@ -420,7 +421,7 @@ public:
void OpenTypeHierarchyTokenAction::run(CppEditorWidget *) void OpenTypeHierarchyTokenAction::run(CppEditorWidget *)
{ {
CppEditor::Internal::CppEditorPlugin::instance()->openTypeHierarchy(); CppEditorPlugin::instance()->openTypeHierarchy();
QApplication::processEvents(); QApplication::processEvents();
} }
@@ -474,7 +475,7 @@ void RunAllQuickFixesTokenAction::run(CppEditorWidget *editorWidget)
return; return;
foreach (CppQuickFixFactory *quickFixFactory, quickFixFactories) { foreach (CppQuickFixFactory *quickFixFactory, quickFixFactories) {
TextEditor::QuickFixOperations operations; QuickFixOperations operations;
// Some Quick Fixes pop up a dialog and are therefore inappropriate for this test. // Some Quick Fixes pop up a dialog and are therefore inappropriate for this test.
// Where possible, use a guiless version of the factory. // Where possible, use a guiless version of the factory.
if (qobject_cast<InsertVirtualMethods *>(quickFixFactory)) { if (qobject_cast<InsertVirtualMethods *>(quickFixFactory)) {
@@ -567,3 +568,6 @@ void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndTriggerQuickFixes()
{ {
TestActionsTestCase(singleAction(ActionPointer(new RunAllQuickFixesTokenAction))); TestActionsTestCase(singleAction(ActionPointer(new RunAllQuickFixesTokenAction)));
} }
} // namespace Internal
} // namespace CppEditor

View File

@@ -71,7 +71,7 @@ bool GlslCompleter::contextAllowsElectricCharacters(const QTextCursor &cursor) c
const Token tk = SimpleLexer::tokenAt(cursor.block().text(), cursor.positionInBlock(), const Token tk = SimpleLexer::tokenAt(cursor.block().text(), cursor.positionInBlock(),
BackwardsScanner::previousBlockState(cursor.block())); BackwardsScanner::previousBlockState(cursor.block()));
// XXX Duplicated from CPPEditor::isInComment to avoid tokenizing twice // XXX Duplicated from CppEditor::isInComment to avoid tokenizing twice
if (tk.isComment()) { if (tk.isComment()) {
const unsigned pos = cursor.selectionEnd() - cursor.block().position(); const unsigned pos = cursor.selectionEnd() - cursor.block().position();