2015-11-17 13:33:31 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:14 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-11-17 13:33:31 +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:57:14 +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-17 13:33:31 +01:00
|
|
|
**
|
2016-01-15 14:57:14 +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-17 13:33:31 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-02-29 13:09:39 +01:00
|
|
|
#pragma once
|
2015-11-17 13:33:31 +01:00
|
|
|
|
|
|
|
|
#include <clangbackendipc_global.h>
|
2015-11-18 17:07:44 +01:00
|
|
|
#include <highlightingmarkcontainer.h>
|
2015-11-17 13:33:31 +01:00
|
|
|
|
|
|
|
|
#include "cursor.h"
|
|
|
|
|
|
|
|
|
|
#include <clang-c/Index.h>
|
|
|
|
|
|
|
|
|
|
namespace ClangBackEnd {
|
|
|
|
|
|
2016-02-29 13:09:39 +01:00
|
|
|
class HighlightingMark
|
2015-11-17 13:33:31 +01:00
|
|
|
{
|
2016-02-29 13:09:39 +01:00
|
|
|
friend bool operator==(const HighlightingMark &first, const HighlightingMark &second);
|
2015-11-17 13:33:31 +01:00
|
|
|
|
2016-03-03 13:02:29 +01:00
|
|
|
enum class Recursion {
|
|
|
|
|
FirstPass,
|
|
|
|
|
RecursivePass
|
|
|
|
|
};
|
|
|
|
|
|
2015-11-17 13:33:31 +01:00
|
|
|
public:
|
2016-10-11 18:19:12 +02:00
|
|
|
HighlightingMark(const CXCursor &cxCursor,
|
|
|
|
|
CXToken *cxToken,
|
|
|
|
|
CXTranslationUnit cxTranslationUnit,
|
|
|
|
|
std::vector<CXSourceRange> ¤tOutputArgumentRanges);
|
2016-03-03 13:02:29 +01:00
|
|
|
HighlightingMark(uint line, uint column, uint length, HighlightingTypes types);
|
2016-02-29 13:09:39 +01:00
|
|
|
HighlightingMark(uint line, uint column, uint length, HighlightingType type);
|
2015-11-17 13:33:31 +01:00
|
|
|
|
2016-03-03 13:02:29 +01:00
|
|
|
bool hasInvalidMainType() const;
|
|
|
|
|
bool hasMainType(HighlightingType type) const;
|
|
|
|
|
bool hasMixinType(HighlightingType type) const;
|
|
|
|
|
bool hasOnlyType(HighlightingType type) const;
|
2015-11-17 13:33:31 +01:00
|
|
|
bool hasFunctionArguments() const;
|
|
|
|
|
|
2015-11-18 17:07:44 +01:00
|
|
|
operator HighlightingMarkContainer() const;
|
|
|
|
|
|
2015-11-17 13:33:31 +01:00
|
|
|
private:
|
2016-03-03 13:02:29 +01:00
|
|
|
void identifierKind(const Cursor &cursor, Recursion recursion);
|
|
|
|
|
void referencedTypeKind(const Cursor &cursor);
|
2017-06-01 11:00:59 +02:00
|
|
|
void overloadedDeclRefKind(const Cursor &cursor);
|
2016-03-03 13:02:29 +01:00
|
|
|
void variableKind(const Cursor &cursor);
|
2016-10-11 18:19:12 +02:00
|
|
|
void fieldKind(const Cursor &cursor);
|
2015-11-17 13:33:31 +01:00
|
|
|
bool isVirtualMethodDeclarationOrDefinition(const Cursor &cursor) const;
|
2016-03-03 13:02:29 +01:00
|
|
|
void functionKind(const Cursor &cursor, Recursion recursion);
|
|
|
|
|
void memberReferenceKind(const Cursor &cursor);
|
2016-10-11 18:19:12 +02:00
|
|
|
HighlightingType punctuationKind(const Cursor &cursor);
|
2017-05-17 16:40:21 +02:00
|
|
|
void collectKinds(CXTranslationUnit cxTranslationUnit, CXToken *cxToken, const Cursor &cursor);
|
2015-11-17 13:33:31 +01:00
|
|
|
bool isRealDynamicCall(const Cursor &cursor) const;
|
2016-03-03 13:02:29 +01:00
|
|
|
void addExtraTypeIfFirstPass(HighlightingType type, Recursion recursion);
|
2016-10-11 18:19:12 +02:00
|
|
|
bool isOutputArgument() const;
|
|
|
|
|
void collectOutputArguments(const Cursor &cursor);
|
|
|
|
|
void filterOutPreviousOutputArguments();
|
|
|
|
|
bool isArgumentInCurrentOutputArgumentLocations() const;
|
2015-11-17 13:33:31 +01:00
|
|
|
|
2017-06-12 20:03:34 +02:00
|
|
|
friend std::ostream &operator<<(std::ostream &os, const HighlightingMark& highlightingMark);
|
|
|
|
|
|
2015-11-17 13:33:31 +01:00
|
|
|
private:
|
2016-10-11 18:19:12 +02:00
|
|
|
std::vector<CXSourceRange> *currentOutputArgumentRanges = nullptr;
|
2015-11-17 13:33:31 +01:00
|
|
|
Cursor originalCursor;
|
|
|
|
|
uint line;
|
|
|
|
|
uint column;
|
|
|
|
|
uint length;
|
2016-10-11 18:19:12 +02:00
|
|
|
uint offset = 0;
|
2016-03-03 13:02:29 +01:00
|
|
|
HighlightingTypes types;
|
2015-11-17 13:33:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2016-02-29 13:09:39 +01:00
|
|
|
inline bool operator==(const HighlightingMark &first, const HighlightingMark &second)
|
2015-11-17 13:33:31 +01:00
|
|
|
{
|
|
|
|
|
return first.line == second.line
|
|
|
|
|
&& first.column == second.column
|
|
|
|
|
&& first.length == second.length
|
2016-03-03 13:02:29 +01:00
|
|
|
&& first.types == second.types;
|
2015-11-17 13:33:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ClangBackEnd
|