forked from qt-creator/qt-creator
Clang: add more data to TokenInfo class
Add token name, usr, isDefinition and isDeclaration. Change-Id: If67bf78c999cb9edd397d0b553b33e5f5f378f8a Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -40,9 +40,9 @@
|
||||
namespace ClangBackEnd {
|
||||
|
||||
TokenInfo::TokenInfo(const CXCursor &cxCursor,
|
||||
CXToken *cxToken,
|
||||
CXTranslationUnit cxTranslationUnit,
|
||||
std::vector<CXSourceRange> ¤tOutputArgumentRanges)
|
||||
CXToken *cxToken,
|
||||
CXTranslationUnit cxTranslationUnit,
|
||||
std::vector<CXSourceRange> ¤tOutputArgumentRanges)
|
||||
: m_currentOutputArgumentRanges(¤tOutputArgumentRanges),
|
||||
m_originalCursor(cxCursor)
|
||||
{
|
||||
@@ -115,8 +115,9 @@ bool TokenInfo::hasFunctionArguments() const
|
||||
|
||||
TokenInfo::operator TokenInfoContainer() const
|
||||
{
|
||||
return TokenInfoContainer(m_line, m_column, m_length, m_types, m_isIdentifier,
|
||||
m_isInclusion);
|
||||
return TokenInfoContainer(m_line, m_column, m_length, m_types, m_token, m_typeSpelling,
|
||||
m_isIdentifier, m_isInclusion,
|
||||
m_isDeclaration, m_isDefinition);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -451,6 +452,13 @@ void TokenInfo::collectKinds(CXTranslationUnit cxTranslationUnit,
|
||||
auto cxTokenKind = clang_getTokenKind(*cxToken);
|
||||
|
||||
m_types = HighlightingTypes();
|
||||
m_token = ClangString(clang_getTokenSpelling(cxTranslationUnit, *cxToken));
|
||||
m_typeSpelling = cursor.type().utf8Spelling();
|
||||
|
||||
if (cxTokenKind == CXToken_Identifier) {
|
||||
m_isDeclaration = cursor.isDeclaration();
|
||||
m_isDefinition = cursor.isDefinition();
|
||||
}
|
||||
|
||||
switch (cxTokenKind) {
|
||||
case CXToken_Keyword: m_types.mainHighlightingType = highlightingTypeForKeyword(cxTranslationUnit, cxToken, m_originalCursor); break;
|
||||
|
||||
@@ -25,10 +25,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <clangsupport_global.h>
|
||||
#include <tokeninfocontainer.h>
|
||||
|
||||
#include "clangsupport_global.h"
|
||||
#include "cursor.h"
|
||||
#include "tokeninfocontainer.h"
|
||||
|
||||
#include <sqlite/utf8string.h>
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
|
||||
@@ -45,9 +46,9 @@ class TokenInfo
|
||||
|
||||
public:
|
||||
TokenInfo(const CXCursor &cxCursor,
|
||||
CXToken *cxToken,
|
||||
CXTranslationUnit cxTranslationUnit,
|
||||
std::vector<CXSourceRange> &m_currentOutputArgumentRanges);
|
||||
CXToken *cxToken,
|
||||
CXTranslationUnit cxTranslationUnit,
|
||||
std::vector<CXSourceRange> &m_currentOutputArgumentRanges);
|
||||
TokenInfo(uint m_line, uint m_column, uint m_length, HighlightingTypes m_types);
|
||||
TokenInfo(uint m_line, uint m_column, uint m_length, HighlightingType type);
|
||||
|
||||
@@ -90,8 +91,12 @@ private:
|
||||
uint m_length;
|
||||
uint m_offset = 0;
|
||||
HighlightingTypes m_types;
|
||||
Utf8String m_token;
|
||||
Utf8String m_typeSpelling;
|
||||
bool m_isIdentifier = false;
|
||||
bool m_isInclusion = false;
|
||||
bool m_isDeclaration = false;
|
||||
bool m_isDefinition = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user