2015-06-01 18:51:55 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:58:39 +01:00
|
|
|
** 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.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** 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.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-06-16 12:38:04 +02:00
|
|
|
#include "clangbackendipc_global.h"
|
2015-06-01 18:51:55 +02:00
|
|
|
#include "codecompletionchunk.h"
|
|
|
|
|
|
2015-06-16 12:38:04 +02:00
|
|
|
#include <utf8string.h>
|
|
|
|
|
|
2016-07-19 12:20:30 +02:00
|
|
|
#include <QDataStream>
|
2015-07-22 17:33:27 +02:00
|
|
|
#include <QVector>
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
namespace ClangBackEnd {
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-07-22 17:33:27 +02:00
|
|
|
class CodeCompletion;
|
|
|
|
|
using CodeCompletions = QVector<CodeCompletion>;
|
|
|
|
|
|
2016-07-19 12:20:30 +02:00
|
|
|
class CodeCompletion
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum Kind : quint32 {
|
|
|
|
|
Other = 0,
|
|
|
|
|
FunctionCompletionKind,
|
|
|
|
|
TemplateFunctionCompletionKind,
|
|
|
|
|
ConstructorCompletionKind,
|
|
|
|
|
DestructorCompletionKind,
|
|
|
|
|
VariableCompletionKind,
|
|
|
|
|
ClassCompletionKind,
|
2015-12-08 13:01:25 +01:00
|
|
|
TypeAliasCompletionKind,
|
2015-06-01 18:51:55 +02:00
|
|
|
TemplateClassCompletionKind,
|
|
|
|
|
EnumerationCompletionKind,
|
|
|
|
|
EnumeratorCompletionKind,
|
|
|
|
|
NamespaceCompletionKind,
|
|
|
|
|
PreProcessorCompletionKind,
|
|
|
|
|
SignalCompletionKind,
|
|
|
|
|
SlotCompletionKind,
|
|
|
|
|
ObjCMessageCompletionKind,
|
|
|
|
|
KeywordCompletionKind,
|
|
|
|
|
ClangSnippetKind
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum Availability : quint32 {
|
|
|
|
|
Available,
|
|
|
|
|
Deprecated,
|
|
|
|
|
NotAvailable,
|
|
|
|
|
NotAccessible
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CodeCompletion() = default;
|
|
|
|
|
CodeCompletion(const Utf8String &text,
|
|
|
|
|
quint32 priority = 0,
|
|
|
|
|
Kind completionKind = Other,
|
|
|
|
|
Availability availability = Available,
|
2016-07-19 12:20:30 +02:00
|
|
|
bool hasParameters = false)
|
|
|
|
|
: text_(text),
|
|
|
|
|
priority_(priority),
|
|
|
|
|
completionKind_(completionKind),
|
|
|
|
|
availability_(availability),
|
|
|
|
|
hasParameters_(hasParameters)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setText(const Utf8String &text)
|
|
|
|
|
{
|
|
|
|
|
text_ = text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Utf8String &text() const
|
|
|
|
|
{
|
|
|
|
|
return text_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setCompletionKind(Kind completionKind)
|
|
|
|
|
{
|
|
|
|
|
completionKind_ = completionKind;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Kind completionKind() const
|
|
|
|
|
{
|
|
|
|
|
return completionKind_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setChunks(const CodeCompletionChunks &chunks)
|
|
|
|
|
{
|
|
|
|
|
chunks_ = chunks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CodeCompletionChunks &chunks() const
|
|
|
|
|
{
|
|
|
|
|
return chunks_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setAvailability(Availability availability)
|
|
|
|
|
{
|
|
|
|
|
availability_ = availability;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Availability availability() const
|
|
|
|
|
{
|
|
|
|
|
return availability_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setHasParameters(bool hasParameters)
|
|
|
|
|
{
|
|
|
|
|
hasParameters_ = hasParameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool hasParameters() const
|
|
|
|
|
{
|
|
|
|
|
return hasParameters_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setPriority(quint32 priority)
|
|
|
|
|
{
|
|
|
|
|
priority_ = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quint32 priority() const
|
|
|
|
|
{
|
|
|
|
|
return priority_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setBriefComment(const Utf8String &briefComment)
|
|
|
|
|
{
|
|
|
|
|
briefComment_ = briefComment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Utf8String &briefComment() const
|
|
|
|
|
{
|
|
|
|
|
return briefComment_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend QDataStream &operator<<(QDataStream &out, const CodeCompletion &message)
|
|
|
|
|
{
|
|
|
|
|
out << message.text_;
|
|
|
|
|
out << message.briefComment_;
|
|
|
|
|
out << message.chunks_;
|
|
|
|
|
out << message.priority_;
|
|
|
|
|
out << static_cast<quint32>(message.completionKind_);
|
|
|
|
|
out << static_cast<quint32>(message.availability_);
|
|
|
|
|
out << message.hasParameters_;
|
|
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend QDataStream &operator>>(QDataStream &in, CodeCompletion &message)
|
|
|
|
|
{
|
|
|
|
|
quint32 completionKind;
|
|
|
|
|
quint32 availability;
|
|
|
|
|
|
|
|
|
|
in >> message.text_;
|
|
|
|
|
in >> message.briefComment_;
|
|
|
|
|
in >> message.chunks_;
|
|
|
|
|
in >> message.priority_;
|
|
|
|
|
in >> completionKind;
|
|
|
|
|
in >> availability;
|
|
|
|
|
in >> message.hasParameters_;
|
|
|
|
|
|
|
|
|
|
message.completionKind_ = static_cast<CodeCompletion::Kind>(completionKind);
|
|
|
|
|
message.availability_ = static_cast<CodeCompletion::Availability>(availability);
|
|
|
|
|
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend bool operator==(const CodeCompletion &first, const CodeCompletion &second)
|
|
|
|
|
{
|
|
|
|
|
return first.text_ == second.text_
|
|
|
|
|
&& first.completionKind_ == second.completionKind_;
|
|
|
|
|
}
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-07-19 12:20:30 +02:00
|
|
|
friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletion &message);
|
|
|
|
|
friend void PrintTo(const CodeCompletion &message, ::std::ostream* os);
|
2015-08-25 16:19:19 +02:00
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
private:
|
|
|
|
|
Utf8String text_;
|
2015-08-25 16:19:19 +02:00
|
|
|
Utf8String briefComment_;
|
2015-07-22 17:33:27 +02:00
|
|
|
CodeCompletionChunks chunks_;
|
2015-06-01 18:51:55 +02:00
|
|
|
quint32 priority_ = 0;
|
|
|
|
|
Kind completionKind_ = Other;
|
|
|
|
|
Availability availability_ = NotAvailable;
|
|
|
|
|
bool hasParameters_ = false;
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-10 13:52:45 +02:00
|
|
|
CMBIPC_EXPORT QDebug operator<<(QDebug debug, CodeCompletion::Kind kind);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
void PrintTo(CodeCompletion::Kind kind, ::std::ostream *os);
|
|
|
|
|
void PrintTo(CodeCompletion::Availability availability, ::std::ostream *os);
|
2015-06-16 11:56:00 +02:00
|
|
|
} // namespace ClangBackEnd
|