forked from qt-creator/qt-creator
CppEditor: Remove RefactoringEngine
Another useless indirection. Change-Id: Icfcc0704a1056d8002a674edbe74b946cb56ff27 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -26,7 +26,6 @@ add_qtc_plugin(ClangCodeModel
|
|||||||
clangpreprocessorassistproposalitem.cpp clangpreprocessorassistproposalitem.h
|
clangpreprocessorassistproposalitem.cpp clangpreprocessorassistproposalitem.h
|
||||||
clangprojectsettings.cpp clangprojectsettings.h
|
clangprojectsettings.cpp clangprojectsettings.h
|
||||||
clangprojectsettingswidget.cpp clangprojectsettingswidget.h clangprojectsettingswidget.ui
|
clangprojectsettingswidget.cpp clangprojectsettingswidget.h clangprojectsettingswidget.ui
|
||||||
clangrefactoringengine.cpp clangrefactoringengine.h
|
|
||||||
clangtextmark.cpp clangtextmark.h
|
clangtextmark.cpp clangtextmark.h
|
||||||
clanguiheaderondiskmanager.cpp clanguiheaderondiskmanager.h
|
clanguiheaderondiskmanager.cpp clanguiheaderondiskmanager.h
|
||||||
clangutils.cpp clangutils.h
|
clangutils.cpp clangutils.h
|
||||||
|
@@ -59,8 +59,6 @@ QtcPlugin {
|
|||||||
"clangprojectsettingswidget.cpp",
|
"clangprojectsettingswidget.cpp",
|
||||||
"clangprojectsettingswidget.h",
|
"clangprojectsettingswidget.h",
|
||||||
"clangprojectsettingswidget.ui",
|
"clangprojectsettingswidget.ui",
|
||||||
"clangrefactoringengine.cpp",
|
|
||||||
"clangrefactoringengine.h",
|
|
||||||
"clangtextmark.cpp",
|
"clangtextmark.cpp",
|
||||||
"clangtextmark.h",
|
"clangtextmark.h",
|
||||||
"clanguiheaderondiskmanager.cpp",
|
"clanguiheaderondiskmanager.cpp",
|
||||||
|
@@ -826,7 +826,7 @@ public:
|
|||||||
class LocalRefsData {
|
class LocalRefsData {
|
||||||
public:
|
public:
|
||||||
LocalRefsData(quint64 id, TextDocument *doc, const QTextCursor &cursor,
|
LocalRefsData(quint64 id, TextDocument *doc, const QTextCursor &cursor,
|
||||||
CppEditor::RefactoringEngineInterface::RenameCallback &&callback)
|
CppEditor::RenameCallback &&callback)
|
||||||
: id(id), document(doc), cursor(cursor), callback(std::move(callback)),
|
: id(id), document(doc), cursor(cursor), callback(std::move(callback)),
|
||||||
uri(DocumentUri::fromFilePath(doc->filePath())), revision(doc->document()->revision())
|
uri(DocumentUri::fromFilePath(doc->filePath())), revision(doc->document()->revision())
|
||||||
{}
|
{}
|
||||||
@@ -840,7 +840,7 @@ public:
|
|||||||
const quint64 id;
|
const quint64 id;
|
||||||
const QPointer<TextDocument> document;
|
const QPointer<TextDocument> document;
|
||||||
const QTextCursor cursor;
|
const QTextCursor cursor;
|
||||||
CppEditor::RefactoringEngineInterface::RenameCallback callback;
|
CppEditor::RenameCallback callback;
|
||||||
const DocumentUri uri;
|
const DocumentUri uri;
|
||||||
const int revision;
|
const int revision;
|
||||||
};
|
};
|
||||||
@@ -2187,7 +2187,7 @@ void ClangdClient::switchDeclDef(TextDocument *document, const QTextCursor &curs
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClangdClient::findLocalUsages(TextDocument *document, const QTextCursor &cursor,
|
void ClangdClient::findLocalUsages(TextDocument *document, const QTextCursor &cursor,
|
||||||
CppEditor::RefactoringEngineInterface::RenameCallback &&callback)
|
CppEditor::RenameCallback &&callback)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(documentOpen(document), openDocument(document));
|
QTC_ASSERT(documentOpen(document), openDocument(document));
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <cppeditor/baseeditordocumentparser.h>
|
#include <cppeditor/baseeditordocumentparser.h>
|
||||||
#include <cppeditor/cppcodemodelsettings.h>
|
#include <cppeditor/cppcodemodelsettings.h>
|
||||||
#include <cppeditor/refactoringengineinterface.h>
|
#include <cppeditor/cursorineditor.h>
|
||||||
#include <languageclient/client.h>
|
#include <languageclient/client.h>
|
||||||
#include <utils/link.h>
|
#include <utils/link.h>
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
Utils::ProcessLinkCallback &&callback);
|
Utils::ProcessLinkCallback &&callback);
|
||||||
|
|
||||||
void findLocalUsages(TextEditor::TextDocument *document, const QTextCursor &cursor,
|
void findLocalUsages(TextEditor::TextDocument *document, const QTextCursor &cursor,
|
||||||
CppEditor::RefactoringEngineInterface::RenameCallback &&callback);
|
CppEditor::RenameCallback &&callback);
|
||||||
|
|
||||||
void gatherHelpItemForTooltip(
|
void gatherHelpItemForTooltip(
|
||||||
const LanguageServerProtocol::HoverRequest::Response &hoverResponse,
|
const LanguageServerProtocol::HoverRequest::Response &hoverResponse,
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
#include "clangeditordocumentprocessor.h"
|
#include "clangeditordocumentprocessor.h"
|
||||||
#include "clangdlocatorfilters.h"
|
#include "clangdlocatorfilters.h"
|
||||||
#include "clangprojectsettings.h"
|
#include "clangprojectsettings.h"
|
||||||
#include "clangrefactoringengine.h"
|
|
||||||
#include "clangutils.h"
|
#include "clangutils.h"
|
||||||
|
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
@@ -49,7 +48,6 @@
|
|||||||
#include <cppeditor/cppprojectfile.h>
|
#include <cppeditor/cppprojectfile.h>
|
||||||
#include <cppeditor/cpptoolsreuse.h>
|
#include <cppeditor/cpptoolsreuse.h>
|
||||||
#include <cppeditor/editordocumenthandle.h>
|
#include <cppeditor/editordocumenthandle.h>
|
||||||
#include <cppeditor/symbolfinder.h>
|
|
||||||
|
|
||||||
#include <languageclient/languageclientmanager.h>
|
#include <languageclient/languageclientmanager.h>
|
||||||
|
|
||||||
@@ -104,7 +102,7 @@ static const QList<TextEditor::TextDocument *> allCppDocuments()
|
|||||||
return Utils::qobject_container_cast<TextEditor::TextDocument *>(documents);
|
return Utils::qobject_container_cast<TextEditor::TextDocument *>(documents);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangModelManagerSupport::ClangModelManagerSupport() : m_refactoringEngine(new RefactoringEngine)
|
ClangModelManagerSupport::ClangModelManagerSupport()
|
||||||
{
|
{
|
||||||
QTC_CHECK(!m_instance);
|
QTC_CHECK(!m_instance);
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
@@ -189,10 +187,8 @@ void ClangModelManagerSupport::followSymbol(const CppEditor::CursorInEditor &dat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolFinder finder;
|
CppModelManager::followSymbol(data, std::move(processLinkCallback), resolveTarget, inNextSplit,
|
||||||
CppModelManager::builtinFollowSymbol().findLink(data, std::move(processLinkCallback),
|
CppModelManager::Backend::Builtin);
|
||||||
resolveTarget, CppModelManager::instance()->snapshot(),
|
|
||||||
data.editorWidget()->semanticInfo().doc, &finder, inNextSplit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangModelManagerSupport::switchDeclDef(const CppEditor::CursorInEditor &data,
|
void ClangModelManagerSupport::switchDeclDef(const CppEditor::CursorInEditor &data,
|
||||||
@@ -205,15 +201,52 @@ void ClangModelManagerSupport::switchDeclDef(const CppEditor::CursorInEditor &da
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolFinder finder;
|
CppModelManager::switchDeclDef(data, std::move(processLinkCallback),
|
||||||
CppModelManager::builtinFollowSymbol().switchDeclDef(data, std::move(processLinkCallback),
|
CppModelManager::Backend::Builtin);
|
||||||
CppModelManager::instance()->snapshot(), data.editorWidget()->semanticInfo().doc,
|
|
||||||
&finder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CppEditor::RefactoringEngineInterface &ClangModelManagerSupport::refactoringEngineInterface()
|
void ClangModelManagerSupport::startLocalRenaming(const CppEditor::CursorInEditor &data,
|
||||||
|
const CppEditor::ProjectPart *projectPart,
|
||||||
|
RenameCallback &&renameSymbolsCallback)
|
||||||
{
|
{
|
||||||
return *m_refactoringEngine;
|
if (ClangdClient * const client = clientForFile(data.filePath());
|
||||||
|
client && client->reachable()) {
|
||||||
|
client->findLocalUsages(data.textDocument(), data.cursor(),
|
||||||
|
std::move(renameSymbolsCallback));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CppModelManager::startLocalRenaming(data, projectPart,
|
||||||
|
std::move(renameSymbolsCallback), CppModelManager::Backend::Builtin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangModelManagerSupport::globalRename(const CppEditor::CursorInEditor &cursor,
|
||||||
|
CppEditor::UsagesCallback &&callback,
|
||||||
|
const QString &replacement)
|
||||||
|
{
|
||||||
|
if (ClangdClient * const client = clientForFile(cursor.filePath());
|
||||||
|
client && client->isFullyIndexed()) {
|
||||||
|
QTC_ASSERT(client->documentOpen(cursor.textDocument()),
|
||||||
|
client->openDocument(cursor.textDocument()));
|
||||||
|
client->findUsages(cursor.textDocument(), cursor.cursor(), replacement);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CppModelManager::globalRename(cursor, std::move(callback), replacement,
|
||||||
|
CppModelManager::Backend::Builtin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangModelManagerSupport::findUsages(const CppEditor::CursorInEditor &cursor,
|
||||||
|
CppEditor::UsagesCallback &&callback) const
|
||||||
|
{
|
||||||
|
if (ClangdClient * const client = clientForFile(cursor.filePath());
|
||||||
|
client && client->isFullyIndexed()) {
|
||||||
|
QTC_ASSERT(client->documentOpen(cursor.textDocument()),
|
||||||
|
client->openDocument(cursor.textDocument()));
|
||||||
|
client->findUsages(cursor.textDocument(), cursor.cursor(), {});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CppModelManager::findUsages(cursor, std::move(callback), CppModelManager::Backend::Builtin);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CppEditor::AbstractOverviewModel> ClangModelManagerSupport::createOverviewModel()
|
std::unique_ptr<CppEditor::AbstractOverviewModel> ClangModelManagerSupport::createOverviewModel()
|
||||||
|
@@ -68,7 +68,6 @@ public:
|
|||||||
TextEditor::BaseHoverHandler *createHoverHandler() override { return nullptr; }
|
TextEditor::BaseHoverHandler *createHoverHandler() override { return nullptr; }
|
||||||
CppEditor::BaseEditorDocumentProcessor *createEditorDocumentProcessor(
|
CppEditor::BaseEditorDocumentProcessor *createEditorDocumentProcessor(
|
||||||
TextEditor::TextDocument *baseTextDocument) override;
|
TextEditor::TextDocument *baseTextDocument) override;
|
||||||
CppEditor::RefactoringEngineInterface &refactoringEngineInterface() override;
|
|
||||||
std::unique_ptr<CppEditor::AbstractOverviewModel> createOverviewModel() override;
|
std::unique_ptr<CppEditor::AbstractOverviewModel> createOverviewModel() override;
|
||||||
bool supportsOutline(const TextEditor::TextDocument *document) const override;
|
bool supportsOutline(const TextEditor::TextDocument *document) const override;
|
||||||
bool supportsLocalUses(const TextEditor::TextDocument *document) const override;
|
bool supportsLocalUses(const TextEditor::TextDocument *document) const override;
|
||||||
@@ -93,6 +92,13 @@ private:
|
|||||||
bool inNextSplit) override;
|
bool inNextSplit) override;
|
||||||
void switchDeclDef(const CppEditor::CursorInEditor &data,
|
void switchDeclDef(const CppEditor::CursorInEditor &data,
|
||||||
Utils::ProcessLinkCallback &&processLinkCallback) override;
|
Utils::ProcessLinkCallback &&processLinkCallback) override;
|
||||||
|
void startLocalRenaming(const CppEditor::CursorInEditor &data,
|
||||||
|
const CppEditor::ProjectPart *projectPart,
|
||||||
|
CppEditor::RenameCallback &&renameSymbolsCallback) override;
|
||||||
|
void globalRename(const CppEditor::CursorInEditor &cursor, CppEditor::UsagesCallback &&callback,
|
||||||
|
const QString &replacement) override;
|
||||||
|
void findUsages(const CppEditor::CursorInEditor &cursor,
|
||||||
|
CppEditor::UsagesCallback &&callback) const override;
|
||||||
|
|
||||||
void onEditorOpened(Core::IEditor *editor);
|
void onEditorOpened(Core::IEditor *editor);
|
||||||
void onCurrentEditorChanged(Core::IEditor *newCurrent);
|
void onCurrentEditorChanged(Core::IEditor *newCurrent);
|
||||||
@@ -128,7 +134,6 @@ private:
|
|||||||
void watchForInternalChanges();
|
void watchForInternalChanges();
|
||||||
|
|
||||||
UiHeaderOnDiskManager m_uiHeaderOnDiskManager;
|
UiHeaderOnDiskManager m_uiHeaderOnDiskManager;
|
||||||
std::unique_ptr<CppEditor::RefactoringEngineInterface> m_refactoringEngine;
|
|
||||||
|
|
||||||
QHash<ProjectExplorer::Project *, ClangProjectSettings *> m_projectSettings;
|
QHash<ProjectExplorer::Project *, ClangProjectSettings *> m_projectSettings;
|
||||||
Utils::FutureSynchronizer m_generatorSynchronizer;
|
Utils::FutureSynchronizer m_generatorSynchronizer;
|
||||||
|
@@ -1,87 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "clangrefactoringengine.h"
|
|
||||||
|
|
||||||
#include "clangdclient.h"
|
|
||||||
#include "clangmodelmanagersupport.h"
|
|
||||||
|
|
||||||
#include <cppeditor/cppmodelmanager.h>
|
|
||||||
#include <languageclient/languageclientsymbolsupport.h>
|
|
||||||
#include <utils/textutils.h>
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
namespace ClangCodeModel {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
void RefactoringEngine::startLocalRenaming(const CppEditor::CursorInEditor &data,
|
|
||||||
const CppEditor::ProjectPart *projectPart,
|
|
||||||
RenameCallback &&renameSymbolsCallback)
|
|
||||||
{
|
|
||||||
ClangdClient * const client
|
|
||||||
= ClangModelManagerSupport::instance()->clientForFile(data.filePath());
|
|
||||||
if (client && client->reachable()) {
|
|
||||||
client->findLocalUsages(data.textDocument(), data.cursor(),
|
|
||||||
std::move(renameSymbolsCallback));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CppEditor::CppModelManager::builtinRefactoringEngine()
|
|
||||||
->startLocalRenaming(data, projectPart, std::move(renameSymbolsCallback));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RefactoringEngine::globalRename(const CppEditor::CursorInEditor &cursor,
|
|
||||||
CppEditor::UsagesCallback &&callback,
|
|
||||||
const QString &replacement)
|
|
||||||
{
|
|
||||||
ClangdClient * const client
|
|
||||||
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
|
||||||
if (!client || !client->isFullyIndexed()) {
|
|
||||||
CppEditor::CppModelManager::builtinRefactoringEngine()
|
|
||||||
->globalRename(cursor, std::move(callback), replacement);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QTC_ASSERT(client->documentOpen(cursor.textDocument()),
|
|
||||||
client->openDocument(cursor.textDocument()));
|
|
||||||
client->findUsages(cursor.textDocument(), cursor.cursor(), replacement);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RefactoringEngine::findUsages(const CppEditor::CursorInEditor &cursor,
|
|
||||||
CppEditor::UsagesCallback &&callback) const
|
|
||||||
{
|
|
||||||
ClangdClient * const client
|
|
||||||
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
|
||||||
if (!client || !client->isFullyIndexed()) {
|
|
||||||
CppEditor::CppModelManager::builtinRefactoringEngine()
|
|
||||||
->findUsages(cursor, std::move(callback));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QTC_ASSERT(client->documentOpen(cursor.textDocument()),
|
|
||||||
client->openDocument(cursor.textDocument()));
|
|
||||||
client->findUsages(cursor.textDocument(), cursor.cursor(), {});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace ClangCodeModel
|
|
@@ -1,58 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cppeditor/refactoringengineinterface.h>
|
|
||||||
#include <cppeditor/cppcursorinfo.h>
|
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
|
||||||
|
|
||||||
namespace ClangBackEnd {
|
|
||||||
class RefactoringClientInterface;
|
|
||||||
class RefactoringServerInterface;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ClangCodeModel {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class RefactoringEngine : public CppEditor::RefactoringEngineInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void startLocalRenaming(const CppEditor::CursorInEditor &data,
|
|
||||||
const CppEditor::ProjectPart *projectPart,
|
|
||||||
RenameCallback &&renameSymbolsCallback) override;
|
|
||||||
void globalRename(const CppEditor::CursorInEditor &cursor, CppEditor::UsagesCallback &&callback,
|
|
||||||
const QString &replacement) override;
|
|
||||||
void findUsages(const CppEditor::CursorInEditor &cursor,
|
|
||||||
CppEditor::UsagesCallback &&callback) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
using FutureCursorWatcher = QFutureWatcher<CppEditor::CursorInfo>;
|
|
||||||
std::unique_ptr<FutureCursorWatcher> m_watcher;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace ClangRefactoring
|
|
@@ -85,7 +85,6 @@ add_qtc_plugin(CppEditor
|
|||||||
cppquickfixsettingspage.cpp cppquickfixsettingspage.h
|
cppquickfixsettingspage.cpp cppquickfixsettingspage.h
|
||||||
cppquickfixsettingswidget.cpp cppquickfixsettingswidget.h cppquickfixsettingswidget.ui
|
cppquickfixsettingswidget.cpp cppquickfixsettingswidget.h cppquickfixsettingswidget.ui
|
||||||
cpprefactoringchanges.cpp cpprefactoringchanges.h
|
cpprefactoringchanges.cpp cpprefactoringchanges.h
|
||||||
cpprefactoringengine.cpp cpprefactoringengine.h
|
|
||||||
cppselectionchanger.cpp cppselectionchanger.h
|
cppselectionchanger.cpp cppselectionchanger.h
|
||||||
cppsemanticinfo.h
|
cppsemanticinfo.h
|
||||||
cppsemanticinfoupdater.cpp cppsemanticinfoupdater.h
|
cppsemanticinfoupdater.cpp cppsemanticinfoupdater.h
|
||||||
@@ -109,7 +108,6 @@ add_qtc_plugin(CppEditor
|
|||||||
insertionpointlocator.cpp insertionpointlocator.h
|
insertionpointlocator.cpp insertionpointlocator.h
|
||||||
projectinfo.cpp projectinfo.h
|
projectinfo.cpp projectinfo.h
|
||||||
projectpart.cpp projectpart.h
|
projectpart.cpp projectpart.h
|
||||||
refactoringengineinterface.h
|
|
||||||
resourcepreviewhoverhandler.cpp resourcepreviewhoverhandler.h
|
resourcepreviewhoverhandler.cpp resourcepreviewhoverhandler.h
|
||||||
searchsymbols.cpp searchsymbols.h
|
searchsymbols.cpp searchsymbols.h
|
||||||
semantichighlighter.cpp semantichighlighter.h
|
semantichighlighter.cpp semantichighlighter.h
|
||||||
|
@@ -26,18 +26,20 @@
|
|||||||
#include "cppbuiltinmodelmanagersupport.h"
|
#include "cppbuiltinmodelmanagersupport.h"
|
||||||
|
|
||||||
#include "builtineditordocumentprocessor.h"
|
#include "builtineditordocumentprocessor.h"
|
||||||
|
#include "cppcanonicalsymbol.h"
|
||||||
#include "cppcompletionassist.h"
|
#include "cppcompletionassist.h"
|
||||||
#include "cppeditorwidget.h"
|
#include "cppeditorwidget.h"
|
||||||
#include "cppelementevaluator.h"
|
#include "cppelementevaluator.h"
|
||||||
#include "cppfollowsymbolundercursor.h"
|
#include "cppfollowsymbolundercursor.h"
|
||||||
#include "cppoverviewmodel.h"
|
#include "cppoverviewmodel.h"
|
||||||
#include "cpprefactoringengine.h"
|
|
||||||
#include "cpptoolsreuse.h"
|
#include "cpptoolsreuse.h"
|
||||||
#include "symbolfinder.h"
|
#include "symbolfinder.h"
|
||||||
|
|
||||||
#include <app/app_version.h>
|
#include <app/app_version.h>
|
||||||
|
#include <clangsupport/sourcelocationscontainer.h>
|
||||||
#include <texteditor/basehoverhandler.h>
|
#include <texteditor/basehoverhandler.h>
|
||||||
#include <utils/executeondestruction.h>
|
#include <utils/executeondestruction.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
@@ -105,8 +107,7 @@ ModelManagerSupport::Ptr BuiltinModelManagerSupportProvider::createModelManagerS
|
|||||||
|
|
||||||
BuiltinModelManagerSupport::BuiltinModelManagerSupport()
|
BuiltinModelManagerSupport::BuiltinModelManagerSupport()
|
||||||
: m_completionAssistProvider(new InternalCompletionAssistProvider),
|
: m_completionAssistProvider(new InternalCompletionAssistProvider),
|
||||||
m_followSymbol(new FollowSymbolUnderCursor),
|
m_followSymbol(new FollowSymbolUnderCursor)
|
||||||
m_refactoringEngine(new CppRefactoringEngine)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,11 +135,6 @@ TextEditor::BaseHoverHandler *BuiltinModelManagerSupport::createHoverHandler()
|
|||||||
return new CppHoverHandler;
|
return new CppHoverHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefactoringEngineInterface &BuiltinModelManagerSupport::refactoringEngineInterface()
|
|
||||||
{
|
|
||||||
return *m_refactoringEngine;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<AbstractOverviewModel> BuiltinModelManagerSupport::createOverviewModel()
|
std::unique_ptr<AbstractOverviewModel> BuiltinModelManagerSupport::createOverviewModel()
|
||||||
{
|
{
|
||||||
return std::make_unique<OverviewModel>();
|
return std::make_unique<OverviewModel>();
|
||||||
@@ -163,4 +159,68 @@ void BuiltinModelManagerSupport::switchDeclDef(const CursorInEditor &data,
|
|||||||
&finder);
|
&finder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BuiltinModelManagerSupport::startLocalRenaming(const CursorInEditor &data,
|
||||||
|
const ProjectPart *,
|
||||||
|
RenameCallback &&renameSymbolsCallback)
|
||||||
|
{
|
||||||
|
CppEditorWidget *editorWidget = data.editorWidget();
|
||||||
|
QTC_ASSERT(editorWidget, renameSymbolsCallback(QString(),
|
||||||
|
ClangBackEnd::SourceLocationsContainer(),
|
||||||
|
0); return;);
|
||||||
|
editorWidget->updateSemanticInfo();
|
||||||
|
// Call empty callback
|
||||||
|
renameSymbolsCallback(QString(),
|
||||||
|
ClangBackEnd::SourceLocationsContainer(),
|
||||||
|
data.cursor().document()->revision());
|
||||||
|
}
|
||||||
|
|
||||||
|
void BuiltinModelManagerSupport::globalRename(const CursorInEditor &data,
|
||||||
|
UsagesCallback &&,
|
||||||
|
const QString &replacement)
|
||||||
|
{
|
||||||
|
CppModelManager *modelManager = CppModelManager::instance();
|
||||||
|
if (!modelManager)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CppEditorWidget *editorWidget = data.editorWidget();
|
||||||
|
QTC_ASSERT(editorWidget, return;);
|
||||||
|
|
||||||
|
SemanticInfo info = editorWidget->semanticInfo();
|
||||||
|
info.snapshot = modelManager->snapshot();
|
||||||
|
info.snapshot.insert(info.doc);
|
||||||
|
const QTextCursor &cursor = data.cursor();
|
||||||
|
if (const CPlusPlus::Macro *macro = findCanonicalMacro(cursor, info.doc)) {
|
||||||
|
modelManager->renameMacroUsages(*macro, replacement);
|
||||||
|
} else {
|
||||||
|
Internal::CanonicalSymbol cs(info.doc, info.snapshot);
|
||||||
|
CPlusPlus::Symbol *canonicalSymbol = cs(cursor);
|
||||||
|
if (canonicalSymbol)
|
||||||
|
modelManager->renameUsages(canonicalSymbol, cs.context(), replacement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BuiltinModelManagerSupport::findUsages(const CursorInEditor &data,
|
||||||
|
UsagesCallback &&) const
|
||||||
|
{
|
||||||
|
CppModelManager *modelManager = CppModelManager::instance();
|
||||||
|
if (!modelManager)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CppEditorWidget *editorWidget = data.editorWidget();
|
||||||
|
QTC_ASSERT(editorWidget, return;);
|
||||||
|
|
||||||
|
SemanticInfo info = editorWidget->semanticInfo();
|
||||||
|
info.snapshot = modelManager->snapshot();
|
||||||
|
info.snapshot.insert(info.doc);
|
||||||
|
const QTextCursor &cursor = data.cursor();
|
||||||
|
if (const CPlusPlus::Macro *macro = findCanonicalMacro(cursor, info.doc)) {
|
||||||
|
modelManager->findMacroUsages(*macro);
|
||||||
|
} else {
|
||||||
|
Internal::CanonicalSymbol cs(info.doc, info.snapshot);
|
||||||
|
CPlusPlus::Symbol *canonicalSymbol = cs(cursor);
|
||||||
|
if (canonicalSymbol)
|
||||||
|
modelManager->findUsages(canonicalSymbol, cs.context());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace CppEditor::Internal
|
} // namespace CppEditor::Internal
|
||||||
|
@@ -46,7 +46,6 @@ public:
|
|||||||
TextEditor::BaseHoverHandler *createHoverHandler() final;
|
TextEditor::BaseHoverHandler *createHoverHandler() final;
|
||||||
BaseEditorDocumentProcessor *createEditorDocumentProcessor(
|
BaseEditorDocumentProcessor *createEditorDocumentProcessor(
|
||||||
TextEditor::TextDocument *baseTextDocument) final;
|
TextEditor::TextDocument *baseTextDocument) final;
|
||||||
RefactoringEngineInterface &refactoringEngineInterface() final;
|
|
||||||
std::unique_ptr<AbstractOverviewModel> createOverviewModel() final;
|
std::unique_ptr<AbstractOverviewModel> createOverviewModel() final;
|
||||||
|
|
||||||
FollowSymbolUnderCursor &followSymbolInterface() { return *m_followSymbol; }
|
FollowSymbolUnderCursor &followSymbolInterface() { return *m_followSymbol; }
|
||||||
@@ -56,10 +55,15 @@ private:
|
|||||||
bool resolveTarget, bool inNextSplit) override;
|
bool resolveTarget, bool inNextSplit) override;
|
||||||
void switchDeclDef(const CursorInEditor &data,
|
void switchDeclDef(const CursorInEditor &data,
|
||||||
Utils::ProcessLinkCallback &&processLinkCallback) override;
|
Utils::ProcessLinkCallback &&processLinkCallback) override;
|
||||||
|
void startLocalRenaming(const CursorInEditor &data,
|
||||||
|
const ProjectPart *projectPart,
|
||||||
|
RenameCallback &&renameSymbolsCallback) override;
|
||||||
|
void globalRename(const CursorInEditor &data, UsagesCallback &&,
|
||||||
|
const QString &replacement) override;
|
||||||
|
void findUsages(const CursorInEditor &data, UsagesCallback &&) const override;
|
||||||
|
|
||||||
QScopedPointer<CppCompletionAssistProvider> m_completionAssistProvider;
|
QScopedPointer<CppCompletionAssistProvider> m_completionAssistProvider;
|
||||||
QScopedPointer<FollowSymbolUnderCursor> m_followSymbol;
|
QScopedPointer<FollowSymbolUnderCursor> m_followSymbol;
|
||||||
QScopedPointer<RefactoringEngineInterface> m_refactoringEngine;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class BuiltinModelManagerSupportProvider : public ModelManagerSupportProvider
|
class BuiltinModelManagerSupportProvider : public ModelManagerSupportProvider
|
||||||
|
@@ -189,8 +189,6 @@ QtcPlugin {
|
|||||||
"cppqtstyleindenter.h",
|
"cppqtstyleindenter.h",
|
||||||
"cpprefactoringchanges.cpp",
|
"cpprefactoringchanges.cpp",
|
||||||
"cpprefactoringchanges.h",
|
"cpprefactoringchanges.h",
|
||||||
"cpprefactoringengine.cpp",
|
|
||||||
"cpprefactoringengine.h",
|
|
||||||
"cppselectionchanger.cpp",
|
"cppselectionchanger.cpp",
|
||||||
"cppselectionchanger.h",
|
"cppselectionchanger.h",
|
||||||
"cppsemanticinfo.h",
|
"cppsemanticinfo.h",
|
||||||
@@ -235,7 +233,6 @@ QtcPlugin {
|
|||||||
"projectinfo.h",
|
"projectinfo.h",
|
||||||
"projectpart.cpp",
|
"projectpart.cpp",
|
||||||
"projectpart.h",
|
"projectpart.h",
|
||||||
"refactoringengineinterface.h",
|
|
||||||
"resourcepreviewhoverhandler.cpp",
|
"resourcepreviewhoverhandler.cpp",
|
||||||
"resourcepreviewhoverhandler.h",
|
"resourcepreviewhoverhandler.h",
|
||||||
"searchsymbols.cpp",
|
"searchsymbols.cpp",
|
||||||
|
@@ -50,7 +50,6 @@
|
|||||||
#include "cpptoolssettings.h"
|
#include "cpptoolssettings.h"
|
||||||
#include "cppuseselectionsupdater.h"
|
#include "cppuseselectionsupdater.h"
|
||||||
#include "cppworkingcopy.h"
|
#include "cppworkingcopy.h"
|
||||||
#include "refactoringengineinterface.h"
|
|
||||||
#include "symbolfinder.h"
|
#include "symbolfinder.h"
|
||||||
|
|
||||||
#include <clangsupport/sourcelocationscontainer.h>
|
#include <clangsupport/sourcelocationscontainer.h>
|
||||||
@@ -1044,7 +1043,7 @@ void CppEditorWidget::switchDeclarationDefinition(bool inNextSplit)
|
|||||||
if (self && link.hasValidTarget())
|
if (self && link.hasValidTarget())
|
||||||
self->openLink(link, split);
|
self->openLink(link, split);
|
||||||
};
|
};
|
||||||
CppModelManager::instance()->switchDeclDef(cursor, std::move(callback));
|
CppModelManager::switchDeclDef(cursor, std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorWidget::findLinkAt(const QTextCursor &cursor,
|
void CppEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||||
@@ -1084,7 +1083,7 @@ void CppEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
}
|
}
|
||||||
callback(link);
|
callback(link);
|
||||||
};
|
};
|
||||||
CppModelManager::instance()->followSymbol(
|
CppModelManager::followSymbol(
|
||||||
CursorInEditor{cursor, filePath, this, textDocument()},
|
CursorInEditor{cursor, filePath, this, textDocument()},
|
||||||
std::move(callbackWrapper),
|
std::move(callbackWrapper),
|
||||||
resolveTarget,
|
resolveTarget,
|
||||||
|
@@ -40,7 +40,6 @@
|
|||||||
#include "cpplocatorfilter.h"
|
#include "cpplocatorfilter.h"
|
||||||
#include "cppbuiltinmodelmanagersupport.h"
|
#include "cppbuiltinmodelmanagersupport.h"
|
||||||
#include "cpprefactoringchanges.h"
|
#include "cpprefactoringchanges.h"
|
||||||
#include "cpprefactoringengine.h"
|
|
||||||
#include "cppsourceprocessor.h"
|
#include "cppsourceprocessor.h"
|
||||||
#include "cpptoolsjsextension.h"
|
#include "cpptoolsjsextension.h"
|
||||||
#include "cpptoolsreuse.h"
|
#include "cpptoolsreuse.h"
|
||||||
@@ -136,8 +135,6 @@ protected:
|
|||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
|
|
||||||
using REType = RefactoringEngineType;
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static CppModelManager *m_instance;
|
static CppModelManager *m_instance;
|
||||||
@@ -197,10 +194,6 @@ public:
|
|||||||
QTimer m_delayedGcTimer;
|
QTimer m_delayedGcTimer;
|
||||||
QTimer m_fallbackProjectPartTimer;
|
QTimer m_fallbackProjectPartTimer;
|
||||||
|
|
||||||
// Refactoring
|
|
||||||
using REHash = QMap<REType, RefactoringEngineInterface *>;
|
|
||||||
REHash m_refactoringEngines;
|
|
||||||
|
|
||||||
CppLocatorData m_locatorData;
|
CppLocatorData m_locatorData;
|
||||||
std::unique_ptr<Core::ILocatorFilter> m_locatorFilter;
|
std::unique_ptr<Core::ILocatorFilter> m_locatorFilter;
|
||||||
std::unique_ptr<Core::ILocatorFilter> m_classesFilter;
|
std::unique_ptr<Core::ILocatorFilter> m_classesFilter;
|
||||||
@@ -308,43 +301,32 @@ QString CppModelManager::editorConfigurationFileName()
|
|||||||
return QLatin1String("<per-editor-defines>");
|
return QLatin1String("<per-editor-defines>");
|
||||||
}
|
}
|
||||||
|
|
||||||
static RefactoringEngineInterface *getRefactoringEngine(CppModelManagerPrivate::REHash &engines)
|
ModelManagerSupport *CppModelManager::modelManagerSupport(Backend backend) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!engines.empty(), return nullptr;);
|
return (backend == Backend::Builtin
|
||||||
RefactoringEngineInterface *currentEngine = engines[REType::BuiltIn];
|
? d->m_builtinModelManagerSupport : d->m_activeModelManagerSupport).data();
|
||||||
if (engines.find(REType::ClangCodeModel) != engines.end()) {
|
|
||||||
currentEngine = engines[REType::ClangCodeModel];
|
|
||||||
} else if (engines.find(REType::ClangRefactoring) != engines.end()) {
|
|
||||||
RefactoringEngineInterface *engine = engines[REType::ClangRefactoring];
|
|
||||||
if (engine->isRefactoringEngineAvailable())
|
|
||||||
currentEngine = engine;
|
|
||||||
}
|
|
||||||
return currentEngine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppModelManager::startLocalRenaming(const CursorInEditor &data,
|
void CppModelManager::startLocalRenaming(const CursorInEditor &data,
|
||||||
const ProjectPart *projectPart,
|
const ProjectPart *projectPart,
|
||||||
RenameCallback &&renameSymbolsCallback)
|
RenameCallback &&renameSymbolsCallback,
|
||||||
|
Backend backend)
|
||||||
{
|
{
|
||||||
RefactoringEngineInterface *engine = getRefactoringEngine(d->m_refactoringEngines);
|
instance()->modelManagerSupport(backend)
|
||||||
QTC_ASSERT(engine, return;);
|
->startLocalRenaming(data, projectPart, std::move(renameSymbolsCallback));
|
||||||
engine->startLocalRenaming(data, projectPart, std::move(renameSymbolsCallback));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppModelManager::globalRename(const CursorInEditor &data, UsagesCallback &&renameCallback,
|
void CppModelManager::globalRename(const CursorInEditor &data, UsagesCallback &&renameCallback,
|
||||||
const QString &replacement)
|
const QString &replacement, Backend backend)
|
||||||
{
|
{
|
||||||
RefactoringEngineInterface *engine = getRefactoringEngine(d->m_refactoringEngines);
|
instance()->modelManagerSupport(backend)
|
||||||
QTC_ASSERT(engine, return;);
|
->globalRename(data, std::move(renameCallback), replacement);
|
||||||
engine->globalRename(data, std::move(renameCallback), replacement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppModelManager::findUsages(const CursorInEditor &data,
|
void CppModelManager::findUsages(const CursorInEditor &data,
|
||||||
UsagesCallback &&showUsagesCallback) const
|
UsagesCallback &&showUsagesCallback, Backend backend)
|
||||||
{
|
{
|
||||||
RefactoringEngineInterface *engine = getRefactoringEngine(d->m_refactoringEngines);
|
instance()->modelManagerSupport(backend)->findUsages(data, std::move(showUsagesCallback));
|
||||||
QTC_ASSERT(engine, return;);
|
|
||||||
engine->findUsages(data, std::move(showUsagesCallback));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppModelManager::positionRequiresSignal(const QString &filePath, const QByteArray &content,
|
bool CppModelManager::positionRequiresSignal(const QString &filePath, const QByteArray &content,
|
||||||
@@ -456,22 +438,6 @@ bool CppModelManager::positionRequiresSignal(const QString &filePath, const QByt
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppModelManager::addRefactoringEngine(RefactoringEngineType type,
|
|
||||||
RefactoringEngineInterface *refactoringEngine)
|
|
||||||
{
|
|
||||||
instance()->d->m_refactoringEngines[type] = refactoringEngine;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppModelManager::removeRefactoringEngine(RefactoringEngineType type)
|
|
||||||
{
|
|
||||||
instance()->d->m_refactoringEngines.remove(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
RefactoringEngineInterface *CppModelManager::builtinRefactoringEngine()
|
|
||||||
{
|
|
||||||
return instance()->d->m_refactoringEngines.value(RefactoringEngineType::BuiltIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
FollowSymbolUnderCursor &CppModelManager::builtinFollowSymbol()
|
FollowSymbolUnderCursor &CppModelManager::builtinFollowSymbol()
|
||||||
{
|
{
|
||||||
return instance()->d->m_builtinModelManagerSupport.staticCast<BuiltinModelManagerSupport>()
|
return instance()->d->m_builtinModelManagerSupport.staticCast<BuiltinModelManagerSupport>()
|
||||||
@@ -622,8 +588,6 @@ void CppModelManager::initializeBuiltinModelManagerSupport()
|
|||||||
d->m_builtinModelManagerSupport
|
d->m_builtinModelManagerSupport
|
||||||
= BuiltinModelManagerSupportProvider().createModelManagerSupport();
|
= BuiltinModelManagerSupportProvider().createModelManagerSupport();
|
||||||
d->m_activeModelManagerSupport = d->m_builtinModelManagerSupport;
|
d->m_activeModelManagerSupport = d->m_builtinModelManagerSupport;
|
||||||
d->m_refactoringEngines[RefactoringEngineType::BuiltIn] =
|
|
||||||
&d->m_activeModelManagerSupport->refactoringEngineInterface();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CppModelManager::CppModelManager()
|
CppModelManager::CppModelManager()
|
||||||
@@ -1647,8 +1611,6 @@ void CppModelManager::activateClangCodeModel(
|
|||||||
QTC_ASSERT(modelManagerSupportProvider, return);
|
QTC_ASSERT(modelManagerSupportProvider, return);
|
||||||
|
|
||||||
d->m_activeModelManagerSupport = modelManagerSupportProvider->createModelManagerSupport();
|
d->m_activeModelManagerSupport = modelManagerSupportProvider->createModelManagerSupport();
|
||||||
d->m_refactoringEngines[RefactoringEngineType::ClangCodeModel] =
|
|
||||||
&d->m_activeModelManagerSupport->refactoringEngineInterface();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CppCompletionAssistProvider *CppModelManager::completionAssistProvider() const
|
CppCompletionAssistProvider *CppModelManager::completionAssistProvider() const
|
||||||
@@ -1668,16 +1630,17 @@ TextEditor::BaseHoverHandler *CppModelManager::createHoverHandler() const
|
|||||||
|
|
||||||
void CppModelManager::followSymbol(const CursorInEditor &data,
|
void CppModelManager::followSymbol(const CursorInEditor &data,
|
||||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||||
bool resolveTarget, bool inNextSplit)
|
bool resolveTarget, bool inNextSplit, Backend backend)
|
||||||
{
|
{
|
||||||
d->m_activeModelManagerSupport->followSymbol(data, std::move(processLinkCallback),
|
instance()->modelManagerSupport(backend)->followSymbol(data, std::move(processLinkCallback),
|
||||||
resolveTarget, inNextSplit);
|
resolveTarget, inNextSplit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppModelManager::switchDeclDef(const CursorInEditor &data,
|
void CppModelManager::switchDeclDef(const CursorInEditor &data,
|
||||||
Utils::ProcessLinkCallback &&processLinkCallback)
|
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||||
|
Backend backend)
|
||||||
{
|
{
|
||||||
d->m_activeModelManagerSupport->switchDeclDef(data, std::move(processLinkCallback));
|
instance()->modelManagerSupport(backend)->switchDeclDef(data, std::move(processLinkCallback));
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::ILocatorFilter *CppModelManager::createAuxiliaryCurrentDocumentFilter()
|
Core::ILocatorFilter *CppModelManager::createAuxiliaryCurrentDocumentFilter()
|
||||||
|
@@ -27,14 +27,16 @@
|
|||||||
|
|
||||||
#include "cppeditor_global.h"
|
#include "cppeditor_global.h"
|
||||||
|
|
||||||
#include "refactoringengineinterface.h"
|
#include "cursorineditor.h"
|
||||||
#include "projectinfo.h"
|
#include "projectinfo.h"
|
||||||
#include "projectpart.h"
|
#include "projectpart.h"
|
||||||
#include <projectexplorer/headerpath.h>
|
#include "usages.h"
|
||||||
|
|
||||||
#include <cplusplus/cppmodelmanagerbase.h>
|
#include <cplusplus/cppmodelmanagerbase.h>
|
||||||
#include <coreplugin/find/ifindfilter.h>
|
#include <coreplugin/find/ifindfilter.h>
|
||||||
#include <coreplugin/locator/ilocatorfilter.h>
|
#include <coreplugin/locator/ilocatorfilter.h>
|
||||||
|
#include <projectexplorer/headerpath.h>
|
||||||
|
#include <utils/link.h>
|
||||||
|
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -62,6 +64,7 @@ class CppIndexingSupport;
|
|||||||
class CppLocatorData;
|
class CppLocatorData;
|
||||||
class FollowSymbolUnderCursor;
|
class FollowSymbolUnderCursor;
|
||||||
class ModelManagerSupportProvider;
|
class ModelManagerSupportProvider;
|
||||||
|
class ModelManagerSupport;
|
||||||
class SymbolFinder;
|
class SymbolFinder;
|
||||||
class WorkingCopy;
|
class WorkingCopy;
|
||||||
|
|
||||||
@@ -73,15 +76,7 @@ class CppModelManagerPrivate;
|
|||||||
|
|
||||||
namespace Tests { class ModelManagerTestHelper; }
|
namespace Tests { class ModelManagerTestHelper; }
|
||||||
|
|
||||||
enum class RefactoringEngineType : int
|
class CPPEDITOR_EXPORT CppModelManager final : public CPlusPlus::CppModelManagerBase
|
||||||
{
|
|
||||||
BuiltIn = 0,
|
|
||||||
ClangCodeModel = 1,
|
|
||||||
ClangRefactoring = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
class CPPEDITOR_EXPORT CppModelManager final : public CPlusPlus::CppModelManagerBase,
|
|
||||||
public RefactoringEngineInterface
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -156,14 +151,6 @@ public:
|
|||||||
|
|
||||||
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
||||||
|
|
||||||
void startLocalRenaming(const CursorInEditor &data,
|
|
||||||
const ProjectPart *projectPart,
|
|
||||||
RenameCallback &&renameSymbolsCallback) final;
|
|
||||||
void globalRename(const CursorInEditor &data, UsagesCallback &&renameCallback,
|
|
||||||
const QString &replacement) final;
|
|
||||||
void findUsages(const CursorInEditor &data,
|
|
||||||
UsagesCallback &&showUsagesCallback) const final;
|
|
||||||
|
|
||||||
bool positionRequiresSignal(const QString &filePath, const QByteArray &content,
|
bool positionRequiresSignal(const QString &filePath, const QByteArray &content,
|
||||||
int position) const;
|
int position) const;
|
||||||
|
|
||||||
@@ -183,10 +170,22 @@ public:
|
|||||||
TextEditor::TextDocument *baseTextDocument) const;
|
TextEditor::TextDocument *baseTextDocument) const;
|
||||||
TextEditor::BaseHoverHandler *createHoverHandler() const;
|
TextEditor::BaseHoverHandler *createHoverHandler() const;
|
||||||
static FollowSymbolUnderCursor &builtinFollowSymbol();
|
static FollowSymbolUnderCursor &builtinFollowSymbol();
|
||||||
void followSymbol(const CursorInEditor &data, Utils::ProcessLinkCallback &&processLinkCallback,
|
|
||||||
bool resolveTarget, bool inNextSplit);
|
enum class Backend { Builtin, Best };
|
||||||
void switchDeclDef(const CursorInEditor &data,
|
static void followSymbol(const CursorInEditor &data,
|
||||||
Utils::ProcessLinkCallback &&processLinkCallback);
|
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||||
|
bool resolveTarget, bool inNextSplit, Backend backend = Backend::Best);
|
||||||
|
static void switchDeclDef(const CursorInEditor &data,
|
||||||
|
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||||
|
Backend backend = Backend::Best);
|
||||||
|
static void startLocalRenaming(const CursorInEditor &data, const ProjectPart *projectPart,
|
||||||
|
RenameCallback &&renameSymbolsCallback,
|
||||||
|
Backend backend = Backend::Best);
|
||||||
|
static void globalRename(const CursorInEditor &data, UsagesCallback &&renameCallback,
|
||||||
|
const QString &replacement, Backend backend = Backend::Best);
|
||||||
|
static void findUsages(const CursorInEditor &data, UsagesCallback &&showUsagesCallback,
|
||||||
|
Backend backend = Backend::Best);
|
||||||
|
|
||||||
static Core::ILocatorFilter *createAuxiliaryCurrentDocumentFilter();
|
static Core::ILocatorFilter *createAuxiliaryCurrentDocumentFilter();
|
||||||
|
|
||||||
std::unique_ptr<AbstractOverviewModel> createOverviewModel() const;
|
std::unique_ptr<AbstractOverviewModel> createOverviewModel() const;
|
||||||
@@ -214,11 +213,6 @@ public:
|
|||||||
static QString configurationFileName();
|
static QString configurationFileName();
|
||||||
static QString editorConfigurationFileName();
|
static QString editorConfigurationFileName();
|
||||||
|
|
||||||
static void addRefactoringEngine(RefactoringEngineType type,
|
|
||||||
RefactoringEngineInterface *refactoringEngine);
|
|
||||||
static void removeRefactoringEngine(RefactoringEngineType type);
|
|
||||||
static RefactoringEngineInterface *builtinRefactoringEngine();
|
|
||||||
|
|
||||||
void setLocatorFilter(std::unique_ptr<Core::ILocatorFilter> &&filter);
|
void setLocatorFilter(std::unique_ptr<Core::ILocatorFilter> &&filter);
|
||||||
void setClassesFilter(std::unique_ptr<Core::ILocatorFilter> &&filter);
|
void setClassesFilter(std::unique_ptr<Core::ILocatorFilter> &&filter);
|
||||||
void setIncludesFilter(std::unique_ptr<Core::ILocatorFilter> &&filter);
|
void setIncludesFilter(std::unique_ptr<Core::ILocatorFilter> &&filter);
|
||||||
@@ -292,6 +286,8 @@ private:
|
|||||||
|
|
||||||
WorkingCopy buildWorkingCopyList();
|
WorkingCopy buildWorkingCopyList();
|
||||||
|
|
||||||
|
ModelManagerSupport *modelManagerSupport(Backend backend) const;
|
||||||
|
|
||||||
void ensureUpdated();
|
void ensureUpdated();
|
||||||
QStringList internalProjectFiles() const;
|
QStringList internalProjectFiles() const;
|
||||||
ProjectExplorer::HeaderPaths internalHeaderPaths() const;
|
ProjectExplorer::HeaderPaths internalHeaderPaths() const;
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cppeditor_global.h"
|
#include "cppeditor_global.h"
|
||||||
|
#include "cursorineditor.h"
|
||||||
|
#include "usages.h"
|
||||||
|
|
||||||
#include <utils/link.h>
|
#include <utils/link.h>
|
||||||
|
|
||||||
@@ -44,7 +46,7 @@ namespace CppEditor {
|
|||||||
class AbstractOverviewModel;
|
class AbstractOverviewModel;
|
||||||
class BaseEditorDocumentProcessor;
|
class BaseEditorDocumentProcessor;
|
||||||
class CppCompletionAssistProvider;
|
class CppCompletionAssistProvider;
|
||||||
class CursorInEditor;
|
class ProjectPart;
|
||||||
class RefactoringEngineInterface;
|
class RefactoringEngineInterface;
|
||||||
|
|
||||||
class CPPEDITOR_EXPORT ModelManagerSupport
|
class CPPEDITOR_EXPORT ModelManagerSupport
|
||||||
@@ -60,7 +62,6 @@ public:
|
|||||||
virtual TextEditor::BaseHoverHandler *createHoverHandler() = 0;
|
virtual TextEditor::BaseHoverHandler *createHoverHandler() = 0;
|
||||||
virtual BaseEditorDocumentProcessor *createEditorDocumentProcessor(
|
virtual BaseEditorDocumentProcessor *createEditorDocumentProcessor(
|
||||||
TextEditor::TextDocument *baseTextDocument) = 0;
|
TextEditor::TextDocument *baseTextDocument) = 0;
|
||||||
virtual RefactoringEngineInterface &refactoringEngineInterface() = 0;
|
|
||||||
virtual std::unique_ptr<AbstractOverviewModel> createOverviewModel() = 0;
|
virtual std::unique_ptr<AbstractOverviewModel> createOverviewModel() = 0;
|
||||||
virtual bool supportsOutline(const TextEditor::TextDocument *) const { return true; }
|
virtual bool supportsOutline(const TextEditor::TextDocument *) const { return true; }
|
||||||
virtual bool hasSpecialHoverHandler(const TextEditor::TextDocument *) const { return false; }
|
virtual bool hasSpecialHoverHandler(const TextEditor::TextDocument *) const { return false; }
|
||||||
@@ -71,6 +72,14 @@ public:
|
|||||||
bool resolveTarget, bool inNextSplit) = 0;
|
bool resolveTarget, bool inNextSplit) = 0;
|
||||||
virtual void switchDeclDef(const CursorInEditor &data,
|
virtual void switchDeclDef(const CursorInEditor &data,
|
||||||
Utils::ProcessLinkCallback &&processLinkCallback) = 0;
|
Utils::ProcessLinkCallback &&processLinkCallback) = 0;
|
||||||
|
virtual void startLocalRenaming(const CursorInEditor &data,
|
||||||
|
const ProjectPart *projectPart,
|
||||||
|
RenameCallback &&renameSymbolsCallback) = 0;
|
||||||
|
virtual void globalRename(const CursorInEditor &data,
|
||||||
|
UsagesCallback &&renameCallback,
|
||||||
|
const QString &replacement) = 0;
|
||||||
|
virtual void findUsages(const CursorInEditor &data,
|
||||||
|
UsagesCallback &&showUsagesCallback) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPPEDITOR_EXPORT ModelManagerSupportProvider
|
class CPPEDITOR_EXPORT ModelManagerSupportProvider
|
||||||
|
@@ -1,106 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "cpprefactoringengine.h"
|
|
||||||
|
|
||||||
#include "cppcanonicalsymbol.h"
|
|
||||||
#include "cppeditorwidget.h"
|
|
||||||
#include "cppmodelmanager.h"
|
|
||||||
#include "cppsemanticinfo.h"
|
|
||||||
#include "cpptoolsreuse.h"
|
|
||||||
#include "cppfollowsymbolundercursor.h"
|
|
||||||
|
|
||||||
#include <clangsupport/sourcelocationscontainer.h>
|
|
||||||
#include <texteditor/texteditor.h>
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
namespace CppEditor::Internal {
|
|
||||||
|
|
||||||
void CppRefactoringEngine::startLocalRenaming(const CursorInEditor &data,
|
|
||||||
const ProjectPart *,
|
|
||||||
RenameCallback &&renameSymbolsCallback)
|
|
||||||
{
|
|
||||||
CppEditorWidget *editorWidget = data.editorWidget();
|
|
||||||
QTC_ASSERT(editorWidget, renameSymbolsCallback(QString(),
|
|
||||||
ClangBackEnd::SourceLocationsContainer(),
|
|
||||||
0); return;);
|
|
||||||
editorWidget->updateSemanticInfo();
|
|
||||||
// Call empty callback
|
|
||||||
renameSymbolsCallback(QString(),
|
|
||||||
ClangBackEnd::SourceLocationsContainer(),
|
|
||||||
data.cursor().document()->revision());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppRefactoringEngine::globalRename(const CursorInEditor &data,
|
|
||||||
UsagesCallback &&,
|
|
||||||
const QString &replacement)
|
|
||||||
{
|
|
||||||
CppModelManager *modelManager = CppModelManager::instance();
|
|
||||||
if (!modelManager)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CppEditorWidget *editorWidget = data.editorWidget();
|
|
||||||
QTC_ASSERT(editorWidget, return;);
|
|
||||||
|
|
||||||
SemanticInfo info = editorWidget->semanticInfo();
|
|
||||||
info.snapshot = modelManager->snapshot();
|
|
||||||
info.snapshot.insert(info.doc);
|
|
||||||
const QTextCursor &cursor = data.cursor();
|
|
||||||
if (const CPlusPlus::Macro *macro = findCanonicalMacro(cursor, info.doc)) {
|
|
||||||
modelManager->renameMacroUsages(*macro, replacement);
|
|
||||||
} else {
|
|
||||||
Internal::CanonicalSymbol cs(info.doc, info.snapshot);
|
|
||||||
CPlusPlus::Symbol *canonicalSymbol = cs(cursor);
|
|
||||||
if (canonicalSymbol)
|
|
||||||
modelManager->renameUsages(canonicalSymbol, cs.context(), replacement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppRefactoringEngine::findUsages(const CursorInEditor &data,
|
|
||||||
UsagesCallback &&) const
|
|
||||||
{
|
|
||||||
CppModelManager *modelManager = CppModelManager::instance();
|
|
||||||
if (!modelManager)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CppEditorWidget *editorWidget = data.editorWidget();
|
|
||||||
QTC_ASSERT(editorWidget, return;);
|
|
||||||
|
|
||||||
SemanticInfo info = editorWidget->semanticInfo();
|
|
||||||
info.snapshot = modelManager->snapshot();
|
|
||||||
info.snapshot.insert(info.doc);
|
|
||||||
const QTextCursor &cursor = data.cursor();
|
|
||||||
if (const CPlusPlus::Macro *macro = findCanonicalMacro(cursor, info.doc)) {
|
|
||||||
modelManager->findMacroUsages(*macro);
|
|
||||||
} else {
|
|
||||||
Internal::CanonicalSymbol cs(info.doc, info.snapshot);
|
|
||||||
CPlusPlus::Symbol *canonicalSymbol = cs(cursor);
|
|
||||||
if (canonicalSymbol)
|
|
||||||
modelManager->findUsages(canonicalSymbol, cs.context());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace CppEditor::Internal
|
|
@@ -1,43 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "refactoringengineinterface.h"
|
|
||||||
|
|
||||||
namespace CppEditor::Internal {
|
|
||||||
|
|
||||||
class CppRefactoringEngine : public RefactoringEngineInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void startLocalRenaming(const CursorInEditor &data,
|
|
||||||
const ProjectPart *projectPart,
|
|
||||||
RenameCallback &&renameSymbolsCallback) override;
|
|
||||||
void globalRename(const CursorInEditor &data, UsagesCallback &&,
|
|
||||||
const QString &replacement) override;
|
|
||||||
void findUsages(const CursorInEditor &data, UsagesCallback &&) const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace CppEditor::Internal
|
|
@@ -29,11 +29,19 @@
|
|||||||
|
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
namespace ClangBackEnd { class SourceLocationsContainer; }
|
||||||
namespace TextEditor { class TextDocument; }
|
namespace TextEditor { class TextDocument; }
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
class CppEditorWidget;
|
class CppEditorWidget;
|
||||||
|
|
||||||
|
// TODO: Move to a better place.
|
||||||
|
using RenameCallback = std::function<void(const QString &,
|
||||||
|
const ClangBackEnd::SourceLocationsContainer &,
|
||||||
|
int)>;
|
||||||
|
|
||||||
class CursorInEditor
|
class CursorInEditor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -1,73 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "cppeditor_global.h"
|
|
||||||
#include "cursorineditor.h"
|
|
||||||
#include "usages.h"
|
|
||||||
|
|
||||||
#include <utils/link.h>
|
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
#include <cplusplus/CppDocument.h>
|
|
||||||
|
|
||||||
namespace ClangBackEnd { class SourceLocationsContainer; }
|
|
||||||
namespace TextEditor { class TextEditorWidget; }
|
|
||||||
|
|
||||||
namespace CppEditor {
|
|
||||||
|
|
||||||
class ProjectPart;
|
|
||||||
class SymbolFinder;
|
|
||||||
|
|
||||||
enum class CallType
|
|
||||||
{
|
|
||||||
Synchronous,
|
|
||||||
Asynchronous
|
|
||||||
};
|
|
||||||
|
|
||||||
// NOTE: This interface is not supposed to be owned as an interface pointer
|
|
||||||
class CPPEDITOR_EXPORT RefactoringEngineInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using RenameCallback = std::function<void(const QString &,
|
|
||||||
const ClangBackEnd::SourceLocationsContainer &,
|
|
||||||
int)>;
|
|
||||||
using Link = Utils::Link;
|
|
||||||
|
|
||||||
virtual ~RefactoringEngineInterface() = default;
|
|
||||||
|
|
||||||
virtual void startLocalRenaming(const CursorInEditor &data,
|
|
||||||
const ProjectPart *projectPart,
|
|
||||||
RenameCallback &&renameSymbolsCallback) = 0;
|
|
||||||
virtual void globalRename(const CursorInEditor &data,
|
|
||||||
UsagesCallback &&renameCallback,
|
|
||||||
const QString &replacement) = 0;
|
|
||||||
virtual void findUsages(const CursorInEditor &data,
|
|
||||||
UsagesCallback &&showUsagesCallback) const = 0;
|
|
||||||
virtual bool isRefactoringEngineAvailable() const { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace CppEditor
|
|
Reference in New Issue
Block a user