Commit a31eae4d authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen

Clang: Add clang query pane

We now support highlighting for an example text and for the query.

Change-Id: I88c415ff871cf3e4c2d4fc83d60a8555bf0ce08a
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 8c4127eb
......@@ -79,7 +79,9 @@ SOURCES += $$PWD/clangcodemodelserverinterface.cpp \
$$PWD/pchmanagerclientproxy.cpp \
$$PWD/projectpartpch.cpp \
$$PWD/precompiledheadersupdatedmessage.cpp \
$$PWD/removepchprojectpartsmessage.cpp
$$PWD/removepchprojectpartsmessage.cpp \
$$PWD/sourcerangesforquerymessage.cpp \
$$PWD/requestsourcerangesforquerymessage.cpp
HEADERS += \
$$PWD/clangcodemodelserverinterface.h \
......@@ -159,5 +161,10 @@ HEADERS += \
$$PWD/removepchprojectpartsmessage.h \
$$PWD/clangcodemodelclientmessages.h \
$$PWD/clangcodemodelservermessages.h \
$$PWD/sourcerangesforquerymessage.h \
$$PWD/clangrefactoringmessages.h \
$$PWD/clangrefactoringclientmessages.h \
$$PWD/clangrefactoringservermessages.h \
$$PWD/requestsourcerangesforquerymessage.h
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
......@@ -128,7 +128,9 @@ enum class MessageType : quint8 {
RequestSourceLocationsForRenamingMessage,
RequestSourceRangesAndDiagnosticsForQueryMessage,
RequestSourceRangesForQueryMessage,
SourceRangesAndDiagnosticsForQueryMessage,
SourceRangesForQueryMessage,
CancelMessage,
UpdatePchProjectPartsMessage,
......
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "sourcelocationsforrenamingmessage.h"
#include "sourcerangesanddiagnosticsforquerymessage.h"
#include "sourcerangesforquerymessage.h"
#include "cmbalivemessage.h"
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "clangrefactoringclientmessages.h"
#include "clangrefactoringservermessages.h"
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "cancelmessage.h"
#include "cmbendmessage.h"
#include "requestsourcelocationforrenamingmessage.h"
#include "requestsourcerangesanddiagnosticsforquerymessage.h"
#include "requestsourcerangesforquerymessage.h"
......@@ -34,19 +34,19 @@ class DynamicASTMatcherDiagnosticContainer
{
public:
DynamicASTMatcherDiagnosticContainer() = default;
DynamicASTMatcherDiagnosticContainer(std::vector<DynamicASTMatcherDiagnosticMessageContainer> &&messages,
std::vector<DynamicASTMatcherDiagnosticContextContainer> &&contexts)
DynamicASTMatcherDiagnosticContainer(DynamicASTMatcherDiagnosticMessageContainers &&messages,
DynamicASTMatcherDiagnosticContextContainers &&contexts)
: m_messages(std::move(messages)),
m_contexts(std::move(contexts))
{
}
const std::vector<DynamicASTMatcherDiagnosticMessageContainer> &messages() const
const DynamicASTMatcherDiagnosticMessageContainers &messages() const
{
return m_messages;
}
const std::vector<DynamicASTMatcherDiagnosticContextContainer> &contexts() const
const DynamicASTMatcherDiagnosticContextContainers &contexts() const
{
return m_contexts;
}
......@@ -88,15 +88,16 @@ public:
DynamicASTMatcherDiagnosticContainer clone() const
{
return DynamicASTMatcherDiagnosticContainer(Utils::clone(m_messages),
Utils::clone(m_contexts));
return *this;
}
private:
std::vector<DynamicASTMatcherDiagnosticMessageContainer> m_messages;
std::vector<DynamicASTMatcherDiagnosticContextContainer> m_contexts;
DynamicASTMatcherDiagnosticMessageContainers m_messages;
DynamicASTMatcherDiagnosticContextContainers m_contexts;
};
using DynamicASTMatcherDiagnosticContainers = std::vector<DynamicASTMatcherDiagnosticContainer>;
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContainer &container);
std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticContainer &container);
......
......@@ -105,6 +105,8 @@ private:
Utils::SmallStringVector m_arguments;
};
using DynamicASTMatcherDiagnosticContextContainers = std::vector<DynamicASTMatcherDiagnosticContextContainer>;
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContextContainer &container);
std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticContextContainer &container);
......
......@@ -105,6 +105,8 @@ private:
Utils::SmallStringVector m_arguments;
};
using DynamicASTMatcherDiagnosticMessageContainers = std::vector<DynamicASTMatcherDiagnosticMessageContainer>;
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticMessageContainer &container);
std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticMessageContainer &container);
......
......@@ -86,13 +86,19 @@ public:
friend QDataStream &operator<<(QDataStream &out, const FilePath &filePath)
{
out << filePath.m_path;
out << uint(filePath.m_slashIndex);
return out;
}
friend QDataStream &operator>>(QDataStream &in, FilePath &filePath)
{
uint slashIndex;
in >> filePath.m_path;
in >> slashIndex;
filePath.m_slashIndex = slashIndex;
return in;
}
......@@ -116,7 +122,7 @@ public:
FilePath clone() const
{
return FilePath(m_path.clone(), m_slashIndex);
return *this;
}
private:
......
......@@ -26,8 +26,7 @@
#include "refactoringclientinterface.h"
#include "messageenvelop.h"
#include "sourcelocationsforrenamingmessage.h"
#include "sourcerangesanddiagnosticsforquerymessage.h"
#include "clangrefactoringclientmessages.h"
#include <QDebug>
......@@ -45,6 +44,9 @@ void RefactoringClientInterface::dispatch(const MessageEnvelop &messageEnvelop)
case MessageType::SourceRangesAndDiagnosticsForQueryMessage:
sourceRangesAndDiagnosticsForQueryMessage(messageEnvelop.message<SourceRangesAndDiagnosticsForQueryMessage>());
break;
case MessageType::SourceRangesForQueryMessage:
sourceRangesForQueryMessage(messageEnvelop.message<SourceRangesForQueryMessage>());
break;
default:
qWarning() << "Unknown IpcClientMessage";
}
......
......@@ -33,6 +33,7 @@ namespace ClangBackEnd {
class SourceLocationsForRenamingMessage;
class SourceRangesAndDiagnosticsForQueryMessage;
class SourceRangesForQueryMessage;
class SourceLocationsContainer;
class CMBIPC_EXPORT RefactoringClientInterface : public IpcClientInterface
......@@ -47,6 +48,7 @@ public:
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;
};
......
......@@ -28,8 +28,7 @@
#include "cmbalivemessage.h"
#include "messageenvelop.h"
#include "refactoringserverinterface.h"
#include "sourcelocationsforrenamingmessage.h"
#include "sourcerangesanddiagnosticsforquerymessage.h"
#include "clangrefactoringclientmessages.h"
#include <QDebug>
#include <QIODevice>
......@@ -85,4 +84,9 @@ void RefactoringClientProxy::sourceRangesAndDiagnosticsForQueryMessage(SourceRan
writeMessageBlock.write(message);
}
void RefactoringClientProxy::sourceRangesForQueryMessage(SourceRangesForQueryMessage &&message)
{
writeMessageBlock.write(message);
}
} // namespace ClangBackEnd
......@@ -51,6 +51,7 @@ public:
void alive() override;
void sourceLocationsForRenamingMessage(SourceLocationsForRenamingMessage &&message) override;
void sourceRangesAndDiagnosticsForQueryMessage(SourceRangesAndDiagnosticsForQueryMessage &&message) override;
void sourceRangesForQueryMessage(SourceRangesForQueryMessage &&message) override;
void setLocalRenamingCallback(RenameCallback &&) final {}
......
......@@ -26,9 +26,7 @@
#include "refactoringserverinterface.h"
#include "messageenvelop.h"
#include "requestsourcelocationforrenamingmessage.h"
#include "requestsourcerangesanddiagnosticsforquerymessage.h"
#include "cancelmessage.h"
#include "clangrefactoringservermessages.h"
#include <QDebug>
......@@ -46,6 +44,9 @@ void RefactoringServerInterface::dispatch(const MessageEnvelop &messageEnvelop)
case MessageType::RequestSourceRangesAndDiagnosticsForQueryMessage:
requestSourceRangesAndDiagnosticsForQueryMessage(messageEnvelop.message<RequestSourceRangesAndDiagnosticsForQueryMessage>());
break;
case MessageType::RequestSourceRangesForQueryMessage:
requestSourceRangesForQueryMessage(messageEnvelop.message<RequestSourceRangesForQueryMessage>());
break;
case MessageType::CancelMessage:
cancel();
break;
......
......@@ -34,6 +34,7 @@ namespace ClangBackEnd {
class RefactoringClientInterface;
class RequestSourceLocationsForRenamingMessage;
class RequestSourceRangesAndDiagnosticsForQueryMessage;
class RequestSourceRangesForQueryMessage;
class CancelMessage;
class CMBIPC_EXPORT RefactoringServerInterface : public IpcServerInterface<RefactoringClientInterface>
......@@ -44,6 +45,7 @@ public:
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;
bool isUsable() const
......
......@@ -25,12 +25,9 @@
#include "refactoringserverproxy.h"
#include "cancelmessage.h"
#include "cmbendmessage.h"
#include "messageenvelop.h"
#include "refactoringclientinterface.h"
#include "requestsourcelocationforrenamingmessage.h"
#include "requestsourcerangesanddiagnosticsforquerymessage.h"
#include "clangrefactoringservermessages.h"
#include <QIODevice>
#include <QVector>
......@@ -60,6 +57,11 @@ void RefactoringServerProxy::requestSourceRangesAndDiagnosticsForQueryMessage(Re
writeMessageBlock.write(message);
}
void RefactoringServerProxy::requestSourceRangesForQueryMessage(RequestSourceRangesForQueryMessage &&message)
{
writeMessageBlock.write(message);
}
void RefactoringServerProxy::cancel()
{
writeMessageBlock.write(CancelMessage());
......
......@@ -52,6 +52,7 @@ public:
void end() override;
void requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) override;
void requestSourceRangesAndDiagnosticsForQueryMessage(RequestSourceRangesAndDiagnosticsForQueryMessage &&message) override;
void requestSourceRangesForQueryMessage(RequestSourceRangesForQueryMessage &&message) override;
void cancel() override;
void readMessages();
......
......@@ -31,7 +31,7 @@ QDebug operator<<(QDebug debug, const RequestSourceRangesAndDiagnosticsForQueryM
{
debug.nospace() << "RequestSourceRangesAndDiagnosticsForQuery("
<< message.query() << ", "
<< message.sources() << ")";
<< message.source() << ")";
return debug;
}
......@@ -40,7 +40,7 @@ std::ostream &operator<<(std::ostream &os, const RequestSourceRangesAndDiagnosti
{
os << "("
<< message.query() << ", "
<< message.sources()
<< message.source()
<< ")";
return os;
......
......@@ -34,32 +34,20 @@ class RequestSourceRangesAndDiagnosticsForQueryMessage
public:
RequestSourceRangesAndDiagnosticsForQueryMessage() = default;
RequestSourceRangesAndDiagnosticsForQueryMessage(Utils::SmallString &&query,
std::vector<V2::FileContainer> &&sources,
std::vector<V2::FileContainer> &&unsavedContent)
V2::FileContainer &&source)
: m_query(std::move(query)),
m_sources(std::move(sources)),
m_unsavedContent(std::move(unsavedContent))
m_source(std::move(source))
{}
const std::vector<V2::FileContainer> &sources() const
const V2::FileContainer &source() const
{
return m_sources;
return m_source;
}
std::vector<V2::FileContainer> takeSources()
V2::FileContainer takeSource()
{
return std::move(m_sources);
}
const std::vector<V2::FileContainer> &unsavedContent() const
{
return m_unsavedContent;
}
std::vector<V2::FileContainer> takeUnsavedContent()
{
return std::move(m_unsavedContent);
return std::move(m_source);
}
const Utils::SmallString &query() const
......@@ -75,8 +63,7 @@ public:
friend QDataStream &operator<<(QDataStream &out, const RequestSourceRangesAndDiagnosticsForQueryMessage &message)
{
out << message.m_query;
out << message.m_sources;
out << message.m_unsavedContent;
out << message.m_source;
return out;
}
......@@ -84,8 +71,7 @@ public:
friend QDataStream &operator>>(QDataStream &in, RequestSourceRangesAndDiagnosticsForQueryMessage &message)
{
in >> message.m_query;
in >> message.m_sources;
in >> message.m_unsavedContent;
in >> message.m_source;
return in;
}
......@@ -94,26 +80,21 @@ public:
const RequestSourceRangesAndDiagnosticsForQueryMessage &second)
{
return first.m_query == second.m_query
&& first.m_sources == second.m_sources
&& first.m_unsavedContent == second.m_unsavedContent;
&& first.m_source == second.m_source;
}
RequestSourceRangesAndDiagnosticsForQueryMessage clone() const
{
return RequestSourceRangesAndDiagnosticsForQueryMessage(m_query.clone(),
Utils::clone(m_sources),
Utils::clone(m_unsavedContent));
return *this;
}
private:
Utils::SmallString m_query;
std::vector<V2::FileContainer> m_sources;
std::vector<V2::FileContainer> m_unsavedContent;
V2::FileContainer m_source;
};
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RequestSourceRangesAndDiagnosticsForQueryMessage &message);
std::ostream &operator<<(std::ostream &os, const RequestSourceRangesAndDiagnosticsForQueryMessage &message);
DECLARE_MESSAGE(RequestSourceRangesAndDiagnosticsForQueryMessage)
} // namespace ClangBackEnd
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "requestsourcerangesforquerymessage.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const RequestSourceRangesForQueryMessage &message)
{
debug.nospace() << "RequestSourceRangesForQueryMessage("
<< message.query() << ")";
return debug;
}
std::ostream &operator<<(std::ostream &os, const RequestSourceRangesForQueryMessage &message)
{
os << "("
<< message.query()
<< ")";
return os;
}
} // namespace ClangBackEnd
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "filecontainerv2.h"
namespace ClangBackEnd {
class RequestSourceRangesForQueryMessage
{
public:
RequestSourceRangesForQueryMessage() = default;
RequestSourceRangesForQueryMessage(Utils::SmallString &&query,
std::vector<V2::FileContainer> &&sources,
std::vector<V2::FileContainer> &&unsavedContent)
: m_query(std::move(query)),
m_sources(std::move(sources)),
m_unsavedContent(std::move(unsavedContent))
{}
const std::vector<V2::FileContainer> &sources() const
{
return m_sources;
}
std::vector<V2::FileContainer> takeSources()
{
return std::move(m_sources);
}
const std::vector<V2::FileContainer> &unsavedContent() const
{
return m_unsavedContent;
}
std::vector<V2::FileContainer> takeUnsavedContent()
{
return std::move(m_unsavedContent);
}
const Utils::SmallString &query() const
{
return m_query;
}
Utils::SmallString takeQuery()
{
return std::move(m_query);
}
friend QDataStream &operator<<(QDataStream &out, const RequestSourceRangesForQueryMessage &message)
{
out << message.m_query;
out << message.m_sources;
out << message.m_unsavedContent;
return out;
}
friend QDataStream &operator>>(QDataStream &in, RequestSourceRangesForQueryMessage &message)
{
in >> message.m_query;
in >> message.m_sources;
in >> message.m_unsavedContent;
return in;
}
friend bool operator==(const RequestSourceRangesForQueryMessage &first,
const RequestSourceRangesForQueryMessage &second)
{
return first.m_query == second.m_query
&& first.m_sources == second.m_sources
&& first.m_unsavedContent == second.m_unsavedContent;
}
RequestSourceRangesForQueryMessage clone() const
{
return *this;
}
private:
Utils::SmallString m_query;
std::vector<V2::FileContainer> m_sources;
std::vector<V2::FileContainer> m_unsavedContent;
};
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RequestSourceRangesForQueryMessage &message);
std::ostream &operator<<(std::ostream &os, const RequestSourceRangesForQueryMessage &message);
DECLARE_MESSAGE(RequestSourceRangesForQueryMessage)
} // namespace ClangBackEnd