forked from qt-creator/qt-creator
Clang: Remove old code
We maybe bring back the clang query interface but the local rename is better served by other plugins. Change-Id: I97bedcb20870632b7dd50977794a65b2b09ededb Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -27,6 +27,5 @@
|
||||
|
||||
#include "alivemessage.h"
|
||||
#include "progressmessage.h"
|
||||
#include "sourcelocationsforrenamingmessage.h"
|
||||
#include "sourcerangesanddiagnosticsforquerymessage.h"
|
||||
#include "sourcerangesforquerymessage.h"
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
#include "cancelmessage.h"
|
||||
#include "endmessage.h"
|
||||
#include "requestsourcelocationforrenamingmessage.h"
|
||||
#include "requestsourcerangesanddiagnosticsforquerymessage.h"
|
||||
#include "requestsourcerangesforquerymessage.h"
|
||||
#include "removegeneratedfilesmessage.h"
|
||||
|
@@ -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 \
|
||||
|
@@ -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;
|
||||
|
@@ -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:
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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 \
|
||||
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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)
|
||||
{
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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 << "("
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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(_ ,_ ,_))
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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()",
|
||||
|
@@ -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
|
@@ -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
|
||||
|
Reference in New Issue
Block a user