forked from qt-creator/qt-creator
Clang: Extend clang query
It's a first step to introduce clang query. Change-Id: I4d001a8883f56066765ce6bc561fa3f49611c0a4 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
44
src/libs/clangbackendipc/cancelmessage.cpp
Normal file
44
src/libs/clangbackendipc/cancelmessage.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "cancelmessage.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
QDebug operator<<(QDebug debug, const CancelMessage &)
|
||||
{
|
||||
debug.nospace() << "CancelMessage()";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const CancelMessage &, ::std::ostream* os)
|
||||
{
|
||||
*os << "CancelMessage()";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
55
src/libs/clangbackendipc/cancelmessage.h
Normal file
55
src/libs/clangbackendipc/cancelmessage.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "clangbackendipc_global.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CancelMessage
|
||||
{
|
||||
public:
|
||||
friend QDataStream &operator<<(QDataStream &out, const CancelMessage &/*message*/)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, CancelMessage &/*message*/)
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
friend bool operator==(const CancelMessage &/*first*/, const CancelMessage &/*second*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CancelMessage &message);
|
||||
void PrintTo(const CancelMessage &message, ::std::ostream* os);
|
||||
|
||||
DECLARE_MESSAGE(CancelMessage)
|
||||
} // namespace ClangBackEnd
|
||||
@@ -59,6 +59,7 @@ SOURCES += $$PWD/clangcodemodelserverinterface.cpp \
|
||||
$$PWD/requestsourcelocationforrenamingmessage.cpp \
|
||||
$$PWD/filepath.cpp \
|
||||
$$PWD/sourcerangescontainer.cpp \
|
||||
$$PWD/sourcefilepathcontainerbase.cpp \
|
||||
$$PWD/sourcerangecontainerv2.cpp \
|
||||
$$PWD/dynamicastmatcherdiagnosticcontainer.cpp \
|
||||
$$PWD/dynamicastmatcherdiagnosticcontextcontainer.cpp \
|
||||
@@ -66,7 +67,8 @@ SOURCES += $$PWD/clangcodemodelserverinterface.cpp \
|
||||
$$PWD/requestsourcerangesanddiagnosticsforquerymessage.cpp \
|
||||
$$PWD/sourcerangesanddiagnosticsforquerymessage.cpp \
|
||||
$$PWD/sourcerangewithtextcontainer.cpp \
|
||||
$$PWD/filecontainerv2.cpp
|
||||
$$PWD/filecontainerv2.cpp \
|
||||
$$PWD/cancelmessage.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/clangcodemodelserverinterface.h \
|
||||
@@ -130,6 +132,7 @@ HEADERS += \
|
||||
$$PWD/requestsourcerangesanddiagnosticsforquerymessage.h \
|
||||
$$PWD/sourcerangesanddiagnosticsforquerymessage.h \
|
||||
$$PWD/sourcerangewithtextcontainer.h \
|
||||
$$PWD/filecontainerv2.h
|
||||
$$PWD/filecontainerv2.h \
|
||||
$$PWD/cancelmessage.h
|
||||
|
||||
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#endif
|
||||
|
||||
namespace Utils {
|
||||
template<uint Size>
|
||||
template <uint Size>
|
||||
class BasicSmallString;
|
||||
using SmallString = BasicSmallString<31>;
|
||||
}
|
||||
@@ -122,7 +122,9 @@ enum class MessageType : quint8 {
|
||||
RequestSourceLocationsForRenamingMessage,
|
||||
|
||||
RequestSourceRangesAndDiagnosticsForQueryMessage,
|
||||
SourceRangesAndDiagnosticsForQueryMessage
|
||||
SourceRangesAndDiagnosticsForQueryMessage,
|
||||
|
||||
CancelMessage
|
||||
};
|
||||
|
||||
template<MessageType messageEnumeration>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "messageenvelop.h"
|
||||
#include "requestsourcelocationforrenamingmessage.h"
|
||||
#include "requestsourcerangesanddiagnosticsforquerymessage.h"
|
||||
#include "cancelmessage.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@@ -45,6 +46,9 @@ void RefactoringServerInterface::dispatch(const MessageEnvelop &messageEnvelop)
|
||||
case MessageType::RequestSourceRangesAndDiagnosticsForQueryMessage:
|
||||
requestSourceRangesAndDiagnosticsForQueryMessage(messageEnvelop.message<RequestSourceRangesAndDiagnosticsForQueryMessage>());
|
||||
break;
|
||||
case MessageType::CancelMessage:
|
||||
cancel();
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Unknown IpcClientMessage";
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace ClangBackEnd {
|
||||
class RefactoringClientInterface;
|
||||
class RequestSourceLocationsForRenamingMessage;
|
||||
class RequestSourceRangesAndDiagnosticsForQueryMessage;
|
||||
class CancelMessage;
|
||||
|
||||
class CMBIPC_EXPORT RefactoringServerInterface : public IpcServerInterface<RefactoringClientInterface>
|
||||
{
|
||||
@@ -43,6 +44,7 @@ public:
|
||||
virtual void end() = 0;
|
||||
virtual void requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) = 0;
|
||||
virtual void requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message) = 0;
|
||||
virtual void cancel() = 0;
|
||||
|
||||
bool isUsable() const
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "refactoringserverproxy.h"
|
||||
|
||||
#include "cancelmessage.h"
|
||||
#include "cmbendmessage.h"
|
||||
#include "messageenvelop.h"
|
||||
#include "refactoringclientinterface.h"
|
||||
@@ -59,6 +60,11 @@ void RefactoringServerProxy::requestSourceRangesAndDiagnosticsForQueryMessage(Re
|
||||
writeMessageBlock.write(message);
|
||||
}
|
||||
|
||||
void RefactoringServerProxy::cancel()
|
||||
{
|
||||
writeMessageBlock.write(CancelMessage());
|
||||
}
|
||||
|
||||
void RefactoringServerProxy::readMessages()
|
||||
{
|
||||
for (const auto &message : readMessageBlock.readAll())
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace ClangBackEnd {
|
||||
|
||||
class RefactoringClientInterface;
|
||||
|
||||
class CMBIPC_EXPORT RefactoringServerProxy : public RefactoringServerInterface
|
||||
class CMBIPC_EXPORT RefactoringServerProxy final : public RefactoringServerInterface
|
||||
{
|
||||
public:
|
||||
explicit RefactoringServerProxy(RefactoringClientInterface *client, QIODevice *ioDevice);
|
||||
@@ -50,8 +50,9 @@ public:
|
||||
const RefactoringServerProxy &operator=(const RefactoringServerProxy&) = delete;
|
||||
|
||||
void end() override;
|
||||
void requestSourceLocationsForRenamingMessage(ClangBackEnd::RequestSourceLocationsForRenamingMessage &&message) override;
|
||||
void requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message);
|
||||
void requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) override;
|
||||
void requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message) override;
|
||||
void cancel() override;
|
||||
|
||||
void readMessages();
|
||||
|
||||
|
||||
@@ -25,13 +25,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "clangbackendipc_global.h"
|
||||
|
||||
#include "filecontainerv2.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT RequestSourceRangesAndDiagnosticsForQueryMessage
|
||||
class RequestSourceRangesAndDiagnosticsForQueryMessage
|
||||
{
|
||||
public:
|
||||
RequestSourceRangesAndDiagnosticsForQueryMessage() = default;
|
||||
|
||||
32
src/libs/clangbackendipc/sourcefilepathcontainerbase.cpp
Normal file
32
src/libs/clangbackendipc/sourcefilepathcontainerbase.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "sourcefilepathcontainerbase.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -44,9 +44,11 @@ public:
|
||||
|
||||
void insertFilePath(uint fileId, Utils::SmallString &&fileDirectory, Utils::SmallString &&fileName)
|
||||
{
|
||||
filePathHash.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(fileId),
|
||||
std::forward_as_tuple(std::move(fileDirectory), std::move(fileName)));
|
||||
if (filePathHash.find(fileId) == filePathHash.end()) {
|
||||
filePathHash.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(fileId),
|
||||
std::forward_as_tuple(std::move(fileDirectory), std::move(fileName)));
|
||||
}
|
||||
}
|
||||
|
||||
void reserve(std::size_t size)
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
|
||||
#include "sourcerangewithtextcontainer.h"
|
||||
|
||||
#ifdef UNIT_TESTS
|
||||
#include <gtest/gtest.h>
|
||||
#endif
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
QDebug operator<<(QDebug debug, const SourceRangeWithTextContainer &container)
|
||||
@@ -40,12 +44,18 @@ QDebug operator<<(QDebug debug, const SourceRangeWithTextContainer &container)
|
||||
|
||||
void PrintTo(const SourceRangeWithTextContainer &container, ::std::ostream* os)
|
||||
{
|
||||
Q_UNUSED(container)
|
||||
Q_UNUSED(os)
|
||||
#ifdef UNIT_TESTS
|
||||
*os << "(("
|
||||
<< container.start().line() << ", "
|
||||
<< container.start().column() << "), ("
|
||||
<< container.start().column() << ", "
|
||||
<< container.start().offset() << "), ("
|
||||
<< container.end().line() << ", "
|
||||
<< container.end().column() << ", "
|
||||
<< "\"" << container.text() << "\""
|
||||
<< "))";
|
||||
<< container.end().offset() << "), "
|
||||
<< testing::PrintToString(container.text())
|
||||
<< ")";
|
||||
#endif
|
||||
}
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Reference in New Issue
Block a user