forked from qt-creator/qt-creator
Clang: Rename HighlightingMark to TokenInfo
Before adding additional members into that class it makes sense to rename it to better represent its content. Other classes serving the same purpose are also renamed to keep the names consistent. Change-Id: I3c8517e42aae29779d71ec9c85b713cff581a473 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -48,14 +48,14 @@ HEADERS += \
|
||||
$$PWD/diagnosticset.h \
|
||||
$$PWD/diagnosticsetiterator.h \
|
||||
$$PWD/fixit.h \
|
||||
$$PWD/highlightingmark.h \
|
||||
$$PWD/highlightingmarks.h \
|
||||
$$PWD/highlightingmarksiterator.h \
|
||||
$$PWD/projectpart.h \
|
||||
$$PWD/projects.h \
|
||||
$$PWD/skippedsourceranges.h \
|
||||
$$PWD/sourcelocation.h \
|
||||
$$PWD/sourcerange.h \
|
||||
$$PWD/tokeninfo.h \
|
||||
$$PWD/tokeninfos.h \
|
||||
$$PWD/tokeninfositerator.h \
|
||||
$$PWD/unsavedfile.h \
|
||||
$$PWD/unsavedfiles.h \
|
||||
$$PWD/utf8positionfromlinecolumn.h
|
||||
@@ -102,13 +102,13 @@ SOURCES += \
|
||||
$$PWD/diagnostic.cpp \
|
||||
$$PWD/diagnosticset.cpp \
|
||||
$$PWD/fixit.cpp \
|
||||
$$PWD/highlightingmark.cpp \
|
||||
$$PWD/highlightingmarks.cpp \
|
||||
$$PWD/projectpart.cpp \
|
||||
$$PWD/projects.cpp \
|
||||
$$PWD/skippedsourceranges.cpp \
|
||||
$$PWD/sourcelocation.cpp \
|
||||
$$PWD/sourcerange.cpp \
|
||||
$$PWD/tokeninfo.cpp \
|
||||
$$PWD/tokeninfos.cpp \
|
||||
$$PWD/unsavedfile.cpp \
|
||||
$$PWD/unsavedfiles.cpp \
|
||||
$$PWD/utf8positionfromlinecolumn.cpp
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "clangtranslationunits.h"
|
||||
#include "codecompleter.h"
|
||||
#include "diagnosticset.h"
|
||||
#include "highlightingmarks.h"
|
||||
#include "tokeninfos.h"
|
||||
#include "clangexceptions.h"
|
||||
#include "skippedsourceranges.h"
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "clangdocuments.h"
|
||||
|
||||
#include <diagnosticset.h>
|
||||
#include <highlightingmarks.h>
|
||||
#include <tokeninfos.h>
|
||||
#include <clangexceptions.h>
|
||||
#include <projects.h>
|
||||
#include <skippedsourceranges.h>
|
||||
|
||||
@@ -47,7 +47,7 @@ IAsyncJob::AsyncPrepareResult RequestDocumentAnnotationsJob::prepareAsyncRun()
|
||||
RequestDocumentAnnotationsJob::AsyncResult asyncResult;
|
||||
translationUnit.extractDocumentAnnotations(asyncResult.firstHeaderErrorDiagnostic,
|
||||
asyncResult.diagnostics,
|
||||
asyncResult.highlightingMarks,
|
||||
asyncResult.tokenInfos,
|
||||
asyncResult.skippedSourceRanges);
|
||||
return asyncResult;
|
||||
});
|
||||
@@ -63,7 +63,7 @@ void RequestDocumentAnnotationsJob::finalizeAsyncRun()
|
||||
DocumentAnnotationsChangedMessage(m_pinnedFileContainer,
|
||||
result.diagnostics,
|
||||
result.firstHeaderErrorDiagnostic,
|
||||
result.highlightingMarks,
|
||||
result.tokenInfos,
|
||||
result.skippedSourceRanges));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "clangdocumentjob.h"
|
||||
|
||||
#include <clangsupport/diagnosticcontainer.h>
|
||||
#include <clangsupport/highlightingmarkcontainer.h>
|
||||
#include <clangsupport/tokeninfocontainer.h>
|
||||
#include <clangsupport/sourcerangecontainer.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
@@ -37,7 +37,7 @@ struct RequestDocumentAnnotationsJobResult
|
||||
{
|
||||
ClangBackEnd::DiagnosticContainer firstHeaderErrorDiagnostic;
|
||||
QVector<ClangBackEnd::DiagnosticContainer> diagnostics;
|
||||
QVector<HighlightingMarkContainer> highlightingMarks;
|
||||
QVector<TokenInfoContainer> tokenInfos;
|
||||
QVector<SourceRangeContainer> skippedSourceRanges;
|
||||
};
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
#include <cursor.h>
|
||||
#include <diagnosticcontainer.h>
|
||||
#include <diagnosticset.h>
|
||||
#include <highlightingmark.h>
|
||||
#include <highlightingmarks.h>
|
||||
#include <tokeninfo.h>
|
||||
#include <tokeninfos.h>
|
||||
#include <skippedsourceranges.h>
|
||||
#include <sourcelocation.h>
|
||||
#include <sourcerange.h>
|
||||
@@ -131,11 +131,11 @@ TranslationUnit::CodeCompletionResult TranslationUnit::complete(
|
||||
void TranslationUnit::extractDocumentAnnotations(
|
||||
DiagnosticContainer &firstHeaderErrorDiagnostic,
|
||||
QVector<DiagnosticContainer> &mainFileDiagnostics,
|
||||
QVector<HighlightingMarkContainer> &highlightingMarks,
|
||||
QVector<TokenInfoContainer> &tokenInfos,
|
||||
QVector<SourceRangeContainer> &skippedSourceRanges) const
|
||||
{
|
||||
extractDiagnostics(firstHeaderErrorDiagnostic, mainFileDiagnostics);
|
||||
highlightingMarks = this->highlightingMarks().toHighlightingMarksContainers();
|
||||
tokenInfos = this->tokenInfos().toTokenInfoContainers();
|
||||
skippedSourceRanges = this->skippedSourceRanges().toSourceRangeContainers();
|
||||
}
|
||||
|
||||
@@ -187,19 +187,19 @@ Cursor TranslationUnit::cursor() const
|
||||
return clang_getTranslationUnitCursor(m_cxTranslationUnit);
|
||||
}
|
||||
|
||||
HighlightingMarks TranslationUnit::highlightingMarks() const
|
||||
TokenInfos TranslationUnit::tokenInfos() const
|
||||
{
|
||||
return highlightingMarksInRange(cursor().sourceRange());
|
||||
return tokenInfosInRange(cursor().sourceRange());
|
||||
}
|
||||
|
||||
HighlightingMarks TranslationUnit::highlightingMarksInRange(const SourceRange &range) const
|
||||
TokenInfos TranslationUnit::tokenInfosInRange(const SourceRange &range) const
|
||||
{
|
||||
CXToken *cxTokens = 0;
|
||||
uint cxTokensCount = 0;
|
||||
|
||||
clang_tokenize(m_cxTranslationUnit, range, &cxTokens, &cxTokensCount);
|
||||
|
||||
return HighlightingMarks(m_cxTranslationUnit, cxTokens, cxTokensCount);
|
||||
return TokenInfos(m_cxTranslationUnit, cxTokens, cxTokensCount);
|
||||
}
|
||||
|
||||
SkippedSourceRanges TranslationUnit::skippedSourceRanges() const
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace ClangBackEnd {
|
||||
class Cursor;
|
||||
class DiagnosticContainer;
|
||||
class DiagnosticSet;
|
||||
class HighlightingMarkContainer;
|
||||
class HighlightingMarks;
|
||||
class TokenInfoContainer;
|
||||
class TokenInfos;
|
||||
class ReferencesResult;
|
||||
class SkippedSourceRanges;
|
||||
class SourceLocation;
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
QVector<DiagnosticContainer> &mainFileDiagnostics) const;
|
||||
void extractDocumentAnnotations(DiagnosticContainer &firstHeaderErrorDiagnostic,
|
||||
QVector<DiagnosticContainer> &mainFileDiagnostics,
|
||||
QVector<HighlightingMarkContainer> &highlightingMarks,
|
||||
QVector<TokenInfoContainer> &tokenInfos,
|
||||
QVector<SourceRangeContainer> &skippedSourceRanges) const;
|
||||
|
||||
|
||||
@@ -96,8 +96,8 @@ public:
|
||||
Cursor cursorAt(const Utf8String &filePath, uint line, uint column) const;
|
||||
Cursor cursor() const;
|
||||
|
||||
HighlightingMarks highlightingMarks() const;
|
||||
HighlightingMarks highlightingMarksInRange(const SourceRange &range) const;
|
||||
TokenInfos tokenInfos() const;
|
||||
TokenInfos tokenInfosInRange(const SourceRange &range) const;
|
||||
|
||||
SkippedSourceRanges skippedSourceRanges() const;
|
||||
SourceRangeContainer followSymbol(uint line,
|
||||
|
||||
@@ -51,7 +51,7 @@ IAsyncJob::AsyncPrepareResult UpdateDocumentAnnotationsJob::prepareAsyncRun()
|
||||
// Collect
|
||||
translationUnit.extractDocumentAnnotations(asyncResult.firstHeaderErrorDiagnostic,
|
||||
asyncResult.diagnostics,
|
||||
asyncResult.highlightingMarks,
|
||||
asyncResult.tokenInfos,
|
||||
asyncResult.skippedSourceRanges);
|
||||
|
||||
return asyncResult;
|
||||
@@ -70,7 +70,7 @@ void UpdateDocumentAnnotationsJob::finalizeAsyncRun()
|
||||
DocumentAnnotationsChangedMessage(m_pinnedFileContainer,
|
||||
result.diagnostics,
|
||||
result.firstHeaderErrorDiagnostic,
|
||||
result.highlightingMarks,
|
||||
result.tokenInfos,
|
||||
result.skippedSourceRanges));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "clangdocumentjob.h"
|
||||
|
||||
#include <clangsupport/diagnosticcontainer.h>
|
||||
#include <clangsupport/highlightingmarkcontainer.h>
|
||||
#include <clangsupport/tokeninfocontainer.h>
|
||||
#include <clangsupport/sourcerangecontainer.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
@@ -39,7 +39,7 @@ struct UpdateDocumentAnnotationsJobResult
|
||||
|
||||
ClangBackEnd::DiagnosticContainer firstHeaderErrorDiagnostic;
|
||||
QVector<ClangBackEnd::DiagnosticContainer> diagnostics;
|
||||
QVector<HighlightingMarkContainer> highlightingMarks;
|
||||
QVector<TokenInfoContainer> tokenInfos;
|
||||
QVector<SourceRangeContainer> skippedSourceRanges;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <highlightingmarkcontainer.h>
|
||||
#include <tokeninfocontainer.h>
|
||||
|
||||
#include "clangstring.h"
|
||||
#include "cursor.h"
|
||||
#include "highlightingmark.h"
|
||||
#include "tokeninfo.h"
|
||||
#include "sourcelocation.h"
|
||||
#include "sourcerange.h"
|
||||
#include "sourcerangecontainer.h"
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
HighlightingMark::HighlightingMark(const CXCursor &cxCursor,
|
||||
TokenInfo::TokenInfo(const CXCursor &cxCursor,
|
||||
CXToken *cxToken,
|
||||
CXTranslationUnit cxTranslationUnit,
|
||||
std::vector<CXSourceRange> ¤tOutputArgumentRanges)
|
||||
@@ -57,7 +57,7 @@ HighlightingMark::HighlightingMark(const CXCursor &cxCursor,
|
||||
collectKinds(cxTranslationUnit, cxToken, m_originalCursor);
|
||||
}
|
||||
|
||||
HighlightingMark::HighlightingMark(uint line, uint column, uint length, HighlightingTypes types)
|
||||
TokenInfo::TokenInfo(uint line, uint column, uint length, HighlightingTypes types)
|
||||
: m_line(line),
|
||||
m_column(column),
|
||||
m_length(length),
|
||||
@@ -65,7 +65,7 @@ HighlightingMark::HighlightingMark(uint line, uint column, uint length, Highligh
|
||||
{
|
||||
}
|
||||
|
||||
HighlightingMark::HighlightingMark(uint line, uint column, uint length, HighlightingType type)
|
||||
TokenInfo::TokenInfo(uint line, uint column, uint length, HighlightingType type)
|
||||
: m_line(line),
|
||||
m_column(column),
|
||||
m_length(length),
|
||||
@@ -74,21 +74,21 @@ HighlightingMark::HighlightingMark(uint line, uint column, uint length, Highligh
|
||||
m_types.mainHighlightingType = type;
|
||||
}
|
||||
|
||||
bool HighlightingMark::hasInvalidMainType() const
|
||||
bool TokenInfo::hasInvalidMainType() const
|
||||
{
|
||||
return m_types.mainHighlightingType == HighlightingType::Invalid;
|
||||
}
|
||||
|
||||
bool HighlightingMark::hasMainType(HighlightingType type) const
|
||||
bool TokenInfo::hasMainType(HighlightingType type) const
|
||||
{
|
||||
return m_types.mainHighlightingType == type;
|
||||
}
|
||||
|
||||
unsigned HighlightingMark::mixinSize() const {
|
||||
unsigned TokenInfo::mixinSize() const {
|
||||
return m_types.mixinHighlightingTypes.size();
|
||||
}
|
||||
|
||||
bool HighlightingMark::hasMixinType(HighlightingType type) const
|
||||
bool TokenInfo::hasMixinType(HighlightingType type) const
|
||||
{
|
||||
auto found = std::find(m_types.mixinHighlightingTypes.begin(),
|
||||
m_types.mixinHighlightingTypes.end(),
|
||||
@@ -97,25 +97,25 @@ bool HighlightingMark::hasMixinType(HighlightingType type) const
|
||||
return found != m_types.mixinHighlightingTypes.end();
|
||||
}
|
||||
|
||||
bool HighlightingMark::hasMixinTypeAt(uint position, HighlightingType type) const
|
||||
bool TokenInfo::hasMixinTypeAt(uint position, HighlightingType type) const
|
||||
{
|
||||
return m_types.mixinHighlightingTypes.size() > position &&
|
||||
m_types.mixinHighlightingTypes.at(position) == type;
|
||||
}
|
||||
|
||||
bool HighlightingMark::hasOnlyType(HighlightingType type) const
|
||||
bool TokenInfo::hasOnlyType(HighlightingType type) const
|
||||
{
|
||||
return m_types.mixinHighlightingTypes.size() == 0 && hasMainType(type);
|
||||
}
|
||||
|
||||
bool HighlightingMark::hasFunctionArguments() const
|
||||
bool TokenInfo::hasFunctionArguments() const
|
||||
{
|
||||
return m_originalCursor.argumentCount() > 0;
|
||||
}
|
||||
|
||||
HighlightingMark::operator HighlightingMarkContainer() const
|
||||
TokenInfo::operator TokenInfoContainer() const
|
||||
{
|
||||
return HighlightingMarkContainer(m_line, m_column, m_length, m_types, m_isIdentifier,
|
||||
return TokenInfoContainer(m_line, m_column, m_length, m_types, m_isIdentifier,
|
||||
m_isInclusion);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ bool isFunctionInFinalClass(const Cursor &cursor)
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightingMark::memberReferenceKind(const Cursor &cursor)
|
||||
void TokenInfo::memberReferenceKind(const Cursor &cursor)
|
||||
{
|
||||
if (cursor.isDynamicCall()) {
|
||||
if (isFinalFunction(cursor) || isFunctionInFinalClass(cursor))
|
||||
@@ -152,7 +152,7 @@ void HighlightingMark::memberReferenceKind(const Cursor &cursor)
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightingMark::referencedTypeKind(const Cursor &cursor)
|
||||
void TokenInfo::referencedTypeKind(const Cursor &cursor)
|
||||
{
|
||||
const Cursor referencedCursor = cursor.referenced();
|
||||
|
||||
@@ -168,7 +168,7 @@ void HighlightingMark::referencedTypeKind(const Cursor &cursor)
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightingMark::overloadedDeclRefKind(const Cursor &cursor)
|
||||
void TokenInfo::overloadedDeclRefKind(const Cursor &cursor)
|
||||
{
|
||||
m_types.mainHighlightingType = HighlightingType::Function;
|
||||
|
||||
@@ -182,7 +182,7 @@ void HighlightingMark::overloadedDeclRefKind(const Cursor &cursor)
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightingMark::variableKind(const Cursor &cursor)
|
||||
void TokenInfo::variableKind(const Cursor &cursor)
|
||||
{
|
||||
if (cursor.isLocalVariable())
|
||||
m_types.mainHighlightingType = HighlightingType::LocalVariable;
|
||||
@@ -193,7 +193,7 @@ void HighlightingMark::variableKind(const Cursor &cursor)
|
||||
m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument);
|
||||
}
|
||||
|
||||
void HighlightingMark::fieldKind(const Cursor &)
|
||||
void TokenInfo::fieldKind(const Cursor &)
|
||||
{
|
||||
m_types.mainHighlightingType = HighlightingType::Field;
|
||||
|
||||
@@ -201,12 +201,12 @@ void HighlightingMark::fieldKind(const Cursor &)
|
||||
m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument);
|
||||
}
|
||||
|
||||
bool HighlightingMark::isDefinition() const
|
||||
bool TokenInfo::isDefinition() const
|
||||
{
|
||||
return m_originalCursor.isDefinition();
|
||||
}
|
||||
|
||||
bool HighlightingMark::isVirtualMethodDeclarationOrDefinition(const Cursor &cursor) const
|
||||
bool TokenInfo::isVirtualMethodDeclarationOrDefinition(const Cursor &cursor) const
|
||||
{
|
||||
return cursor.isVirtualMethod()
|
||||
&& (m_originalCursor.isDeclaration() || m_originalCursor.isDefinition());
|
||||
@@ -218,19 +218,19 @@ bool isNotFinalFunction(const Cursor &cursor)
|
||||
return !cursor.hasFinalFunctionAttribute();
|
||||
}
|
||||
}
|
||||
bool HighlightingMark::isRealDynamicCall(const Cursor &cursor) const
|
||||
bool TokenInfo::isRealDynamicCall(const Cursor &cursor) const
|
||||
{
|
||||
return m_originalCursor.isDynamicCall() && isNotFinalFunction(cursor);
|
||||
}
|
||||
|
||||
void HighlightingMark::addExtraTypeIfFirstPass(HighlightingType type,
|
||||
void TokenInfo::addExtraTypeIfFirstPass(HighlightingType type,
|
||||
Recursion recursion)
|
||||
{
|
||||
if (recursion == Recursion::FirstPass)
|
||||
m_types.mixinHighlightingTypes.push_back(type);
|
||||
}
|
||||
|
||||
bool HighlightingMark::isArgumentInCurrentOutputArgumentLocations() const
|
||||
bool TokenInfo::isArgumentInCurrentOutputArgumentLocations() const
|
||||
{
|
||||
auto originalSourceLocation = m_originalCursor.cxSourceLocation();
|
||||
|
||||
@@ -248,7 +248,7 @@ bool HighlightingMark::isArgumentInCurrentOutputArgumentLocations() const
|
||||
return isOutputArgument;
|
||||
}
|
||||
|
||||
bool HighlightingMark::isOutputArgument() const
|
||||
bool TokenInfo::isOutputArgument() const
|
||||
{
|
||||
if (m_currentOutputArgumentRanges->empty())
|
||||
return false;
|
||||
@@ -256,7 +256,7 @@ bool HighlightingMark::isOutputArgument() const
|
||||
return isArgumentInCurrentOutputArgumentLocations();
|
||||
}
|
||||
|
||||
void HighlightingMark::collectOutputArguments(const Cursor &cursor)
|
||||
void TokenInfo::collectOutputArguments(const Cursor &cursor)
|
||||
{
|
||||
cursor.collectOutputArgumentRangesTo(*m_currentOutputArgumentRanges);
|
||||
filterOutPreviousOutputArguments();
|
||||
@@ -276,7 +276,7 @@ uint getEnd(CXSourceRange cxSourceRange)
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightingMark::filterOutPreviousOutputArguments()
|
||||
void TokenInfo::filterOutPreviousOutputArguments()
|
||||
{
|
||||
auto isAfterLocation = [this] (CXSourceRange outputRange) {
|
||||
return getEnd(outputRange) > m_offset;
|
||||
@@ -289,7 +289,7 @@ void HighlightingMark::filterOutPreviousOutputArguments()
|
||||
m_currentOutputArgumentRanges->erase(precedingBegin, m_currentOutputArgumentRanges->end());
|
||||
}
|
||||
|
||||
void HighlightingMark::functionKind(const Cursor &cursor, Recursion recursion)
|
||||
void TokenInfo::functionKind(const Cursor &cursor, Recursion recursion)
|
||||
{
|
||||
if (isRealDynamicCall(cursor) || isVirtualMethodDeclarationOrDefinition(cursor))
|
||||
m_types.mainHighlightingType = HighlightingType::VirtualFunction;
|
||||
@@ -305,7 +305,7 @@ void HighlightingMark::functionKind(const Cursor &cursor, Recursion recursion)
|
||||
addExtraTypeIfFirstPass(HighlightingType::FunctionDefinition, recursion);
|
||||
}
|
||||
|
||||
void HighlightingMark::identifierKind(const Cursor &cursor, Recursion recursion)
|
||||
void TokenInfo::identifierKind(const Cursor &cursor, Recursion recursion)
|
||||
{
|
||||
m_isIdentifier = (cursor.kind() != CXCursor_PreprocessingDirective);
|
||||
|
||||
@@ -398,7 +398,7 @@ HighlightingType operatorKind(const Cursor &cursor)
|
||||
|
||||
}
|
||||
|
||||
HighlightingType HighlightingMark::punctuationKind(const Cursor &cursor)
|
||||
HighlightingType TokenInfo::punctuationKind(const Cursor &cursor)
|
||||
{
|
||||
HighlightingType highlightingType = HighlightingType::Invalid;
|
||||
|
||||
@@ -445,7 +445,7 @@ static HighlightingType highlightingTypeForKeyword(CXTranslationUnit cxTranslati
|
||||
return HighlightingType::Keyword;
|
||||
}
|
||||
|
||||
void HighlightingMark::collectKinds(CXTranslationUnit cxTranslationUnit,
|
||||
void TokenInfo::collectKinds(CXTranslationUnit cxTranslationUnit,
|
||||
CXToken *cxToken, const Cursor &cursor)
|
||||
{
|
||||
auto cxTokenKind = clang_getTokenKind(*cxToken);
|
||||
@@ -463,12 +463,12 @@ void HighlightingMark::collectKinds(CXTranslationUnit cxTranslationUnit,
|
||||
m_isInclusion = (cursor.kind() == CXCursor_InclusionDirective);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const HighlightingMark& highlightingMark)
|
||||
std::ostream &operator<<(std::ostream &os, const TokenInfo& tokenInfo)
|
||||
{
|
||||
os << "(type: " << highlightingMark.m_types << ", "
|
||||
<< " line: " << highlightingMark.m_line << ", "
|
||||
<< " column: " << highlightingMark.m_column << ", "
|
||||
<< " length: " << highlightingMark.m_length
|
||||
os << "(type: " << tokenInfo.m_types << ", "
|
||||
<< " line: " << tokenInfo.m_line << ", "
|
||||
<< " column: " << tokenInfo.m_column << ", "
|
||||
<< " length: " << tokenInfo.m_length
|
||||
<< ")";
|
||||
|
||||
return os;
|
||||
@@ -26,7 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <clangsupport_global.h>
|
||||
#include <highlightingmarkcontainer.h>
|
||||
#include <tokeninfocontainer.h>
|
||||
|
||||
#include "cursor.h"
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class HighlightingMark
|
||||
class TokenInfo
|
||||
{
|
||||
friend bool operator==(const HighlightingMark &first, const HighlightingMark &second);
|
||||
friend bool operator==(const TokenInfo &first, const TokenInfo &second);
|
||||
|
||||
enum class Recursion {
|
||||
FirstPass,
|
||||
@@ -44,12 +44,12 @@ class HighlightingMark
|
||||
};
|
||||
|
||||
public:
|
||||
HighlightingMark(const CXCursor &cxCursor,
|
||||
TokenInfo(const CXCursor &cxCursor,
|
||||
CXToken *cxToken,
|
||||
CXTranslationUnit cxTranslationUnit,
|
||||
std::vector<CXSourceRange> &m_currentOutputArgumentRanges);
|
||||
HighlightingMark(uint m_line, uint m_column, uint m_length, HighlightingTypes m_types);
|
||||
HighlightingMark(uint m_line, uint m_column, uint m_length, HighlightingType type);
|
||||
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);
|
||||
|
||||
bool hasInvalidMainType() const;
|
||||
bool hasMainType(HighlightingType type) const;
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
bool hasOnlyType(HighlightingType type) const;
|
||||
bool hasFunctionArguments() const;
|
||||
|
||||
operator HighlightingMarkContainer() const;
|
||||
operator TokenInfoContainer() const;
|
||||
|
||||
private:
|
||||
void identifierKind(const Cursor &cursor, Recursion recursion);
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
void filterOutPreviousOutputArguments();
|
||||
bool isArgumentInCurrentOutputArgumentLocations() const;
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &os, const HighlightingMark& highlightingMark);
|
||||
friend std::ostream &operator<<(std::ostream &os, const TokenInfo& tokenInfo);
|
||||
|
||||
private:
|
||||
std::vector<CXSourceRange> *m_currentOutputArgumentRanges = nullptr;
|
||||
@@ -95,7 +95,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
inline bool operator==(const HighlightingMark &first, const HighlightingMark &second)
|
||||
inline bool operator==(const TokenInfo &first, const TokenInfo &second)
|
||||
{
|
||||
return first.m_line == second.m_line
|
||||
&& first.m_column == second.m_column
|
||||
@@ -23,15 +23,15 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "highlightingmarks.h"
|
||||
#include "tokeninfos.h"
|
||||
|
||||
#include "highlightingmarkcontainer.h"
|
||||
#include "tokeninfocontainer.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
HighlightingMarks::HighlightingMarks(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount)
|
||||
TokenInfos::TokenInfos(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount)
|
||||
: cxTranslationUnit(cxTranslationUnit),
|
||||
cxToken(tokens),
|
||||
cxTokenCount(tokensCount)
|
||||
@@ -40,12 +40,12 @@ HighlightingMarks::HighlightingMarks(CXTranslationUnit cxTranslationUnit, CXToke
|
||||
clang_annotateTokens(cxTranslationUnit, cxToken, cxTokenCount, cxCursor.data());
|
||||
}
|
||||
|
||||
HighlightingMarks::~HighlightingMarks()
|
||||
TokenInfos::~TokenInfos()
|
||||
{
|
||||
clang_disposeTokens(cxTranslationUnit, cxToken, cxTokenCount);
|
||||
}
|
||||
|
||||
HighlightingMarks::const_iterator HighlightingMarks::begin() const
|
||||
TokenInfos::const_iterator TokenInfos::begin() const
|
||||
{
|
||||
return const_iterator(cxCursor.cbegin(),
|
||||
cxToken,
|
||||
@@ -53,7 +53,7 @@ HighlightingMarks::const_iterator HighlightingMarks::begin() const
|
||||
currentOutputArgumentRanges);
|
||||
}
|
||||
|
||||
HighlightingMarks::const_iterator HighlightingMarks::end() const
|
||||
TokenInfos::const_iterator TokenInfos::end() const
|
||||
{
|
||||
return const_iterator(cxCursor.cend(),
|
||||
cxToken + cxTokenCount,
|
||||
@@ -61,56 +61,56 @@ HighlightingMarks::const_iterator HighlightingMarks::end() const
|
||||
currentOutputArgumentRanges);
|
||||
}
|
||||
|
||||
QVector<HighlightingMarkContainer> HighlightingMarks::toHighlightingMarksContainers() const
|
||||
QVector<TokenInfoContainer> TokenInfos::toTokenInfoContainers() const
|
||||
{
|
||||
QVector<HighlightingMarkContainer> containers;
|
||||
QVector<TokenInfoContainer> containers;
|
||||
containers.reserve(size());
|
||||
|
||||
const auto isValidHighlightMark = [] (const HighlightingMark &highlightMark) {
|
||||
return !highlightMark.hasInvalidMainType()
|
||||
&& !highlightMark.hasMainType(HighlightingType::NumberLiteral)
|
||||
&& !highlightMark.hasMainType(HighlightingType::Comment);
|
||||
const auto isValidTokenInfo = [] (const TokenInfo &tokenInfo) {
|
||||
return !tokenInfo.hasInvalidMainType()
|
||||
&& !tokenInfo.hasMainType(HighlightingType::NumberLiteral)
|
||||
&& !tokenInfo.hasMainType(HighlightingType::Comment);
|
||||
};
|
||||
for (const HighlightingMark &highlightMark : *this)
|
||||
if (isValidHighlightMark(highlightMark))
|
||||
containers.push_back(highlightMark);
|
||||
for (const TokenInfo &tokenInfo : *this)
|
||||
if (isValidTokenInfo(tokenInfo))
|
||||
containers.push_back(tokenInfo);
|
||||
|
||||
return containers;
|
||||
}
|
||||
|
||||
bool HighlightingMarks::currentOutputArgumentRangesAreEmpty() const
|
||||
bool TokenInfos::currentOutputArgumentRangesAreEmpty() const
|
||||
{
|
||||
return currentOutputArgumentRanges.empty();
|
||||
}
|
||||
|
||||
bool HighlightingMarks::isEmpty() const
|
||||
bool TokenInfos::isEmpty() const
|
||||
{
|
||||
return cxTokenCount == 0;
|
||||
}
|
||||
|
||||
bool ClangBackEnd::HighlightingMarks::isNull() const
|
||||
bool ClangBackEnd::TokenInfos::isNull() const
|
||||
{
|
||||
return cxToken == nullptr;
|
||||
}
|
||||
|
||||
uint HighlightingMarks::size() const
|
||||
uint TokenInfos::size() const
|
||||
{
|
||||
return cxTokenCount;
|
||||
}
|
||||
|
||||
HighlightingMark HighlightingMarks::operator[](size_t index) const
|
||||
TokenInfo TokenInfos::operator[](size_t index) const
|
||||
{
|
||||
return HighlightingMark(cxCursor[index],
|
||||
return TokenInfo(cxCursor[index],
|
||||
cxToken + index,
|
||||
cxTranslationUnit,
|
||||
currentOutputArgumentRanges);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const HighlightingMarks &marks)
|
||||
std::ostream &operator<<(std::ostream &out, const TokenInfos &marks)
|
||||
{
|
||||
out << "[";
|
||||
|
||||
for (const HighlightingMark entry : marks)
|
||||
for (const TokenInfo entry : marks)
|
||||
out << entry;
|
||||
|
||||
out << "]";
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "highlightingmarksiterator.h"
|
||||
#include "tokeninfositerator.h"
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
|
||||
@@ -34,29 +34,29 @@
|
||||
namespace ClangBackEnd {
|
||||
|
||||
using uint = unsigned int;
|
||||
class HighlightingMarkContainer;
|
||||
class TokenInfoContainer;
|
||||
|
||||
class HighlightingMarks
|
||||
class TokenInfos
|
||||
{
|
||||
public:
|
||||
using const_iterator = HighlightingMarksIterator;
|
||||
using value_type = HighlightingMark;
|
||||
using const_iterator = TokenInfosIterator;
|
||||
using value_type = TokenInfo;
|
||||
|
||||
public:
|
||||
HighlightingMarks() = default;
|
||||
HighlightingMarks(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount);
|
||||
~HighlightingMarks();
|
||||
TokenInfos() = default;
|
||||
TokenInfos(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount);
|
||||
~TokenInfos();
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isNull() const;
|
||||
uint size() const;
|
||||
|
||||
HighlightingMark operator[](size_t index) const;
|
||||
TokenInfo operator[](size_t index) const;
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
QVector<HighlightingMarkContainer> toHighlightingMarksContainers() const;
|
||||
QVector<TokenInfoContainer> toTokenInfoContainers() const;
|
||||
|
||||
bool currentOutputArgumentRangesAreEmpty() const;
|
||||
|
||||
@@ -69,6 +69,6 @@ private:
|
||||
std::vector<CXCursor> cxCursor;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const HighlightingMarks &marks);
|
||||
std::ostream &operator<<(std::ostream &out, const TokenInfos &marks);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "highlightingmark.h"
|
||||
#include "tokeninfo.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
@@ -39,10 +39,10 @@ using uint = unsigned int;
|
||||
class DiagnosticSet;
|
||||
class Diagnostic;
|
||||
|
||||
class HighlightingMarksIterator : public std::iterator<std::forward_iterator_tag, HighlightingMark, uint>
|
||||
class TokenInfosIterator : public std::iterator<std::forward_iterator_tag, TokenInfo, uint>
|
||||
{
|
||||
public:
|
||||
HighlightingMarksIterator(std::vector<CXCursor>::const_iterator cxCursorIterator,
|
||||
TokenInfosIterator(std::vector<CXCursor>::const_iterator cxCursorIterator,
|
||||
CXToken *cxToken,
|
||||
CXTranslationUnit cxTranslationUnit,
|
||||
std::vector<CXSourceRange> ¤tOutputArgumentRanges)
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
currentOutputArgumentRanges(currentOutputArgumentRanges)
|
||||
{}
|
||||
|
||||
HighlightingMarksIterator& operator++()
|
||||
TokenInfosIterator& operator++()
|
||||
{
|
||||
++cxCursorIterator;
|
||||
++cxToken;
|
||||
@@ -60,27 +60,27 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
HighlightingMarksIterator operator++(int)
|
||||
TokenInfosIterator operator++(int)
|
||||
{
|
||||
return HighlightingMarksIterator(cxCursorIterator++,
|
||||
return TokenInfosIterator(cxCursorIterator++,
|
||||
cxToken++,
|
||||
cxTranslationUnit,
|
||||
currentOutputArgumentRanges);
|
||||
}
|
||||
|
||||
bool operator==(HighlightingMarksIterator other) const
|
||||
bool operator==(TokenInfosIterator other) const
|
||||
{
|
||||
return cxCursorIterator == other.cxCursorIterator;
|
||||
}
|
||||
|
||||
bool operator!=(HighlightingMarksIterator other) const
|
||||
bool operator!=(TokenInfosIterator other) const
|
||||
{
|
||||
return cxCursorIterator != other.cxCursorIterator;
|
||||
}
|
||||
|
||||
HighlightingMark operator*()
|
||||
TokenInfo operator*()
|
||||
{
|
||||
return HighlightingMark(*cxCursorIterator,
|
||||
return TokenInfo(*cxCursorIterator,
|
||||
cxToken,
|
||||
cxTranslationUnit,
|
||||
currentOutputArgumentRanges);
|
||||
Reference in New Issue
Block a user