2015-11-18 17:07:44 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-11-18 17:07:44 +01: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-11-18 17:07:44 +01: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-11-18 17:07:44 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-02-29 13:09:39 +01:00
|
|
|
#pragma once
|
2015-11-18 17:07:44 +01:00
|
|
|
|
2017-08-24 12:28:01 +02:00
|
|
|
#include "clangsupport_global.h"
|
2016-07-19 13:46:42 +02:00
|
|
|
|
2018-02-07 13:59:06 +01:00
|
|
|
#include "sourcerangecontainer.h"
|
|
|
|
|
|
2017-11-28 14:12:56 +01:00
|
|
|
#include <sqlite/utf8string.h>
|
|
|
|
|
|
2016-07-19 13:46:42 +02:00
|
|
|
#include <QDataStream>
|
|
|
|
|
|
2017-11-28 14:12:56 +01:00
|
|
|
#include <bitset>
|
2018-01-19 09:18:57 +01:00
|
|
|
|
2015-11-18 17:07:44 +01:00
|
|
|
namespace ClangBackEnd {
|
|
|
|
|
|
2016-07-19 13:46:42 +02:00
|
|
|
inline QDataStream &operator<<(QDataStream &out, HighlightingType highlightingType);
|
|
|
|
|
inline QDataStream &operator<<(QDataStream &out, HighlightingTypes highlightingTypes);
|
|
|
|
|
inline QDataStream &operator>>(QDataStream &in, HighlightingType &highlightingType);
|
|
|
|
|
inline QDataStream &operator>>(QDataStream &in, HighlightingTypes &highlightingTypes);
|
|
|
|
|
inline bool operator==(const MixinHighlightingTypes &first, const MixinHighlightingTypes &second);
|
|
|
|
|
inline bool operator==(const HighlightingTypes &first, const HighlightingTypes &second);
|
|
|
|
|
|
2017-11-28 14:12:56 +01:00
|
|
|
using ByteSizeBitset = std::bitset<8>;
|
|
|
|
|
|
|
|
|
|
inline QDataStream &operator<<(QDataStream &out, ByteSizeBitset bits);
|
|
|
|
|
inline QDataStream &operator>>(QDataStream &in, ByteSizeBitset &bits);
|
|
|
|
|
|
2018-01-19 09:18:57 +01:00
|
|
|
struct ExtraInfo
|
2015-11-18 17:07:44 +01:00
|
|
|
{
|
2018-01-19 09:18:57 +01:00
|
|
|
ExtraInfo()
|
|
|
|
|
: identifier(false)
|
|
|
|
|
, includeDirectivePath(false)
|
|
|
|
|
, declaration(false)
|
|
|
|
|
, definition(false)
|
|
|
|
|
, signal(false)
|
|
|
|
|
, slot(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
ExtraInfo(Utf8String token, Utf8String typeSpelling, Utf8String resultTypeSpelling,
|
2018-02-07 13:59:06 +01:00
|
|
|
Utf8String semanticParentTypeSpelling, SourceRangeContainer cursorRange,
|
|
|
|
|
AccessSpecifier accessSpecifier, StorageClass storageClass,
|
|
|
|
|
bool isIdentifier, bool isInclusion, bool isDeclaration, bool isDefinition,
|
|
|
|
|
bool isSignal, bool isSlot)
|
2018-01-19 09:18:57 +01:00
|
|
|
: token(token)
|
|
|
|
|
, typeSpelling(typeSpelling)
|
|
|
|
|
, resultTypeSpelling(resultTypeSpelling)
|
|
|
|
|
, semanticParentTypeSpelling(semanticParentTypeSpelling)
|
2018-02-07 13:59:06 +01:00
|
|
|
, cursorRange(cursorRange)
|
2018-01-19 09:18:57 +01:00
|
|
|
, accessSpecifier(accessSpecifier)
|
|
|
|
|
, storageClass(storageClass)
|
|
|
|
|
, identifier(isIdentifier)
|
|
|
|
|
, includeDirectivePath(isInclusion)
|
|
|
|
|
, declaration(isDeclaration)
|
|
|
|
|
, definition(isDefinition)
|
|
|
|
|
, signal(isSignal)
|
|
|
|
|
, slot(isSlot)
|
2017-11-28 14:12:56 +01:00
|
|
|
{
|
2018-01-19 09:18:57 +01:00
|
|
|
}
|
|
|
|
|
Utf8String token;
|
|
|
|
|
Utf8String typeSpelling;
|
|
|
|
|
Utf8String resultTypeSpelling;
|
|
|
|
|
Utf8String semanticParentTypeSpelling;
|
2018-02-07 13:59:06 +01:00
|
|
|
SourceRangeContainer cursorRange;
|
2018-01-19 09:18:57 +01:00
|
|
|
AccessSpecifier accessSpecifier = AccessSpecifier::Invalid;
|
|
|
|
|
StorageClass storageClass = StorageClass::Invalid;
|
|
|
|
|
bool identifier : 1;
|
|
|
|
|
bool includeDirectivePath : 1;
|
|
|
|
|
bool declaration : 1;
|
|
|
|
|
bool definition : 1;
|
|
|
|
|
bool signal : 1;
|
|
|
|
|
bool slot : 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline QDataStream &operator<<(QDataStream &out, const ExtraInfo &extraInfo);
|
|
|
|
|
inline QDataStream &operator>>(QDataStream &in, ExtraInfo &extraInfo);
|
|
|
|
|
inline bool operator==(const ExtraInfo &first, const ExtraInfo &second);
|
|
|
|
|
|
|
|
|
|
class TokenInfoContainer
|
|
|
|
|
{
|
2015-11-18 17:07:44 +01:00
|
|
|
public:
|
2017-12-05 09:42:35 +01:00
|
|
|
TokenInfoContainer() = default;
|
2018-01-19 09:18:57 +01:00
|
|
|
TokenInfoContainer(uint line, uint column, uint length, HighlightingTypes types)
|
2018-04-04 18:25:23 +02:00
|
|
|
: line(line)
|
|
|
|
|
, column(column)
|
|
|
|
|
, length(length)
|
|
|
|
|
, types(types)
|
2016-07-19 13:46:42 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-19 09:18:57 +01:00
|
|
|
TokenInfoContainer(uint line, uint column, uint length, HighlightingTypes types,
|
|
|
|
|
const ExtraInfo &extraInfo)
|
2018-04-04 18:25:23 +02:00
|
|
|
: line(line)
|
|
|
|
|
, column(column)
|
|
|
|
|
, length(length)
|
|
|
|
|
, types(types)
|
|
|
|
|
, extraInfo(extraInfo)
|
|
|
|
|
, noExtraInfo(false)
|
2016-07-19 13:46:42 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-19 09:18:57 +01:00
|
|
|
bool isInvalid() const
|
2018-01-12 09:44:05 +01:00
|
|
|
{
|
2018-04-04 18:25:23 +02:00
|
|
|
return line == 0 && column == 0 && length == 0;
|
2018-01-12 09:44:05 +01:00
|
|
|
}
|
2017-11-28 14:12:56 +01:00
|
|
|
|
2017-12-05 09:42:35 +01:00
|
|
|
friend QDataStream &operator<<(QDataStream &out, const TokenInfoContainer &container)
|
2016-07-19 13:46:42 +02:00
|
|
|
{
|
2018-04-04 18:25:23 +02:00
|
|
|
out << container.line;
|
|
|
|
|
out << container.column;
|
|
|
|
|
out << container.length;
|
|
|
|
|
out << container.types;
|
|
|
|
|
out << container.noExtraInfo;
|
2018-01-19 09:18:57 +01:00
|
|
|
|
2018-04-04 18:25:23 +02:00
|
|
|
if (container.noExtraInfo)
|
2018-01-19 09:18:57 +01:00
|
|
|
return out;
|
|
|
|
|
|
2018-04-04 18:25:23 +02:00
|
|
|
out << container.extraInfo;
|
2015-11-18 17:07:44 +01:00
|
|
|
|
2016-07-19 13:46:42 +02:00
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 09:42:35 +01:00
|
|
|
friend QDataStream &operator>>(QDataStream &in, TokenInfoContainer &container)
|
2016-07-19 13:46:42 +02:00
|
|
|
{
|
2018-04-04 18:25:23 +02:00
|
|
|
in >> container.line;
|
|
|
|
|
in >> container.column;
|
|
|
|
|
in >> container.length;
|
|
|
|
|
in >> container.types;
|
|
|
|
|
in >> container.noExtraInfo;
|
2018-01-12 09:44:05 +01:00
|
|
|
|
2018-04-04 18:25:23 +02:00
|
|
|
if (container.noExtraInfo)
|
2018-01-19 09:18:57 +01:00
|
|
|
return in;
|
2018-01-12 09:44:05 +01:00
|
|
|
|
2018-04-04 18:25:23 +02:00
|
|
|
in >> container.extraInfo;
|
2016-07-19 13:46:42 +02:00
|
|
|
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 09:42:35 +01:00
|
|
|
friend bool operator==(const TokenInfoContainer &first, const TokenInfoContainer &second)
|
2016-07-19 13:46:42 +02:00
|
|
|
{
|
2018-04-04 18:25:23 +02:00
|
|
|
return first.line == second.line
|
|
|
|
|
&& first.column == second.column
|
|
|
|
|
&& first.length == second.length
|
|
|
|
|
&& first.types == second.types
|
|
|
|
|
&& first.noExtraInfo == second.noExtraInfo
|
|
|
|
|
&& first.extraInfo == second.extraInfo;
|
2016-07-19 13:46:42 +02:00
|
|
|
}
|
2015-11-18 17:07:44 +01:00
|
|
|
|
2018-04-04 18:25:23 +02:00
|
|
|
uint line = 0;
|
|
|
|
|
uint column = 0;
|
|
|
|
|
uint length = 0;
|
|
|
|
|
HighlightingTypes types;
|
|
|
|
|
ExtraInfo extraInfo;
|
|
|
|
|
bool noExtraInfo = true;
|
2015-11-18 17:07:44 +01:00
|
|
|
};
|
|
|
|
|
|
2018-01-19 09:18:57 +01:00
|
|
|
inline QDataStream &operator<<(QDataStream &out, const ExtraInfo &extraInfo)
|
|
|
|
|
{
|
|
|
|
|
out << extraInfo.token;
|
|
|
|
|
out << extraInfo.typeSpelling;
|
|
|
|
|
out << extraInfo.resultTypeSpelling;
|
|
|
|
|
out << extraInfo.semanticParentTypeSpelling;
|
2018-02-07 13:59:06 +01:00
|
|
|
out << extraInfo.cursorRange;
|
2018-01-19 09:18:57 +01:00
|
|
|
out << static_cast<uint>(extraInfo.accessSpecifier);
|
|
|
|
|
out << static_cast<uint>(extraInfo.storageClass);
|
|
|
|
|
out << extraInfo.identifier;
|
|
|
|
|
out << extraInfo.includeDirectivePath;
|
|
|
|
|
out << extraInfo.declaration;
|
|
|
|
|
out << extraInfo.definition;
|
|
|
|
|
out << extraInfo.signal;
|
|
|
|
|
out << extraInfo.slot;
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline QDataStream &operator>>(QDataStream &in, ExtraInfo &extraInfo)
|
|
|
|
|
{
|
|
|
|
|
in >> extraInfo.token;
|
|
|
|
|
in >> extraInfo.typeSpelling;
|
|
|
|
|
in >> extraInfo.resultTypeSpelling;
|
|
|
|
|
in >> extraInfo.semanticParentTypeSpelling;
|
2018-02-07 13:59:06 +01:00
|
|
|
in >> extraInfo.cursorRange;
|
2018-01-19 09:18:57 +01:00
|
|
|
|
|
|
|
|
uint accessSpecifier;
|
|
|
|
|
uint storageClass;
|
|
|
|
|
bool isIdentifier;
|
|
|
|
|
bool isInclusion;
|
|
|
|
|
bool isDeclaration;
|
|
|
|
|
bool isDefinition;
|
|
|
|
|
bool isSignal;
|
|
|
|
|
bool isSlot;
|
|
|
|
|
|
|
|
|
|
in >> accessSpecifier;
|
|
|
|
|
in >> storageClass;
|
|
|
|
|
in >> isIdentifier;
|
|
|
|
|
in >> isInclusion;
|
|
|
|
|
in >> isDeclaration;
|
|
|
|
|
in >> isDefinition;
|
|
|
|
|
in >> isSignal;
|
|
|
|
|
in >> isSlot;
|
|
|
|
|
|
|
|
|
|
extraInfo.accessSpecifier = static_cast<AccessSpecifier>(accessSpecifier);
|
|
|
|
|
extraInfo.storageClass = static_cast<StorageClass>(storageClass);
|
|
|
|
|
extraInfo.identifier = isIdentifier;
|
|
|
|
|
extraInfo.includeDirectivePath = isInclusion;
|
|
|
|
|
extraInfo.declaration = isDeclaration;
|
|
|
|
|
extraInfo.definition = isDefinition;
|
|
|
|
|
extraInfo.signal = isSignal;
|
|
|
|
|
extraInfo.slot = isSlot;
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool operator==(const ExtraInfo &first, const ExtraInfo &second)
|
|
|
|
|
{
|
|
|
|
|
return first.token == second.token
|
|
|
|
|
&& first.typeSpelling == second.typeSpelling
|
|
|
|
|
&& first.resultTypeSpelling == second.resultTypeSpelling
|
|
|
|
|
&& first.semanticParentTypeSpelling == second.semanticParentTypeSpelling
|
2018-02-07 13:59:06 +01:00
|
|
|
&& first.cursorRange == second.cursorRange
|
2018-01-19 09:18:57 +01:00
|
|
|
&& first.accessSpecifier == second.accessSpecifier
|
|
|
|
|
&& first.storageClass == second.storageClass
|
|
|
|
|
&& first.identifier == second.identifier
|
|
|
|
|
&& first.includeDirectivePath == second.includeDirectivePath
|
|
|
|
|
&& first.declaration == second.declaration
|
|
|
|
|
&& first.definition == second.definition
|
|
|
|
|
&& first.signal == second.signal
|
2018-01-26 15:12:38 +01:00
|
|
|
&& first.slot == second.slot;
|
2018-01-19 09:18:57 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-19 13:46:42 +02:00
|
|
|
inline QDataStream &operator<<(QDataStream &out, HighlightingType highlightingType)
|
|
|
|
|
{
|
2018-04-04 21:52:53 +03:00
|
|
|
out << static_cast<quint8>(highlightingType);
|
2016-07-19 13:46:42 +02:00
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline QDataStream &operator<<(QDataStream &out, HighlightingTypes highlightingTypes)
|
|
|
|
|
{
|
|
|
|
|
out << highlightingTypes.mainHighlightingType;
|
|
|
|
|
|
|
|
|
|
out << highlightingTypes.mixinHighlightingTypes.size();
|
|
|
|
|
|
|
|
|
|
for (HighlightingType type : highlightingTypes.mixinHighlightingTypes)
|
|
|
|
|
out << type;
|
|
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline QDataStream &operator>>(QDataStream &in, HighlightingType &highlightingType)
|
|
|
|
|
{
|
|
|
|
|
quint8 highlightingTypeInt;
|
|
|
|
|
|
|
|
|
|
in >> highlightingTypeInt;
|
|
|
|
|
|
|
|
|
|
highlightingType = static_cast<HighlightingType>(highlightingTypeInt);
|
|
|
|
|
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline QDataStream &operator>>(QDataStream &in, HighlightingTypes &highlightingTypes)
|
|
|
|
|
{
|
|
|
|
|
in >> highlightingTypes.mainHighlightingType ;
|
|
|
|
|
|
|
|
|
|
quint8 size;
|
|
|
|
|
in >> size;
|
|
|
|
|
|
|
|
|
|
for (int counter = 0; counter < size; ++counter) {
|
|
|
|
|
HighlightingType type;
|
|
|
|
|
in >> type;
|
|
|
|
|
highlightingTypes.mixinHighlightingTypes.push_back(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool operator==(const MixinHighlightingTypes &first, const MixinHighlightingTypes &second)
|
|
|
|
|
{
|
|
|
|
|
return first.size() == second.size()
|
|
|
|
|
&& std::equal(first.begin(), first.end(), second.begin());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool operator==(const HighlightingTypes &first, const HighlightingTypes &second)
|
|
|
|
|
{
|
|
|
|
|
return first.mainHighlightingType == second.mainHighlightingType
|
|
|
|
|
&& first.mixinHighlightingTypes == second.mixinHighlightingTypes;
|
|
|
|
|
}
|
2015-11-18 17:07:44 +01:00
|
|
|
|
2017-11-28 14:12:56 +01:00
|
|
|
inline QDataStream &operator<<(QDataStream &out, ByteSizeBitset bits)
|
|
|
|
|
{
|
|
|
|
|
// Narrow unsigned long to uint8_t
|
|
|
|
|
out << static_cast<uint8_t>(bits.to_ulong());
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline QDataStream &operator>>(QDataStream &in, ByteSizeBitset &bits)
|
|
|
|
|
{
|
|
|
|
|
uint8_t byteValue;
|
|
|
|
|
in >> byteValue;
|
|
|
|
|
bits = ByteSizeBitset(byteValue);
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 09:42:35 +01:00
|
|
|
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const TokenInfoContainer &container);
|
2015-11-18 17:07:44 +01:00
|
|
|
|
|
|
|
|
} // namespace ClangBackEnd
|