diff options
40 files changed, 5 insertions, 1624 deletions
diff --git a/src/libs/clangsupport/clangrefactoringclientmessages.h b/src/libs/clangsupport/clangrefactoringclientmessages.h index 012ca0431d..87b61b4c6b 100644 --- a/src/libs/clangsupport/clangrefactoringclientmessages.h +++ b/src/libs/clangsupport/clangrefactoringclientmessages.h @@ -27,6 +27,5 @@ #include "alivemessage.h" #include "progressmessage.h" -#include "sourcelocationsforrenamingmessage.h" #include "sourcerangesanddiagnosticsforquerymessage.h" #include "sourcerangesforquerymessage.h" diff --git a/src/libs/clangsupport/clangrefactoringservermessages.h b/src/libs/clangsupport/clangrefactoringservermessages.h index dd1cb3a6d7..8a79518c7e 100644 --- a/src/libs/clangsupport/clangrefactoringservermessages.h +++ b/src/libs/clangsupport/clangrefactoringservermessages.h @@ -27,7 +27,6 @@ #include "cancelmessage.h" #include "endmessage.h" -#include "requestsourcelocationforrenamingmessage.h" #include "requestsourcerangesanddiagnosticsforquerymessage.h" #include "requestsourcerangesforquerymessage.h" #include "removegeneratedfilesmessage.h" diff --git a/src/libs/clangsupport/clangsupport-lib.pri b/src/libs/clangsupport/clangsupport-lib.pri index 1705be3c26..18896c0ea0 100644 --- a/src/libs/clangsupport/clangsupport-lib.pri +++ b/src/libs/clangsupport/clangsupport-lib.pri @@ -56,14 +56,12 @@ SOURCES += \ $$PWD/requestannotationsmessage.cpp \ $$PWD/requestfollowsymbolmessage.cpp \ $$PWD/requestreferencesmessage.cpp \ - $$PWD/requestsourcelocationforrenamingmessage.cpp \ $$PWD/requestsourcerangesanddiagnosticsforquerymessage.cpp \ $$PWD/requestsourcerangesforquerymessage.cpp \ $$PWD/requesttooltipmessage.cpp \ $$PWD/sourcelocationcontainer.cpp \ $$PWD/sourcelocationcontainerv2.cpp \ $$PWD/sourcelocationscontainer.cpp \ - $$PWD/sourcelocationsforrenamingmessage.cpp \ $$PWD/sourcerangecontainer.cpp \ $$PWD/processcreator.cpp \ $$PWD/processexception.cpp \ @@ -120,7 +118,6 @@ HEADERS += \ $$PWD/projectpartid.h \ $$PWD/projectpartsstorage.h \ $$PWD/projectpartsstorageinterface.h \ - $$PWD/projectsourcechunk.h \ $$PWD/requestcompletionsmessage.h \ $$PWD/echomessage.h \ $$PWD/endmessage.h \ @@ -164,14 +161,12 @@ HEADERS += \ $$PWD/requestannotationsmessage.h \ $$PWD/requestfollowsymbolmessage.h \ $$PWD/requestreferencesmessage.h \ - $$PWD/requestsourcelocationforrenamingmessage.h \ $$PWD/requestsourcerangesanddiagnosticsforquerymessage.h \ $$PWD/requestsourcerangesforquerymessage.h \ $$PWD/requesttooltipmessage.h \ $$PWD/sourcelocationcontainer.h \ $$PWD/sourcelocationcontainerv2.h \ $$PWD/sourcelocationscontainer.h \ - $$PWD/sourcelocationsforrenamingmessage.h \ $$PWD/sourcerangecontainer.h \ $$PWD/filepath.h \ $$PWD/processcreator.h \ diff --git a/src/libs/clangsupport/refactoringclientinterface.cpp b/src/libs/clangsupport/refactoringclientinterface.cpp index 5e3b98df66..e862e4e4d9 100644 --- a/src/libs/clangsupport/refactoringclientinterface.cpp +++ b/src/libs/clangsupport/refactoringclientinterface.cpp @@ -38,9 +38,6 @@ void RefactoringClientInterface::dispatch(const MessageEnvelop &messageEnvelop) case MessageType::AliveMessage: alive(); break; - case MessageType::SourceLocationsForRenamingMessage: - sourceLocationsForRenamingMessage(messageEnvelop.message<SourceLocationsForRenamingMessage>()); - break; case MessageType::SourceRangesAndDiagnosticsForQueryMessage: sourceRangesAndDiagnosticsForQueryMessage(messageEnvelop.message<SourceRangesAndDiagnosticsForQueryMessage>()); break; diff --git a/src/libs/clangsupport/refactoringclientinterface.h b/src/libs/clangsupport/refactoringclientinterface.h index c1127592d6..c7d2fcf7d0 100644 --- a/src/libs/clangsupport/refactoringclientinterface.h +++ b/src/libs/clangsupport/refactoringclientinterface.h @@ -47,10 +47,8 @@ public: void dispatch(const MessageEnvelop &messageEnvelop) override; virtual void alive() = 0; - virtual void sourceLocationsForRenamingMessage(SourceLocationsForRenamingMessage &&message) = 0; virtual void sourceRangesAndDiagnosticsForQueryMessage(SourceRangesAndDiagnosticsForQueryMessage &&message) = 0; virtual void sourceRangesForQueryMessage(SourceRangesForQueryMessage &&message) = 0; - virtual void setLocalRenamingCallback(RenameCallback &&localRenamingCallback) = 0; virtual void progress(ProgressMessage &&message) = 0; protected: diff --git a/src/libs/clangsupport/refactoringclientproxy.cpp b/src/libs/clangsupport/refactoringclientproxy.cpp index 646cb0e161..b2d30d7bfb 100644 --- a/src/libs/clangsupport/refactoringclientproxy.cpp +++ b/src/libs/clangsupport/refactoringclientproxy.cpp @@ -66,11 +66,6 @@ void RefactoringClientProxy::alive() writeMessageBlock.write(AliveMessage()); } -void RefactoringClientProxy::sourceLocationsForRenamingMessage(SourceLocationsForRenamingMessage &&message) -{ - writeMessageBlock.write(message); -} - void RefactoringClientProxy::sourceRangesAndDiagnosticsForQueryMessage(SourceRangesAndDiagnosticsForQueryMessage &&message) { writeMessageBlock.write(message); diff --git a/src/libs/clangsupport/refactoringclientproxy.h b/src/libs/clangsupport/refactoringclientproxy.h index 07cba05e8d..371ae91f82 100644 --- a/src/libs/clangsupport/refactoringclientproxy.h +++ b/src/libs/clangsupport/refactoringclientproxy.h @@ -50,13 +50,10 @@ public: void readMessages(); void alive() override; - void sourceLocationsForRenamingMessage(SourceLocationsForRenamingMessage &&message) override; void sourceRangesAndDiagnosticsForQueryMessage(SourceRangesAndDiagnosticsForQueryMessage &&message) override; void sourceRangesForQueryMessage(SourceRangesForQueryMessage &&message) override; void progress(ProgressMessage &&message) override; - void setLocalRenamingCallback(RenameCallback &&) final {} - private: ClangBackEnd::WriteMessageBlock writeMessageBlock; ClangBackEnd::ReadMessageBlock readMessageBlock; diff --git a/src/libs/clangsupport/refactoringserverinterface.cpp b/src/libs/clangsupport/refactoringserverinterface.cpp index a95837f80a..6fcaa0f054 100644 --- a/src/libs/clangsupport/refactoringserverinterface.cpp +++ b/src/libs/clangsupport/refactoringserverinterface.cpp @@ -38,9 +38,6 @@ void RefactoringServerInterface::dispatch(const MessageEnvelop &messageEnvelop) case MessageType::EndMessage: end(); break; - case MessageType::RequestSourceLocationsForRenamingMessage: - requestSourceLocationsForRenamingMessage(messageEnvelop.message<RequestSourceLocationsForRenamingMessage>()); - break; case MessageType::RequestSourceRangesAndDiagnosticsForQueryMessage: requestSourceRangesAndDiagnosticsForQueryMessage(messageEnvelop.message<RequestSourceRangesAndDiagnosticsForQueryMessage>()); break; diff --git a/src/libs/clangsupport/refactoringserverinterface.h b/src/libs/clangsupport/refactoringserverinterface.h index 2dcc503860..a8a677427c 100644 --- a/src/libs/clangsupport/refactoringserverinterface.h +++ b/src/libs/clangsupport/refactoringserverinterface.h @@ -32,7 +32,6 @@ namespace ClangBackEnd { class RefactoringClientInterface; -class RequestSourceLocationsForRenamingMessage; class RequestSourceRangesAndDiagnosticsForQueryMessage; class RequestSourceRangesForQueryMessage; class CancelMessage; @@ -46,7 +45,6 @@ public: void dispatch(const MessageEnvelop &messageEnvelop) override; virtual void end() = 0; - virtual void requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) = 0; virtual void requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message) = 0; virtual void requestSourceRangesForQueryMessage(RequestSourceRangesForQueryMessage &&message) = 0; virtual void cancel() = 0; diff --git a/src/libs/clangsupport/refactoringserverproxy.cpp b/src/libs/clangsupport/refactoringserverproxy.cpp index 2208f3a0ce..a206a2531b 100644 --- a/src/libs/clangsupport/refactoringserverproxy.cpp +++ b/src/libs/clangsupport/refactoringserverproxy.cpp @@ -50,11 +50,6 @@ void RefactoringServerProxy::end() m_writeMessageBlock.write(EndMessage()); } -void RefactoringServerProxy::requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) -{ - m_writeMessageBlock.write(message); -} - void RefactoringServerProxy::requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message) { m_writeMessageBlock.write(message); diff --git a/src/libs/clangsupport/refactoringserverproxy.h b/src/libs/clangsupport/refactoringserverproxy.h index 34861767d8..4b91036c46 100644 --- a/src/libs/clangsupport/refactoringserverproxy.h +++ b/src/libs/clangsupport/refactoringserverproxy.h @@ -52,7 +52,6 @@ public: explicit RefactoringServerProxy(RefactoringClientInterface *client, QIODevice *ioDevice); void end() override; - void requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) override; void requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message) override; void requestSourceRangesForQueryMessage(RequestSourceRangesForQueryMessage &&message) override; void updateProjectParts(UpdateProjectPartsMessage &&message) override; diff --git a/src/libs/clangsupport/requestsourcelocationforrenamingmessage.cpp b/src/libs/clangsupport/requestsourcelocationforrenamingmessage.cpp deleted file mode 100644 index dd25a3ebae..0000000000 --- a/src/libs/clangsupport/requestsourcelocationforrenamingmessage.cpp +++ /dev/null @@ -1,41 +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 "requestsourcelocationforrenamingmessage.h" - -namespace ClangBackEnd { - -QDebug operator<<(QDebug debug, const RequestSourceLocationsForRenamingMessage &message) -{ - debug.nospace() << "RequestSourceLocationsForRenamingMessage(" - << message.filePath << ", " - << message.line << ", " - << message.column << ", " - << message.unsavedContent << ")"; - - return debug; -} - -} // namespace ClangBackEnd diff --git a/src/libs/clangsupport/requestsourcelocationforrenamingmessage.h b/src/libs/clangsupport/requestsourcelocationforrenamingmessage.h deleted file mode 100644 index 9082e0dfaf..0000000000 --- a/src/libs/clangsupport/requestsourcelocationforrenamingmessage.h +++ /dev/null @@ -1,108 +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 "clangsupport_global.h" -#include "filepath.h" - -#include <utils/smallstringvector.h> - -namespace ClangBackEnd { - -class CLANGSUPPORT_EXPORT RequestSourceLocationsForRenamingMessage -{ -public: - RequestSourceLocationsForRenamingMessage() = default; - RequestSourceLocationsForRenamingMessage(FilePath &&filePath, - uint line, - uint column, - Utils::SmallString &&unsavedContent, - Utils::SmallStringVector &&commandLine, - int textDocumentRevision) - : filePath(std::move(filePath)), - unsavedContent(std::move(unsavedContent)), - commandLine(std::move(commandLine)), - line(line), - column(column), - textDocumentRevision(textDocumentRevision) - {} - - friend QDataStream &operator<<(QDataStream &out, const RequestSourceLocationsForRenamingMessage &message) - { - out << message.filePath; - out << message.unsavedContent; - out << message.commandLine; - out << message.line; - out << message.column; - out << message.textDocumentRevision; - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, RequestSourceLocationsForRenamingMessage &message) - { - in >> message.filePath; - in >> message.unsavedContent; - in >> message.commandLine; - in >> message.line; - in >> message.column; - in >> message.textDocumentRevision; - - return in; - } - - friend bool operator==(const RequestSourceLocationsForRenamingMessage &first, const RequestSourceLocationsForRenamingMessage &second) - { - return first.filePath == second.filePath - && first.line == second.line - && first.column == second.column - && first.textDocumentRevision == second.textDocumentRevision - && first.unsavedContent == second.unsavedContent - && first.commandLine == second.commandLine; - } - - RequestSourceLocationsForRenamingMessage clone() const - { - return RequestSourceLocationsForRenamingMessage(filePath.clone(), - line, column, - unsavedContent.clone(), - commandLine.clone(), - textDocumentRevision); - } - -public: - FilePath filePath; - Utils::SmallString unsavedContent; - Utils::SmallStringVector commandLine; - uint line = 1; - uint column = 1; - int textDocumentRevision = 1; -}; - -CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const RequestSourceLocationsForRenamingMessage &message); - -DECLARE_MESSAGE(RequestSourceLocationsForRenamingMessage) -} // namespace ClangBackEnd diff --git a/src/libs/clangsupport/sourcelocationsforrenamingmessage.cpp b/src/libs/clangsupport/sourcelocationsforrenamingmessage.cpp deleted file mode 100644 index 3490738531..0000000000 --- a/src/libs/clangsupport/sourcelocationsforrenamingmessage.cpp +++ /dev/null @@ -1,39 +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 "sourcelocationsforrenamingmessage.h" - -namespace ClangBackEnd { - -QDebug operator<<(QDebug debug, const SourceLocationsForRenamingMessage &message) -{ - debug.nospace() << "SourceLocationsForRenamingMessage(" - << message.sourceLocations - << ")"; - - return debug; -} - -} // namespace ClangBackEnd diff --git a/src/libs/clangsupport/sourcelocationsforrenamingmessage.h b/src/libs/clangsupport/sourcelocationsforrenamingmessage.h deleted file mode 100644 index 5be072677c..0000000000 --- a/src/libs/clangsupport/sourcelocationsforrenamingmessage.h +++ /dev/null @@ -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. -** -****************************************************************************/ - -#pragma once - -#include "sourcelocationscontainer.h" - -#include <utils/smallstring.h> - -namespace ClangBackEnd { - -class SourceLocationsForRenamingMessage -{ -public: - SourceLocationsForRenamingMessage() = default; - SourceLocationsForRenamingMessage(Utils::SmallString &&symbolName, - SourceLocationsContainer &&sourceLocationContainer, - int textDocumentRevision) - : symbolName(std::move(symbolName)), - sourceLocations(std::move(sourceLocationContainer)), - textDocumentRevision(textDocumentRevision) - {} - - friend QDataStream &operator<<(QDataStream &out, const SourceLocationsForRenamingMessage &message) - { - out << message.symbolName; - out << message.sourceLocations; - out << message.textDocumentRevision; - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, SourceLocationsForRenamingMessage &message) - { - in >> message.symbolName; - in >> message.sourceLocations; - in >> message.textDocumentRevision; - - return in; - } - - friend bool operator==(const SourceLocationsForRenamingMessage &first, const SourceLocationsForRenamingMessage &second) - { - return first.textDocumentRevision == second.textDocumentRevision - && first.symbolName == second.symbolName - && first.sourceLocations == second.sourceLocations; - } - - SourceLocationsForRenamingMessage clone() const - { - return SourceLocationsForRenamingMessage(symbolName.clone(), - sourceLocations.clone(), - textDocumentRevision); - } - -public: - Utils::SmallString symbolName; - SourceLocationsContainer sourceLocations; - int textDocumentRevision = 0; -}; - -CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const SourceLocationsForRenamingMessage &message); - -DECLARE_MESSAGE(SourceLocationsForRenamingMessage) -} // namespace ClangBackEnd diff --git a/src/plugins/clangrefactoring/clangrefactoringplugin.cpp b/src/plugins/clangrefactoring/clangrefactoringplugin.cpp index 059eff4c78..d33e4e2b88 100644 --- a/src/plugins/clangrefactoring/clangrefactoringplugin.cpp +++ b/src/plugins/clangrefactoring/clangrefactoringplugin.cpp @@ -96,10 +96,6 @@ public: SymbolQuery<QuerySqliteReadStatementFactory> symbolQuery{statementFactory}; ClangBackEnd::ProjectPartsStorage<Sqlite::Database> projectPartsStorage{database}; RefactoringEngine engine{connectionClient.serverProxy(), refactoringClient, filePathCache, symbolQuery}; - QtCreatorSearch qtCreatorSearch; - QtCreatorClangQueryFindFilter qtCreatorfindFilter{connectionClient.serverProxy(), - qtCreatorSearch, - refactoringClient}; QtCreatorRefactoringProjectUpdater projectUpdate{connectionClient.serverProxy(), ClangPchManagerPlugin::pchManagerClient(), filePathCache, @@ -126,7 +122,6 @@ bool ClangRefactoringPlugin::initialize(const QStringList & /*arguments*/, QStri d->refactoringClient.setRefactoringEngine(&d->engine); d->refactoringClient.setRefactoringConnectionClient(&d->connectionClient); - ExtensionSystem::PluginManager::addObject(&d->qtCreatorfindFilter); connectBackend(); startBackend(); @@ -145,7 +140,6 @@ void ClangRefactoringPlugin::extensionsInitialized() ExtensionSystem::IPlugin::ShutdownFlag ClangRefactoringPlugin::aboutToShutdown() { - ExtensionSystem::PluginManager::removeObject(&d->qtCreatorfindFilter); CppTools::CppModelManager::removeRefactoringEngine( CppTools::RefactoringEngineType::ClangRefactoring); d->refactoringClient.setRefactoringConnectionClient(nullptr); diff --git a/src/plugins/clangrefactoring/refactoringclient.cpp b/src/plugins/clangrefactoring/refactoringclient.cpp index 3bdeb9dd53..e39e27a22a 100644 --- a/src/plugins/clangrefactoring/refactoringclient.cpp +++ b/src/plugins/clangrefactoring/refactoringclient.cpp @@ -40,16 +40,6 @@ void RefactoringClient::alive() m_connectionClient->resetProcessAliveTimer(); } -void RefactoringClient::sourceLocationsForRenamingMessage( - ClangBackEnd::SourceLocationsForRenamingMessage &&message) -{ - m_localRenamingCallback(message.symbolName.toQString(), - message.sourceLocations, - message.textDocumentRevision); - - m_refactoringEngine->setRefactoringEngineAvailable(true); -} - void RefactoringClient::sourceRangesAndDiagnosticsForQueryMessage( ClangBackEnd::SourceRangesAndDiagnosticsForQueryMessage &&message) { @@ -64,12 +54,6 @@ void RefactoringClient::sourceRangesForQueryMessage(ClangBackEnd::SourceRangesFo setResultCounterAndSendSearchIsFinishedIfFinished(); } -void RefactoringClient::setLocalRenamingCallback( - CppTools::RefactoringEngineInterface::RenameCallback &&localRenamingCallback) -{ - m_localRenamingCallback = std::move(localRenamingCallback); -} - void RefactoringClient::progress(ClangBackEnd::ProgressMessage &&message) { m_progressManager.setProgress(message.progress, message.total); @@ -100,11 +84,6 @@ void RefactoringClient::setClangQueryHighlighter(ClangQueryHighlighter *highligh m_clangQueryHighlighter = highlighter; } -bool RefactoringClient::hasValidLocalRenamingCallback() const -{ - return bool(m_localRenamingCallback); -} - void RefactoringClient::setExpectedResultCount(uint count) { m_expectedResultCount = count; diff --git a/src/plugins/clangrefactoring/refactoringclient.h b/src/plugins/clangrefactoring/refactoringclient.h index f3d9e218e5..a68fe39211 100644 --- a/src/plugins/clangrefactoring/refactoringclient.h +++ b/src/plugins/clangrefactoring/refactoringclient.h @@ -54,15 +54,11 @@ public: {} void alive() override; - void sourceLocationsForRenamingMessage( - ClangBackEnd::SourceLocationsForRenamingMessage &&message) override; void sourceRangesAndDiagnosticsForQueryMessage( ClangBackEnd::SourceRangesAndDiagnosticsForQueryMessage &&message) override; void sourceRangesForQueryMessage( ClangBackEnd::SourceRangesForQueryMessage &&message) override; - void setLocalRenamingCallback( - CppTools::RefactoringEngineInterface::RenameCallback &&localRenamingCallback) override; void progress(ClangBackEnd::ProgressMessage &&message) override; void setRefactoringEngine(ClangRefactoring::RefactoringEngine *refactoringEngine); @@ -71,8 +67,6 @@ public: void setClangQueryExampleHighlighter(ClangQueryExampleHighlighter *highlighter); void setClangQueryHighlighter(ClangQueryHighlighter *highlighter); - bool hasValidLocalRenamingCallback() const; - void setExpectedResultCount(uint count); uint expectedResultCount() const; uint resultCounter() const; @@ -90,7 +84,6 @@ private: void sendSearchIsFinished(); private: - CppTools::RefactoringEngineInterface::RenameCallback m_localRenamingCallback; ClangBackEnd::RefactoringConnectionClient *m_connectionClient = nullptr; SearchHandle *m_searchHandle = nullptr; RefactoringEngine *m_refactoringEngine = nullptr; diff --git a/src/plugins/clangrefactoring/refactoringengine.cpp b/src/plugins/clangrefactoring/refactoringengine.cpp index 38f857ef1c..cc9121331d 100644 --- a/src/plugins/clangrefactoring/refactoringengine.cpp +++ b/src/plugins/clangrefactoring/refactoringengine.cpp @@ -28,7 +28,6 @@ #include <filepath.h> #include <refactoringserverinterface.h> -#include <requestsourcelocationforrenamingmessage.h> #include <cpptools/compileroptionsbuilder.h> #include <cpptools/cpptoolsreuse.h> @@ -47,7 +46,6 @@ namespace ClangRefactoring { -using ClangBackEnd::RequestSourceLocationsForRenamingMessage; RefactoringEngine::RefactoringEngine(ClangBackEnd::RefactoringServerInterface &server, ClangBackEnd::RefactoringClientInterface &client, @@ -62,34 +60,10 @@ RefactoringEngine::RefactoringEngine(ClangBackEnd::RefactoringServerInterface &s RefactoringEngine::~RefactoringEngine() = default; -void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data, - CppTools::ProjectPart *projectPart, - RenameCallback &&renameSymbolsCallback) +void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &, + CppTools::ProjectPart *, + RenameCallback &&) { - using CppTools::CompilerOptionsBuilder; - - setRefactoringEngineAvailable(false); - - m_client.setLocalRenamingCallback(std::move(renameSymbolsCallback)); - - QString filePath = data.filePath().toString(); - QTextCursor textCursor = data.cursor(); - CompilerOptionsBuilder optionsBuilder{*projectPart, CppTools::UseSystemHeader::Yes}; - Utils::SmallStringVector commandLine{optionsBuilder.build( - fileKindInProjectPart(projectPart, filePath), - CppTools::getPchUsage())}; - - commandLine.push_back(filePath); - - RequestSourceLocationsForRenamingMessage message(ClangBackEnd::FilePath(filePath), - uint(textCursor.blockNumber() + 1), - uint(textCursor.positionInBlock() + 1), - textCursor.document()->toPlainText(), - std::move(commandLine), - textCursor.document()->revision()); - - - m_server.requestSourceLocationsForRenamingMessage(std::move(message)); } CppTools::Usages RefactoringEngine::locationsAt(const CppTools::CursorInEditor &data) const diff --git a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri index a3da84d83b..9c51093632 100644 --- a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri +++ b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri @@ -26,11 +26,8 @@ HEADERS += \ !isEmpty(LIBTOOLING_LIBS) { SOURCES += \ $$PWD/refactoringcompilationdatabase.cpp \ - $$PWD/symbolfinder.cpp \ - $$PWD/symbollocationfinderaction.cpp \ $$PWD/refactoringserver.cpp \ $$PWD/macropreprocessorcallbacks.cpp \ - $$PWD/findusrforcursoraction.cpp \ $$PWD/clangquery.cpp \ $$PWD/clangtool.cpp \ $$PWD/sourcerangeextractor.cpp \ @@ -44,14 +41,10 @@ SOURCES += \ HEADERS += \ $$PWD/refactoringcompilationdatabase.h \ - $$PWD/symbolfinder.h \ - $$PWD/symbollocationfinderaction.h \ $$PWD/refactoringserver.h \ $$PWD/macropreprocessorcallbacks.h \ $$PWD/sourcelocationsutils.h \ $$PWD/findcursorusr.h \ - $$PWD/findusrforcursoraction.h \ - $$PWD/findlocationsofusrs.h \ $$PWD/clangquery.h \ $$PWD/clangtool.h \ $$PWD/sourcerangeextractor.h \ diff --git a/src/tools/clangrefactoringbackend/source/findcursorusr.h b/src/tools/clangrefactoringbackend/source/findcursorusr.h deleted file mode 100644 index 06777d8611..0000000000 --- a/src/tools/clangrefactoringbackend/source/findcursorusr.h +++ /dev/null @@ -1,191 +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 "clangrefactoringbackend_global.h" - -#include <clang/AST/AST.h> -#include <clang/AST/ASTContext.h> -#include <clang/AST/RecursiveASTVisitor.h> -#include <clang/Index/USRGeneration.h> -#include <llvm/ADT/SmallVector.h> - -#include <vector> - -namespace ClangBackEnd { - -class FindNamedDeclarationASTVisitor : public clang::RecursiveASTVisitor<FindNamedDeclarationASTVisitor> -{ -public: - explicit FindNamedDeclarationASTVisitor(const clang::SourceManager &sourceManager, - const clang::SourceLocation cursorSourceLocation) - : m_sourceManager(sourceManager), - m_cursorSourceLocation(cursorSourceLocation) - { - } - - bool shouldVisitTemplateInstantiations() const - { - return true; - } - - bool VisitNamedDecl(const clang::NamedDecl *declaration) - { - auto name = declaration->getNameAsString(); - - setResultIfCursorIsInBetween(declaration, - declaration->getLocation(), - declaration->getNameAsString().length()); - - return true; - } - - bool VisitDeclRefExpr(const clang::DeclRefExpr *expression) - { - if (!iterateNestedNameSpecifierLocation(expression->getQualifierLoc())) - return false; - - const auto *declaration = expression->getFoundDecl(); - return setResultIfCursorIsInBetween(declaration, - expression->getLocation(), - declaration->getNameAsString().length()); - } - - bool VisitMemberExpr(const clang::MemberExpr *expression) - { - const auto *declaration = expression->getFoundDecl().getDecl(); - return setResultIfCursorIsInBetween(declaration, - expression->getMemberLoc(), - declaration->getNameAsString().length()); - } - - std::vector<const clang::NamedDecl*> takeNamedDecl() - { - return std::move(m_namedDeclarations); - } - -private: - bool canSetResult(const clang::NamedDecl *declaration, - clang::SourceLocation location) - { - return declaration - && !setResultIfCursorIsInBetween(declaration, - location, - declaration->getNameAsString().length()); - } - - bool iterateNestedNameSpecifierLocation(clang::NestedNameSpecifierLoc nameLocation) { - while (nameLocation) { - const auto *declaration = nameLocation.getNestedNameSpecifier()->getAsNamespace(); - if (canSetResult(declaration, nameLocation.getLocalBeginLoc())) - return false; - - nameLocation = nameLocation.getPrefix(); - } - - return true; - } - - bool isValidLocationWithCursorInside(clang::SourceLocation startLocation, - clang::SourceLocation endLocation) - { - return startLocation.isValid() - && startLocation.isFileID() - && endLocation.isValid() - && endLocation.isFileID() - && isCursorLocationBetween(startLocation, endLocation); - } - - bool setResultIfCursorIsInBetween(const clang::NamedDecl *declaration, - clang::SourceLocation startLocation, - clang::SourceLocation endLocation) - { - bool isValid = isValidLocationWithCursorInside(startLocation, endLocation); - - if (isValid) - m_namedDeclarations.push_back(declaration); - - return !isValid; - } - - bool setResultIfCursorIsInBetween(const clang::NamedDecl *declaration, - clang::SourceLocation location, - uint offset) { - return offset == 0 - || setResultIfCursorIsInBetween(declaration, location, location.getLocWithOffset(offset - 1)); - } - - bool isCursorLocationBetween(const clang::SourceLocation startLocation, - const clang::SourceLocation endLocation) - { - return m_cursorSourceLocation == startLocation - || m_cursorSourceLocation == endLocation - || (m_sourceManager.isBeforeInTranslationUnit(startLocation, m_cursorSourceLocation) - && m_sourceManager.isBeforeInTranslationUnit(m_cursorSourceLocation, endLocation)); - } - - std::vector<const clang::NamedDecl*> m_namedDeclarations; - const clang::SourceManager &m_sourceManager; - const clang::SourceLocation m_cursorSourceLocation; -}; - -inline -std::vector<const clang::NamedDecl *> namedDeclarationsAt(const clang::ASTContext &Context, - const clang::SourceLocation cursorSourceLocation) -{ - const auto &sourceManager = Context.getSourceManager(); - const auto currentFile = sourceManager.getFilename(cursorSourceLocation); - - FindNamedDeclarationASTVisitor visitor(sourceManager, cursorSourceLocation); - - auto declarations = Context.getTranslationUnitDecl()->decls(); - for (auto ¤tDeclation : declarations) { - const auto &fileLocation = currentDeclation->getBeginLoc(); - const auto &fileName = sourceManager.getFilename(fileLocation); - if (fileName == currentFile) { - visitor.TraverseDecl(currentDeclation); - const auto &namedDeclarations = visitor.takeNamedDecl(); - - if (!namedDeclarations.empty()) - return namedDeclarations; - } - } - - return std::vector<const clang::NamedDecl *>(); -} - -inline -USRName USROfDeclaration(const clang::Decl *declaration) -{ - USRName buffer; - - if (declaration == nullptr || clang::index::generateUSRForDecl(declaration, buffer)) - return buffer; - - return buffer; -} - -} // namespace ClangBackend diff --git a/src/tools/clangrefactoringbackend/source/findlocationsofusrs.h b/src/tools/clangrefactoringbackend/source/findlocationsofusrs.h deleted file mode 100644 index b6662205da..0000000000 --- a/src/tools/clangrefactoringbackend/source/findlocationsofusrs.h +++ /dev/null @@ -1,126 +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 "findcursorusr.h" - -#include <clang/AST/ASTContext.h> -#include <clang/AST/RecursiveASTVisitor.h> -#include <clang/Basic/SourceLocation.h> -#include <clang/Index/USRGeneration.h> -#include <llvm/ADT/SmallVector.h> - -#include <vector> - -namespace ClangBackEnd { - -class FindLocationsOfUSRsASTVisitor : public clang::RecursiveASTVisitor<FindLocationsOfUSRsASTVisitor> -{ -public: - explicit FindLocationsOfUSRsASTVisitor(const std::vector<USRName> &unifiedSymbolResolutions) - : unifiedSymbolResolutions(unifiedSymbolResolutions) - { - } - - bool VisitNamedDecl(const clang::NamedDecl *declaration) { - auto declarationUSR = USROfDeclaration(declaration); - - if (containsUSR(declarationUSR)) - foundLocations.push_back(declaration->getLocation()); - - return true; - } - - bool VisitDeclRefExpr(const clang::DeclRefExpr *expression) { - const auto *declaration = expression->getFoundDecl(); - - iterateNestedNameSpecifierLocation(expression->getQualifierLoc()); - auto declarationUSR = USROfDeclaration(declaration); - - if (containsUSR(declarationUSR)) - foundLocations.push_back(expression->getLocation()); - - return true; - } - - bool VisitMemberExpr(const clang::MemberExpr *expression) { - const auto *declaration = expression->getFoundDecl().getDecl(); - auto declarationUSR = USROfDeclaration(declaration); - - if (containsUSR(declarationUSR)) - foundLocations.push_back(expression->getMemberLoc()); - - return true; - } - - bool shouldVisitTemplateInstantiations() const - { - return true; - } - - std::vector<clang::SourceLocation> takeFoundLocations() const { - return std::move(foundLocations); - } - -private: - void iterateNestedNameSpecifierLocation(clang::NestedNameSpecifierLoc nameLocation) { - while (nameLocation) { - const auto *declaration = nameLocation.getNestedNameSpecifier()->getAsNamespace(); - if (declaration && containsUSR(USROfDeclaration(declaration))) - foundLocations.push_back(nameLocation.getLocalBeginLoc()); - - nameLocation = nameLocation.getPrefix(); - } - } - - bool containsUSR(const USRName &unifiedSymbolResolution) - { - auto found = std::find(unifiedSymbolResolutions.cbegin(), - unifiedSymbolResolutions.cend(), - unifiedSymbolResolution); - - return found != unifiedSymbolResolutions.cend(); - } - -private: - - // All the locations of the USR were found. - const std::vector<USRName> unifiedSymbolResolutions; - std::vector<clang::SourceLocation> foundLocations; -}; - -inline -std::vector<clang::SourceLocation> takeLocationsOfUSRs(std::vector<USRName> &unifiedSymbolResolutions, - clang::Decl *declartation) -{ - FindLocationsOfUSRsASTVisitor visitor(unifiedSymbolResolutions); - - visitor.TraverseDecl(declartation); - - return visitor.takeFoundLocations(); -} - -} // namespace ClangBackend diff --git a/src/tools/clangrefactoringbackend/source/findusrforcursoraction.cpp b/src/tools/clangrefactoringbackend/source/findusrforcursoraction.cpp deleted file mode 100644 index 6fa964f531..0000000000 --- a/src/tools/clangrefactoringbackend/source/findusrforcursoraction.cpp +++ /dev/null @@ -1,128 +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 "findusrforcursoraction.h" - -#include "findcursorusr.h" - -#include <clang/AST/AST.h> -#include <clang/AST/ASTConsumer.h> -#include <clang/AST/ASTContext.h> - -#include <algorithm> -#include <vector> - -namespace ClangBackEnd { - -namespace { - -std::vector<USRName> collectConstructorUnifiedSymbolResolutions(const clang::CXXRecordDecl *declarations) -{ - std::vector<USRName> unifiedSymbolResolutions; - - const auto constructorDeclarations = declarations->getDefinition()->ctors(); - - std::transform(constructorDeclarations.begin(), - constructorDeclarations.end(), - std::back_inserter(unifiedSymbolResolutions), - USROfDeclaration); - - return unifiedSymbolResolutions; -} - -void addUnifiedSymbolResolutionsForDeclaration(const std::vector<const clang::NamedDecl *> &declarations, - std::vector<USRName> &usrs) -{ - - std::transform(declarations.begin(), - declarations.end(), - std::back_inserter(usrs), - [&] (const clang::NamedDecl *declaration) { - return USROfDeclaration(declaration); - }); -} - -} - -class FindDeclarationsConsumer : public clang::ASTConsumer -{ -public: - FindDeclarationsConsumer(Utils::SmallString &symbolName, - std::vector<USRName> &unifiedSymbolResolutions, - uint line, - uint column) - : m_symbolName(symbolName), - m_unifiedSymbolResolutions(unifiedSymbolResolutions), - m_line(line), - m_column(column) - { - } - - void HandleTranslationUnit(clang::ASTContext &astContext) override { - const auto &sourceManager = astContext.getSourceManager(); - const auto cursorSourceLocation = sourceManager.translateLineCol(sourceManager.getMainFileID(), - m_line, - m_column); - - if (cursorSourceLocation.isValid()) - collectUnifiedSymbolResoltions(astContext, cursorSourceLocation); - } - - void collectUnifiedSymbolResoltions(clang::ASTContext &astContext, - const clang::SourceLocation &cursorSourceLocation) - { - const auto foundDeclarations = namedDeclarationsAt(astContext, cursorSourceLocation); - - if (!foundDeclarations.empty()) { - const auto firstFoundDeclaration = foundDeclarations.front(); - - if (const auto *constructorDecl = clang::dyn_cast<clang::CXXConstructorDecl>(firstFoundDeclaration)) { - const clang::CXXRecordDecl *foundDeclarationParent = constructorDecl->getParent(); - m_unifiedSymbolResolutions = collectConstructorUnifiedSymbolResolutions(foundDeclarationParent); - } else if (const auto *destructorDecl = clang::dyn_cast<clang::CXXDestructorDecl>(firstFoundDeclaration)) { - const clang::CXXRecordDecl *foundDeclarationParent = destructorDecl->getParent(); - m_unifiedSymbolResolutions = collectConstructorUnifiedSymbolResolutions(foundDeclarationParent); - } else if (const auto *recordDeclaration = clang::dyn_cast<clang::CXXRecordDecl>(firstFoundDeclaration)) { - m_unifiedSymbolResolutions = collectConstructorUnifiedSymbolResolutions(recordDeclaration); - } - - addUnifiedSymbolResolutionsForDeclaration(foundDeclarations, m_unifiedSymbolResolutions); - m_symbolName = firstFoundDeclaration->getNameAsString(); - } - } - -private: - Utils::SmallString &m_symbolName; - std::vector<USRName> &m_unifiedSymbolResolutions; - uint m_line; - uint m_column; -}; - -std::unique_ptr<clang::ASTConsumer> -USRFindingAction::newASTConsumer() { - return std::make_unique<FindDeclarationsConsumer>(m_symbolName, m_unifiedSymbolResolutions, m_line, m_column); -} - -} // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/findusrforcursoraction.h b/src/tools/clangrefactoringbackend/source/findusrforcursoraction.h deleted file mode 100644 index bfa4a373a4..0000000000 --- a/src/tools/clangrefactoringbackend/source/findusrforcursoraction.h +++ /dev/null @@ -1,70 +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 "clangrefactoringbackend_global.h" - -#include <utils/smallstring.h> - -#include <clang/Frontend/FrontendAction.h> - -namespace clang { -class ASTConsumer; -class CompilerInstance; -class NamedDecl; -} - -namespace ClangBackEnd { - -class USRFindingAction -{ -public: - USRFindingAction(uint line, uint column) - : m_line(line), - m_column(column) - { - } - - std::unique_ptr<clang::ASTConsumer> newASTConsumer(); - - std::string takeSymbolName() - { - return std::string(m_symbolName); - } - - std::vector<USRName> takeUnifiedSymbolResolutions() - { - return std::move(m_unifiedSymbolResolutions); - } - -private: - Utils::SmallString m_symbolName; - std::vector<USRName> m_unifiedSymbolResolutions; - uint m_line; - uint m_column; -}; - -} // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/refactoringserver.cpp b/src/tools/clangrefactoringbackend/source/refactoringserver.cpp index 83aa5a31fd..387f850c0f 100644 --- a/src/tools/clangrefactoringbackend/source/refactoringserver.cpp +++ b/src/tools/clangrefactoringbackend/source/refactoringserver.cpp @@ -25,7 +25,6 @@ #include "refactoringserver.h" -#include "symbolfinder.h" #include "clangquery.h" #include "symbolindexing.h" @@ -58,21 +57,6 @@ void RefactoringServer::end() QCoreApplication::exit(); } -void RefactoringServer::requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) -{ - SymbolFinder symbolFinder(message.line, message.column, m_filePathCache); - - symbolFinder.addFile(std::move(message.filePath), - std::move(message.unsavedContent), - std::move(message.commandLine)); - - symbolFinder.findSymbol(); - - client()->sourceLocationsForRenamingMessage({symbolFinder.takeSymbolName(), - symbolFinder.takeSourceLocations(), - message.textDocumentRevision}); -} - void RefactoringServer::requestSourceRangesAndDiagnosticsForQueryMessage( RequestSourceRangesAndDiagnosticsForQueryMessage &&message) { diff --git a/src/tools/clangrefactoringbackend/source/refactoringserver.h b/src/tools/clangrefactoringbackend/source/refactoringserver.h index 75b161f1ab..7934790518 100644 --- a/src/tools/clangrefactoringbackend/source/refactoringserver.h +++ b/src/tools/clangrefactoringbackend/source/refactoringserver.h @@ -60,7 +60,6 @@ public: GeneratedFiles &generatedFiles); void end() override; - void requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) override; void requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message) override; void requestSourceRangesForQueryMessage(RequestSourceRangesForQueryMessage &&message) override; void updateProjectParts(UpdateProjectPartsMessage &&message) override; diff --git a/src/tools/clangrefactoringbackend/source/symbolfinder.cpp b/src/tools/clangrefactoringbackend/source/symbolfinder.cpp deleted file mode 100644 index 8f002f10a1..0000000000 --- a/src/tools/clangrefactoringbackend/source/symbolfinder.cpp +++ /dev/null @@ -1,79 +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 "symbolfinder.h" - -#include "locationsourcefilecallbacks.h" -#include "symbollocationfinderaction.h" - -namespace ClangBackEnd { - -SymbolFinder::SymbolFinder(uint line, uint column, FilePathCachingInterface &filePathCache) - : m_usrFindingAction(line, column), - m_symbolLocationFinderAction(filePathCache), - m_sourceFileCallbacks(line, column, filePathCache) -{ -} - -void SymbolFinder::findSymbol() -{ - clang::tooling::ClangTool tool = createTool(); - - tool.run(clang::tooling::newFrontendActionFactory(&m_usrFindingAction, &m_sourceFileCallbacks).get()); - - if (m_sourceFileCallbacks.hasSourceLocations()) { - m_sourceLocations_ = m_sourceFileCallbacks.takeSourceLocations(); - m_symbolName = m_sourceFileCallbacks.takeSymbolName(); - } else { - m_symbolLocationFinderAction.setUnifiedSymbolResolutions(m_usrFindingAction.takeUnifiedSymbolResolutions()); - - tool.run(clang::tooling::newFrontendActionFactory(&m_symbolLocationFinderAction).get()); - - m_sourceLocations_ = m_symbolLocationFinderAction.takeSourceLocations(); - m_symbolName = m_usrFindingAction.takeSymbolName(); - } -} - -Utils::SmallString SymbolFinder::takeSymbolName() -{ - return std::move(m_symbolName); -} - -const std::vector<USRName> &SymbolFinder::unifiedSymbolResolutions() -{ - return m_symbolLocationFinderAction.unifiedSymbolResolutions(); -} - -const SourceLocationsContainer &SymbolFinder::sourceLocations() const -{ - return m_sourceLocations_; -} - -SourceLocationsContainer SymbolFinder::takeSourceLocations() -{ - return std::move(m_sourceLocations_); -} - -} // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/symbolfinder.h b/src/tools/clangrefactoringbackend/source/symbolfinder.h deleted file mode 100644 index a3c9659032..0000000000 --- a/src/tools/clangrefactoringbackend/source/symbolfinder.h +++ /dev/null @@ -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 "clangtool.h" -#include "findusrforcursoraction.h" -#include "symbollocationfinderaction.h" -#include "locationsourcefilecallbacks.h" - -#include <filepathcachingfwd.h> -#include <sourcelocationscontainer.h> - -namespace ClangBackEnd { - -class SymbolFinder : public ClangTool -{ -public: - SymbolFinder(uint line, uint column, FilePathCachingInterface &filePathCache); - - void findSymbol(); - - Utils::SmallString takeSymbolName(); - const std::vector<USRName> &unifiedSymbolResolutions(); - const SourceLocationsContainer &sourceLocations() const; - SourceLocationsContainer takeSourceLocations(); - -private: - Utils::SmallString m_symbolName; - USRFindingAction m_usrFindingAction; - SymbolLocationFinderAction m_symbolLocationFinderAction; - LocationSourceFileCallbacks m_sourceFileCallbacks; - ClangBackEnd::SourceLocationsContainer m_sourceLocations_; -}; - -} // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.cpp b/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.cpp deleted file mode 100644 index eddcf683c7..0000000000 --- a/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.cpp +++ /dev/null @@ -1,99 +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 "symbollocationfinderaction.h" - -#include "sourcelocationsutils.h" -#include "findlocationsofusrs.h" - -#include <filepathcachingfwd.h> - -#include <clang/AST/ASTConsumer.h> -#include <clang/AST/ASTContext.h> - -#include <memory> - -namespace ClangBackEnd { - -class FindingSymbolsASTConsumer : public clang::ASTConsumer -{ -public: - FindingSymbolsASTConsumer(std::vector<USRName> &unifiedSymbolResolutions, - FilePathCachingInterface &filePathCache) - : m_unifiedSymbolResolutions(unifiedSymbolResolutions), - m_filePathCache(filePathCache) - { - } - - void HandleTranslationUnit(clang::ASTContext &context) override - { - std::vector<clang::SourceLocation> sourceLocations; - - - auto &&sourceLocationsOfUsr = takeLocationsOfUSRs(m_unifiedSymbolResolutions, context.getTranslationUnitDecl()); - sourceLocations.insert(sourceLocations.end(), - sourceLocationsOfUsr.begin(), - sourceLocationsOfUsr.end()); - - - std::sort(sourceLocations.begin(), sourceLocations.end()); - auto newEnd = std::unique(sourceLocations.begin(), sourceLocations.end()); - sourceLocations.erase(newEnd, sourceLocations.end()); - - updateSourceLocations(sourceLocations, context.getSourceManager()); - - } - - void updateSourceLocations(const std::vector<clang::SourceLocation> &sourceLocations, - const clang::SourceManager &sourceManager) - { - appendSourceLocationsToSourceLocationsContainer(*m_sourceLocationsContainer, - sourceLocations, - sourceManager, - m_filePathCache); - } - - void setSourceLocations(ClangBackEnd::SourceLocationsContainer *sourceLocations) - { - m_sourceLocationsContainer = sourceLocations; - } - -private: - ClangBackEnd::SourceLocationsContainer *m_sourceLocationsContainer = nullptr; - std::vector<USRName> &m_unifiedSymbolResolutions; - FilePathCachingInterface &m_filePathCache; -}; - -std::unique_ptr<clang::ASTConsumer> SymbolLocationFinderAction::newASTConsumer() -{ - auto consumer = std::make_unique<FindingSymbolsASTConsumer>(m_unifiedSymbolResolutions_, - m_filePathCache); - - consumer->setSourceLocations(&m_sourceLocations); - - return consumer; -} - -} // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.h b/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.h deleted file mode 100644 index e3f4c4a2f3..0000000000 --- a/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.h +++ /dev/null @@ -1,71 +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 "clangrefactoringbackend_global.h" - -#include <filepathcachingfwd.h> -#include <sourcelocationscontainer.h> - -#include <clang/Tooling/Refactoring.h> - -namespace clang { -class ASTConsumer; -} - -namespace ClangBackEnd { - -class SymbolLocationFinderAction -{ -public: - SymbolLocationFinderAction(FilePathCachingInterface &filePathCache) - : m_filePathCache(filePathCache) - {} - - std::unique_ptr<clang::ASTConsumer> newASTConsumer(); - - SourceLocationsContainer takeSourceLocations() - { - return std::move(m_sourceLocations); - } - - void setUnifiedSymbolResolutions(std::vector<USRName> &&unifiedSymbolResolutions) - { - m_unifiedSymbolResolutions_ = std::move(unifiedSymbolResolutions); - } - - const std::vector<USRName> &unifiedSymbolResolutions() const - { - return m_unifiedSymbolResolutions_; - } - -private: - ClangBackEnd::SourceLocationsContainer m_sourceLocations; - std::vector<USRName> m_unifiedSymbolResolutions_; - FilePathCachingInterface &m_filePathCache; -}; - -} // namespace ClangBackEnd diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index e1f721440f..737120abb2 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -810,19 +810,6 @@ std::ostream &operator<<(std::ostream &out, const ToolTipInfo &info) return out; } -std::ostream &operator<<(std::ostream &os, const RequestSourceLocationsForRenamingMessage &message) -{ - os << "(" - << message.filePath << ", " - << message.line << ", " - << message.column << ", " - << message.unsavedContent << ", " - << message.commandLine - << ")"; - - return os; -} - std::ostream &operator<<(std::ostream &os, const RequestSourceRangesAndDiagnosticsForQueryMessage &message) { os << "(" @@ -853,17 +840,6 @@ std::ostream &operator<<(std::ostream &os, const SourceLocationContainer &contai return os; } -std::ostream &operator<<(std::ostream &os, const SourceLocationsForRenamingMessage &message) -{ - os << "(" - << message.symbolName << ", " - << message.textDocumentRevision << ", " - << message.sourceLocations - << ")"; - - return os; -} - std::ostream &operator<<(std::ostream &os, const SourceRangeContainer &container) { os << "(" diff --git a/tests/unit/unittest/gtest-creator-printing.h b/tests/unit/unittest/gtest-creator-printing.h index 057ebba139..b533186739 100644 --- a/tests/unit/unittest/gtest-creator-printing.h +++ b/tests/unit/unittest/gtest-creator-printing.h @@ -147,11 +147,9 @@ class RequestAnnotationsMessage; class RequestFollowSymbolMessage; class RequestReferencesMessage; class RequestToolTipMessage; -class RequestSourceLocationsForRenamingMessage; class RequestSourceRangesAndDiagnosticsForQueryMessage; class RequestSourceRangesForQueryMessage; class SourceLocationContainer; -class SourceLocationsForRenamingMessage; class SourceRangeContainer; class SourceRangesAndDiagnosticsForQueryMessage; class SourceRangesContainer; @@ -241,11 +239,10 @@ std::ostream &operator<<(std::ostream &out, const RequestFollowSymbolMessage &me std::ostream &operator<<(std::ostream &out, const RequestReferencesMessage &message); std::ostream &operator<<(std::ostream &out, const RequestToolTipMessage &message); std::ostream &operator<<(std::ostream &out, const ToolTipInfo &info); -std::ostream &operator<<(std::ostream &out, const RequestSourceLocationsForRenamingMessage &message); -std::ostream &operator<<(std::ostream &out, const RequestSourceRangesAndDiagnosticsForQueryMessage &message); +std::ostream &operator<<(std::ostream &out, + const RequestSourceRangesAndDiagnosticsForQueryMessage &message); std::ostream &operator<<(std::ostream &out, const RequestSourceRangesForQueryMessage &message); std::ostream &operator<<(std::ostream &out, const SourceLocationContainer &container); -std::ostream &operator<<(std::ostream &out, const SourceLocationsForRenamingMessage &message); std::ostream &operator<<(std::ostream &out, const SourceRangeContainer &container); std::ostream &operator<<(std::ostream &out, const SourceRangesAndDiagnosticsForQueryMessage &message); std::ostream &operator<<(std::ostream &out, const SourceRangesContainer &container); diff --git a/tests/unit/unittest/mockrefactoringclient.h b/tests/unit/unittest/mockrefactoringclient.h index 2542898f29..11721bb7af 100644 --- a/tests/unit/unittest/mockrefactoringclient.h +++ b/tests/unit/unittest/mockrefactoringclient.h @@ -34,8 +34,6 @@ class MockRefactoringClient : public ClangBackEnd::RefactoringClientInterface public: MOCK_METHOD0(alive, void()); - MOCK_METHOD1(sourceLocationsForRenamingMessage, - void (const ClangBackEnd::SourceLocationsForRenamingMessage&)); MOCK_METHOD1(sourceRangesAndDiagnosticsForQueryMessage, void (const ClangBackEnd::SourceRangesAndDiagnosticsForQueryMessage&)); MOCK_METHOD1(sourceRangesForQueryMessage, @@ -43,11 +41,6 @@ public: MOCK_METHOD1(progress, void (const ClangBackEnd::ProgressMessage&)); - void sourceLocationsForRenamingMessage(ClangBackEnd::SourceLocationsForRenamingMessage &&message) override - { - sourceLocationsForRenamingMessage(message); - } - void sourceRangesAndDiagnosticsForQueryMessage(ClangBackEnd::SourceRangesAndDiagnosticsForQueryMessage &&message) override { sourceRangesAndDiagnosticsForQueryMessage(message); @@ -58,10 +51,6 @@ public: sourceRangesForQueryMessage(message); } - void setLocalRenamingCallback(RenameCallback &&) override - { - } - void progress(ClangBackEnd::ProgressMessage &&message) override { progress(message); diff --git a/tests/unit/unittest/mockrefactoringserver.h b/tests/unit/unittest/mockrefactoringserver.h index 4bd6aac8fc..dd32a33103 100644 --- a/tests/unit/unittest/mockrefactoringserver.h +++ b/tests/unit/unittest/mockrefactoringserver.h @@ -35,9 +35,6 @@ public: MOCK_METHOD0(end, void()); - MOCK_METHOD1(requestSourceLocationsForRenamingMessage, - void (const ClangBackEnd::RequestSourceLocationsForRenamingMessage&)); - MOCK_METHOD1(requestSourceRangesAndDiagnosticsForQueryMessage, void (const ClangBackEnd::RequestSourceRangesAndDiagnosticsForQueryMessage&)); @@ -62,11 +59,6 @@ public: MOCK_METHOD2(setProgress, void(int, int)); - void requestSourceLocationsForRenamingMessage(ClangBackEnd::RequestSourceLocationsForRenamingMessage &&message) override - { - requestSourceLocationsForRenamingMessage(message); - } - void requestSourceRangesAndDiagnosticsForQueryMessage(ClangBackEnd::RequestSourceRangesAndDiagnosticsForQueryMessage &&message) override { requestSourceRangesAndDiagnosticsForQueryMessage(message); diff --git a/tests/unit/unittest/refactoringclient-test.cpp b/tests/unit/unittest/refactoringclient-test.cpp index 00a390dd14..81036feba0 100644 --- a/tests/unit/unittest/refactoringclient-test.cpp +++ b/tests/unit/unittest/refactoringclient-test.cpp @@ -107,46 +107,11 @@ protected: ProjectExplorer::Project project; CppTools::ProjectPart::Ptr projectPart; CppTools::ProjectFile projectFile{qStringFilePath, CppTools::ProjectFile::CXXSource}; - SourceLocationsForRenamingMessage renameMessage{"symbol", - {{{42, 1, 1, 0}, {42, 2, 5, 10}}}, - 1}; SourceRangesForQueryMessage queryResultMessage{{{{42, 1, 1, 0, 1, 5, 4, ""}, {42, 2, 1, 5, 2, 5, 10, ""}}}}; SourceRangesForQueryMessage emptyQueryResultMessage; }; -TEST_F(RefactoringClient, SourceLocationsForRenaming) -{ - client.setLocalRenamingCallback(mockLocalRenaming.AsStdFunction()); - - EXPECT_CALL(mockLocalRenaming, Call(renameMessage.symbolName.toQString(), - renameMessage.sourceLocations, - renameMessage.textDocumentRevision)); - - client.sourceLocationsForRenamingMessage(std::move(renameMessage)); -} - -TEST_F(RefactoringClient, AfterSourceLocationsForRenamingEngineIsUsableAgain) -{ - client.setLocalRenamingCallback(mockLocalRenaming.AsStdFunction()); - EXPECT_CALL(mockLocalRenaming, Call(_,_,_)); - - client.sourceLocationsForRenamingMessage(std::move(renameMessage)); - - ASSERT_TRUE(engine.isRefactoringEngineAvailable()); -} - -TEST_F(RefactoringClient, AfterStartLocalRenameHasValidCallback) -{ - engine.startLocalRenaming(CppTools::CursorInEditor{cursor, filePath}, - projectPart.data(), - [&] (const QString &, - const ClangBackEnd::SourceLocationsContainer &, - int) {}); - - ASSERT_TRUE(client.hasValidLocalRenamingCallback()); -} - TEST_F(RefactoringClient, CallAddResultsForEmptyQueryMessage) { EXPECT_CALL(mockSearchHandle, addResult(_ ,_ ,_)) diff --git a/tests/unit/unittest/refactoringclientserverinprocess-test.cpp b/tests/unit/unittest/refactoringclientserverinprocess-test.cpp index 113e21859e..8b6237bfad 100644 --- a/tests/unit/unittest/refactoringclientserverinprocess-test.cpp +++ b/tests/unit/unittest/refactoringclientserverinprocess-test.cpp @@ -90,28 +90,6 @@ TEST_F(RefactoringClientServerInProcess, SendAliveMessage) scheduleClientMessages(); } -TEST_F(RefactoringClientServerInProcess, SendSourceLocationsForRenamingMessage) -{ - ClangBackEnd::SourceLocationsContainer container; - ClangBackEnd::SourceLocationsForRenamingMessage message("symbolName", std::move(container), 1); - - EXPECT_CALL(mockRefactoringClient, sourceLocationsForRenamingMessage(message)); - - clientProxy.sourceLocationsForRenamingMessage(message.clone()); - scheduleClientMessages(); -} - -TEST_F(RefactoringClientServerInProcess, SendRequestSourceLocationsForRenamingMessage) -{ - RequestSourceLocationsForRenamingMessage message{ - {TESTDATA_DIR, "renamevariable.cpp"}, 1, 5, "int v;\n\nint x = v + 3;\n", {"cc"}, 1}; - - EXPECT_CALL(mockRefactoringServer, requestSourceLocationsForRenamingMessage(message)); - - serverProxy.requestSourceLocationsForRenamingMessage(message.clone()); - scheduleServerMessages(); -} - TEST_F(RefactoringClientServerInProcess, SourceRangesAndDiagnosticsForQueryMessage) { ClangBackEnd::SourceRangesContainer sourceRangesContainer; diff --git a/tests/unit/unittest/refactoringengine-test.cpp b/tests/unit/unittest/refactoringengine-test.cpp index 3cf5961dd1..280a240942 100644 --- a/tests/unit/unittest/refactoringengine-test.cpp +++ b/tests/unit/unittest/refactoringengine-test.cpp @@ -49,8 +49,6 @@ using testing::_; using CppTools::CompilerOptionsBuilder; -using ClangBackEnd::RequestSourceLocationsForRenamingMessage; - using Utils::SmallString; using Utils::SmallStringVector; @@ -90,33 +88,6 @@ protected: CppTools::ProjectFile projectFile{qStringFilePath, CppTools::ProjectFile::CXXSource}; }; -TEST_F(RefactoringEngine, SendRequestSourceLocationsForRenamingMessage) -{ - cursor.setPosition(11); - RequestSourceLocationsForRenamingMessage message(clangBackEndFilePath.clone(), - 2, - 5, - fileContent, - commandLine.clone(), - 1); - - EXPECT_CALL(mockRefactoringServer, requestSourceLocationsForRenamingMessage(message)) - .Times(1); - - engine.startLocalRenaming(CppTools::CursorInEditor{cursor, filePath}, - projectPart.data(), {}); -} - -TEST_F(RefactoringEngine, AfterSendRequestSourceLocationsForRenamingMessageIsUnusable) -{ - EXPECT_CALL(mockRefactoringServer, requestSourceLocationsForRenamingMessage(_)); - - engine.startLocalRenaming(CppTools::CursorInEditor{cursor, filePath}, - projectPart.data(), {}); - - ASSERT_FALSE(engine.isRefactoringEngineAvailable()); -} - TEST_F(RefactoringEngine, ExpectSourceUsagesAtInFindUsages) { cursor.setPosition(11); diff --git a/tests/unit/unittest/refactoringserver-test.cpp b/tests/unit/unittest/refactoringserver-test.cpp index 8a81e37258..74363de35f 100644 --- a/tests/unit/unittest/refactoringserver-test.cpp +++ b/tests/unit/unittest/refactoringserver-test.cpp @@ -56,11 +56,9 @@ using testing::_; using ClangBackEnd::FilePath; using ClangBackEnd::IncludeSearchPaths; using ClangBackEnd::IncludeSearchPathType; -using ClangBackEnd::RequestSourceLocationsForRenamingMessage; using ClangBackEnd::RequestSourceRangesAndDiagnosticsForQueryMessage; using ClangBackEnd::RequestSourceRangesForQueryMessage; using ClangBackEnd::SourceLocationsContainer; -using ClangBackEnd::SourceLocationsForRenamingMessage; using ClangBackEnd::SourceRangesAndDiagnosticsForQueryMessage; using ClangBackEnd::SourceRangesContainer; using ClangBackEnd::SourceRangesForQueryMessage; @@ -109,23 +107,6 @@ protected: using RefactoringServerSlowTest = RefactoringServer; using RefactoringServerVerySlowTest = RefactoringServer; -TEST_F(RefactoringServerSlowTest, RequestSourceLocationsForRenamingMessage) -{ - RequestSourceLocationsForRenamingMessage message{ - {TESTDATA_DIR, "renamevariable.cpp"}, 1, 5, "int v;\n\nint x = v + 3;\n", {"cc"}, 1}; - - EXPECT_CALL(mockRefactoringClient, - sourceLocationsForRenamingMessage( - AllOf(Field(&SourceLocationsForRenamingMessage::textDocumentRevision, 1), - Field(&SourceLocationsForRenamingMessage::symbolName, "v"), - Field(&SourceLocationsForRenamingMessage::sourceLocations, - Property(&SourceLocationsContainer::sourceLocationContainers, - AllOf(Contains(IsSourceLocation(1, 5)), - Contains(IsSourceLocation(3, 9)))))))); - - refactoringServer.requestSourceLocationsForRenamingMessage(std::move(message)); -} - TEST_F(RefactoringServerSlowTest, RequestSingleSourceRangesForQueryMessage) { RequestSourceRangesForQueryMessage message{"functionDecl()", diff --git a/tests/unit/unittest/symbolfinder-test.cpp b/tests/unit/unittest/symbolfinder-test.cpp deleted file mode 100644 index 8f29fe02da..0000000000 --- a/tests/unit/unittest/symbolfinder-test.cpp +++ /dev/null @@ -1,255 +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 "googletest.h" -#include "mockfilepathcaching.h" - -#include <clangrefactoringbackend_global.h> -#include <symbolfinder.h> - -#include "filesystem-utilities.h" - -using ClangBackEnd::FileContent; -using ClangBackEnd::FilePathView; -using ClangBackEnd::NativeFilePath; -using ClangBackEnd::NativeFilePathView; -using ClangBackEnd::SymbolFinder; -namespace { - -inline bool operator==(const ClangBackEnd::NativeFilePath &first, const std::string &second) -{ - return first.path() == second; -} -MATCHER_P2(IsSourceLocation, - line, - column, - std::string(negation ? "isn't" : "is") + "line " + PrintToString(line) + ", column " - + PrintToString(column)) -{ - return arg.line == uint(line) && arg.column == uint(column); -} - -MATCHER_P(StrEq, text, std::string(negation ? "isn't" : "is") + " text " + PrintToString(text)) -{ - return std::string(arg.data(), arg.size()) == std::string(text); -} -using Finder = SymbolFinder; - -class SymbolFinder : public testing::Test -{ -protected: - NiceMock<MockFilePathCaching> filePathCaching; -}; - -using SymbolFinderSlowTest = SymbolFinder; - -TEST_F(SymbolFinder, FileContentFilePath) -{ - FileContent fileContent(NativeFilePath{FilePathView{"/tmp/data.cpp"}}, "int variable;"); - - ASSERT_THAT(fileContent.filePath, toNativePath("/tmp/data.cpp")); -} - -TEST_F(SymbolFinderSlowTest, FindName) -{ - Finder finder(1, 5, filePathCaching); - finder.addFile({TESTDATA_DIR "/renamevariable.cpp"}, "int variable;", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.takeSymbolName(), "variable"); -} - -TEST_F(SymbolFinderSlowTest, FindNameInUnsavedFile) -{ - Finder finder(1, 5, filePathCaching); - finder.addFile({TESTDATA_DIR "/renamevariable.cpp"}, "int newVariable;", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.takeSymbolName(), "newVariable"); -} - -TEST_F(SymbolFinderSlowTest, FindUsrs) -{ - Finder finder(1, 5, filePathCaching); - finder.addFile({TESTDATA_DIR "/renamevariable.cpp"}, "int variable;", {"cc", "-std=c++14"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.unifiedSymbolResolutions().front(), StrEq("c:@variable")); -} - -TEST_F(SymbolFinderSlowTest, VariableDeclarationSourceLocations) -{ - Finder finder(1, 5, filePathCaching); - finder.addFile({TESTDATA_DIR "/renamevariable.cpp"}, "", {"cc", "-std=c++14"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - AllOf(Contains(IsSourceLocation(1, 5)), - Contains(IsSourceLocation(3, 9)))); -} - -TEST_F(SymbolFinderSlowTest, VariableUsageSourceLocations) -{ - Finder finder(3, 9, filePathCaching); - finder.addFile({TESTDATA_DIR "/renamevariable.cpp"}, "", {"cc", "-std=c++14"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - AllOf(Contains(IsSourceLocation(1, 5)), - Contains(IsSourceLocation(3, 9)))); -} - -TEST_F(SymbolFinderSlowTest, TemplateMemberVariableDeclarationSourceLocations) -{ - Finder finder(8, 18, filePathCaching); - finder.addFile({TESTDATA_DIR "/renamevariable.cpp"}, "", {"cc", "-std=c++14"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - AllOf(Contains(IsSourceLocation(8, 18)), - Contains(IsSourceLocation(15, 14)), - Contains(IsSourceLocation(18, 19)))); -} - -TEST_F(SymbolFinderSlowTest, TemplateMemberVariableUsageSourceLocations) -{ - Finder finder(15, 14, filePathCaching); - finder.addFile({TESTDATA_DIR "/renamevariable.cpp"}, "", {"cc", "-std=c++14"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - AllOf(Contains(IsSourceLocation(8, 18)), - Contains(IsSourceLocation(15, 14)), - Contains(IsSourceLocation(18, 19)))); -} - -TEST_F(SymbolFinderSlowTest, TemplateMemberVariableUsageInLambdaSourceLocations) -{ - Finder finder(18, 19, filePathCaching); - finder.addFile({TESTDATA_DIR "/renamevariable.cpp"}, "", {"cc", "-std=c++14"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - AllOf(Contains(IsSourceLocation(8, 18)), - Contains(IsSourceLocation(15, 14)), - Contains(IsSourceLocation(18, 19)))); -} - -TEST_F(SymbolFinderSlowTest, CursorOverMacroDefintionSymbolName) -{ - Finder finder(1, 9, filePathCaching); - finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"}, "", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.takeSymbolName(), "Macro"); -} - -TEST_F(SymbolFinderSlowTest, CursorOverMacroExpansionSymbolName) -{ - Finder finder(10, 10, filePathCaching); - finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"}, "", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.takeSymbolName(), "Macro"); -} - -TEST_F(SymbolFinderSlowTest, FindMacroDefinition) -{ - Finder finder(1, 9, filePathCaching); - finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"}, "", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - Contains(IsSourceLocation(1, 9))); -} - -TEST_F(SymbolFinderSlowTest, FindMacroExpansion) -{ - Finder finder(1, 9, filePathCaching); - finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"}, "", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - Contains(IsSourceLocation(5, 17))); -} - -TEST_F(SymbolFinderSlowTest, DoNotFindUndedefinedMacroExpansion) -{ - Finder finder(1, 9, filePathCaching); - finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"}, "", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - Not(Contains(IsSourceLocation(10, 10)))); -} - -TEST_F(SymbolFinderSlowTest, FindMacroDefinitionFromMacroExpansion) -{ - Finder finder(10, 10, filePathCaching); - finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"}, "", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - Contains(IsSourceLocation(8, 9))); -} - - -TEST_F(SymbolFinderSlowTest, FindMacroExpansionBeforeMacroExpansionWithCursor) -{ - Finder finder(12, 10, filePathCaching); - finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"}, "", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - Contains(IsSourceLocation(10, 10))); -} - -TEST_F(SymbolFinderSlowTest, FindMacroExpansionAfterMacroExpansionWithCursor) -{ - Finder finder(10, 10, filePathCaching); - finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"}, "", {"cc"}); - - finder.findSymbol(); - - ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), - Contains(IsSourceLocation(12, 10))); -} - -} // namespace diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index d9cef683e7..6565c47a09 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -194,7 +194,6 @@ SOURCES += \ sourcerangeextractor-test.cpp \ symbolindexing-test.cpp \ symbolscollector-test.cpp \ - symbolfinder-test.cpp \ testclangtool.cpp \ usedmacrocollector-test.cpp \ builddependencycollector-test.cpp |