diff --git a/src/libs/clangbackendipc/highlightingmarkcontainer.h b/src/libs/clangbackendipc/highlightingmarkcontainer.h index b4a89dd1fe1..97cc402f921 100644 --- a/src/libs/clangbackendipc/highlightingmarkcontainer.h +++ b/src/libs/clangbackendipc/highlightingmarkcontainer.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef CLANGBACKEND_HIGHLIGHTINGMARKCONTAINER_H -#define CLANGBACKEND_HIGHLIGHTINGMARKCONTAINER_H +#pragma once #include "clangbackendipc_global.h" @@ -63,5 +62,3 @@ CMBIPC_EXPORT void PrintTo(HighlightingType highlightingType, ::std::ostream *os void PrintTo(const HighlightingMarkContainer &container, ::std::ostream *os); } // namespace ClangBackEnd - -#endif // CLANGBACKEND_HIGHLIGHTINGMARKCONTAINER_H diff --git a/src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri b/src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri index 344a0372076..e9ad8d3f794 100644 --- a/src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri +++ b/src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri @@ -27,12 +27,12 @@ HEADERS += $$PWD/clangipcserver.h \ $$PWD/translationunitalreadyexistsexception.h \ $$PWD/commandlinearguments.h \ $$PWD/cursor.h \ - $$PWD/highlightinginformations.h \ - $$PWD/highlightinginformation.h \ - $$PWD/highlightinginformationsiterator.h \ $$PWD/skippedsourceranges.h \ $$PWD/clangtranslationunit.h \ - $$PWD/clangtype.h + $$PWD/clangtype.h \ + $$PWD/highlightingmark.h \ + $$PWD/highlightingmarks.h \ + $$PWD/highlightingmarksiterator.h SOURCES += $$PWD/clangipcserver.cpp \ $$PWD/codecompleter.cpp \ @@ -60,8 +60,8 @@ SOURCES += $$PWD/clangipcserver.cpp \ $$PWD/translationunitalreadyexistsexception.cpp \ $$PWD/commandlinearguments.cpp \ $$PWD/cursor.cpp \ - $$PWD/highlightinginformations.cpp \ - $$PWD/highlightinginformation.cpp \ $$PWD/skippedsourceranges.cpp \ $$PWD/clangtranslationunit.cpp \ - $$PWD/clangtype.cpp + $$PWD/clangtype.cpp \ + $$PWD/highlightingmark.cpp \ + $$PWD/highlightingmarks.cpp diff --git a/src/tools/clangbackend/ipcsource/clangipcserver.cpp b/src/tools/clangbackend/ipcsource/clangipcserver.cpp index 301633c6584..d5a4ef6edf9 100644 --- a/src/tools/clangbackend/ipcsource/clangipcserver.cpp +++ b/src/tools/clangbackend/ipcsource/clangipcserver.cpp @@ -28,7 +28,7 @@ #include "clangfilesystemwatcher.h" #include "codecompleter.h" #include "diagnosticset.h" -#include "highlightinginformations.h" +#include "highlightingmarks.h" #include "projectpartsdonotexistexception.h" #include "skippedsourceranges.h" #include "translationunitdoesnotexistexception.h" @@ -288,7 +288,7 @@ void ClangIpcServer::requestHighlighting(const RequestHighlightingMessage &messa message.fileContainer().projectPartId()); client()->highlightingChanged(HighlightingChangedMessage(translationUnit.fileContainer(), - translationUnit.highlightingInformations().toHighlightingMarksContainers(), + translationUnit.highlightingMarks().toHighlightingMarksContainers(), translationUnit.skippedSourceRanges().toSourceRangeContainers())); } catch (const TranslationUnitDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); diff --git a/src/tools/clangbackend/ipcsource/clangtranslationunit.cpp b/src/tools/clangbackend/ipcsource/clangtranslationunit.cpp index 38315719d1c..8682a3e9a39 100644 --- a/src/tools/clangbackend/ipcsource/clangtranslationunit.cpp +++ b/src/tools/clangbackend/ipcsource/clangtranslationunit.cpp @@ -35,7 +35,7 @@ #include "skippedsourceranges.h" #include "sourcelocation.h" #include "sourcerange.h" -#include "highlightinginformations.h" +#include "highlightingmarks.h" #include "translationunitfilenotexitexception.h" #include "translationunitisnullexception.h" #include "translationunitparseerrorexception.h" @@ -80,7 +80,7 @@ public: uint documentRevision = 0; bool needsToBeReparsed = false; bool hasNewDiagnostics = true; - bool hasNewHighlightingInformations = true; + bool hasNewHighlightingMarks = true; bool isUsedByCurrentEditor = false; bool isVisibleInEditor = false; }; @@ -247,9 +247,9 @@ bool TranslationUnit::hasNewDiagnostics() const return d->hasNewDiagnostics; } -bool TranslationUnit::hasNewHighlightingInformations() const +bool TranslationUnit::hasNewHighlightingMarks() const { - return d->hasNewHighlightingInformations; + return d->hasNewHighlightingMarks; } DiagnosticSet TranslationUnit::diagnostics() const @@ -319,14 +319,14 @@ Cursor TranslationUnit::cursor() const return clang_getTranslationUnitCursor(cxTranslationUnit()); } -HighlightingInformations TranslationUnit::highlightingInformations() const +HighlightingMarks TranslationUnit::highlightingMarks() const { - d->hasNewHighlightingInformations = false; + d->hasNewHighlightingMarks = false; - return highlightingInformationsInRange(cursor().sourceRange()); + return highlightingMarksInRange(cursor().sourceRange()); } -HighlightingInformations TranslationUnit::highlightingInformationsInRange(const SourceRange &range) const +HighlightingMarks TranslationUnit::highlightingMarksInRange(const SourceRange &range) const { CXToken *cxTokens = 0; uint cxTokensCount = 0; @@ -334,7 +334,7 @@ HighlightingInformations TranslationUnit::highlightingInformationsInRange(const clang_tokenize(translationUnit, range, &cxTokens, &cxTokensCount); - return HighlightingInformations(translationUnit, cxTokens, cxTokensCount); + return HighlightingMarks(translationUnit, cxTokens, cxTokensCount); } SkippedSourceRanges TranslationUnit::skippedSourceRanges() const @@ -376,7 +376,7 @@ void TranslationUnit::setDirty() { d->needsToBeReparsed = true; d->hasNewDiagnostics = true; - d->hasNewHighlightingInformations = true; + d->hasNewHighlightingMarks = true; } bool TranslationUnit::isMainFileAndExistsOrIsOtherFile(const Utf8String &filePath) const diff --git a/src/tools/clangbackend/ipcsource/clangtranslationunit.h b/src/tools/clangbackend/ipcsource/clangtranslationunit.h index 467c9346523..6943664aaee 100644 --- a/src/tools/clangbackend/ipcsource/clangtranslationunit.h +++ b/src/tools/clangbackend/ipcsource/clangtranslationunit.h @@ -48,7 +48,7 @@ class ProjectPart; class DiagnosticContainer; class DiagnosticSet; class FileContainer; -class HighlightingInformations; +class HighlightingMarks; class TranslationUnits; class CommandLineArguments; class Cursor; @@ -112,7 +112,7 @@ public: bool isNeedingReparse() const; bool hasNewDiagnostics() const; - bool hasNewHighlightingInformations() const; + bool hasNewHighlightingMarks() const; DiagnosticSet diagnostics() const; QVector mainFileDiagnostics() const; @@ -134,8 +134,8 @@ public: Cursor cursorAt(const Utf8String &filePath, uint line, uint column) const; Cursor cursor() const; - HighlightingInformations highlightingInformations() const; - HighlightingInformations highlightingInformationsInRange(const SourceRange &range) const; + HighlightingMarks highlightingMarks() const; + HighlightingMarks highlightingMarksInRange(const SourceRange &range) const; SkippedSourceRanges skippedSourceRanges() const; diff --git a/src/tools/clangbackend/ipcsource/highlightinginformation.cpp b/src/tools/clangbackend/ipcsource/highlightingmark.cpp similarity index 87% rename from src/tools/clangbackend/ipcsource/highlightinginformation.cpp rename to src/tools/clangbackend/ipcsource/highlightingmark.cpp index 9fe288319f2..46568cc5555 100644 --- a/src/tools/clangbackend/ipcsource/highlightinginformation.cpp +++ b/src/tools/clangbackend/ipcsource/highlightingmark.cpp @@ -27,7 +27,7 @@ #include "clangstring.h" #include "cursor.h" -#include "highlightinginformation.h" +#include "highlightingmark.h" #include "sourcelocation.h" #include "sourcerange.h" @@ -38,7 +38,7 @@ namespace ClangBackEnd { -HighlightingInformation::HighlightingInformation(const CXCursor &cxCursor, +HighlightingMark::HighlightingMark(const CXCursor &cxCursor, CXToken *cxToken, CXTranslationUnit cxTranslationUnit) { @@ -53,7 +53,7 @@ HighlightingInformation::HighlightingInformation(const CXCursor &cxCursor, type = kind(cxToken, originalCursor); } -HighlightingInformation::HighlightingInformation(uint line, uint column, uint length, HighlightingType type) +HighlightingMark::HighlightingMark(uint line, uint column, uint length, HighlightingType type) : line(line), column(column), length(length), @@ -61,24 +61,24 @@ HighlightingInformation::HighlightingInformation(uint line, uint column, uint le { } -bool HighlightingInformation::hasType(HighlightingType type) const +bool HighlightingMark::hasType(HighlightingType type) const { return this->type == type; } -bool HighlightingInformation::hasFunctionArguments() const +bool HighlightingMark::hasFunctionArguments() const { return originalCursor.argumentCount() > 0; } -QVector HighlightingInformation::outputFunctionArguments() const +QVector HighlightingMark::outputFunctionArguments() const { - QVector outputFunctionArguments; + QVector outputFunctionArguments; return outputFunctionArguments; } -HighlightingInformation::operator HighlightingMarkContainer() const +HighlightingMark::operator HighlightingMarkContainer() const { return HighlightingMarkContainer(line, column, length, type); } @@ -104,7 +104,7 @@ bool isFunctionInFinalClass(const Cursor &cursor) } } -HighlightingType HighlightingInformation::memberReferenceKind(const Cursor &cursor) const +HighlightingType HighlightingMark::memberReferenceKind(const Cursor &cursor) const { if (cursor.isDynamicCall()) { if (isFinalFunction(cursor) || isFunctionInFinalClass(cursor)) @@ -117,7 +117,7 @@ HighlightingType HighlightingInformation::memberReferenceKind(const Cursor &curs } -HighlightingType HighlightingInformation::referencedTypeKind(const Cursor &cursor) const +HighlightingType HighlightingMark::referencedTypeKind(const Cursor &cursor) const { const Cursor referencedCursor = cursor.referenced(); @@ -135,7 +135,7 @@ HighlightingType HighlightingInformation::referencedTypeKind(const Cursor &curso Q_UNREACHABLE(); } -HighlightingType HighlightingInformation::variableKind(const Cursor &cursor) const +HighlightingType HighlightingMark::variableKind(const Cursor &cursor) const { if (cursor.isLocalVariable()) return HighlightingType::LocalVariable; @@ -143,7 +143,7 @@ HighlightingType HighlightingInformation::variableKind(const Cursor &cursor) con return HighlightingType::GlobalVariable; } -bool HighlightingInformation::isVirtualMethodDeclarationOrDefinition(const Cursor &cursor) const +bool HighlightingMark::isVirtualMethodDeclarationOrDefinition(const Cursor &cursor) const { return cursor.isVirtualMethod() && (originalCursor.isDeclaration() || originalCursor.isDefinition()); @@ -155,13 +155,13 @@ bool isNotFinalFunction(const Cursor &cursor) } } -bool HighlightingInformation::isRealDynamicCall(const Cursor &cursor) const +bool HighlightingMark::isRealDynamicCall(const Cursor &cursor) const { return originalCursor.isDynamicCall() && isNotFinalFunction(cursor); } -HighlightingType HighlightingInformation::functionKind(const Cursor &cursor) const +HighlightingType HighlightingMark::functionKind(const Cursor &cursor) const { if (isRealDynamicCall(cursor) || isVirtualMethodDeclarationOrDefinition(cursor)) return HighlightingType::VirtualFunction; @@ -169,7 +169,7 @@ HighlightingType HighlightingInformation::functionKind(const Cursor &cursor) con return HighlightingType::Function; } -HighlightingType HighlightingInformation::identifierKind(const Cursor &cursor) const +HighlightingType HighlightingMark::identifierKind(const Cursor &cursor) const { switch (cursor.kind()) { case CXCursor_Destructor: @@ -268,7 +268,7 @@ HighlightingType punctationKind(const Cursor &cursor) } } -HighlightingType HighlightingInformation::kind(CXToken *cxToken, const Cursor &cursor) const +HighlightingType HighlightingMark::kind(CXToken *cxToken, const Cursor &cursor) const { auto cxTokenKind = clang_getTokenKind(*cxToken); @@ -283,7 +283,7 @@ HighlightingType HighlightingInformation::kind(CXToken *cxToken, const Cursor &c Q_UNREACHABLE(); } -void PrintTo(const HighlightingInformation &information, ::std::ostream *os) +void PrintTo(const HighlightingMark &information, ::std::ostream *os) { *os << "type: "; PrintTo(information.type, os); diff --git a/src/tools/clangbackend/ipcsource/highlightinginformation.h b/src/tools/clangbackend/ipcsource/highlightingmark.h similarity index 73% rename from src/tools/clangbackend/ipcsource/highlightinginformation.h rename to src/tools/clangbackend/ipcsource/highlightingmark.h index d943b8b54a2..aad9351b5b0 100644 --- a/src/tools/clangbackend/ipcsource/highlightinginformation.h +++ b/src/tools/clangbackend/ipcsource/highlightingmark.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef CLANGBACKEND_HIGHLIGHTINGINFORMATION_H -#define CLANGBACKEND_HIGHLIGHTINGINFORMATION_H +#pragma once #include #include @@ -35,18 +34,18 @@ namespace ClangBackEnd { -class HighlightingInformation +class HighlightingMark { - friend bool operator==(const HighlightingInformation &first, const HighlightingInformation &second); - friend void PrintTo(const HighlightingInformation& highlightingInformation, ::std::ostream *os); + friend bool operator==(const HighlightingMark &first, const HighlightingMark &second); + friend void PrintTo(const HighlightingMark& highlightingMark, ::std::ostream *os); public: - HighlightingInformation(const CXCursor &cxCursor, CXToken *cxToken, CXTranslationUnit cxTranslationUnit); - HighlightingInformation(uint line, uint column, uint length, HighlightingType type); + HighlightingMark(const CXCursor &cxCursor, CXToken *cxToken, CXTranslationUnit cxTranslationUnit); + HighlightingMark(uint line, uint column, uint length, HighlightingType type); bool hasType(HighlightingType type) const; bool hasFunctionArguments() const; - QVector outputFunctionArguments() const; + QVector outputFunctionArguments() const; operator HighlightingMarkContainer() const; @@ -68,9 +67,9 @@ private: HighlightingType type; }; -void PrintTo(const HighlightingInformation& highlightingInformation, ::std::ostream *os); +void PrintTo(const HighlightingMark& highlightingMark, ::std::ostream *os); -inline bool operator==(const HighlightingInformation &first, const HighlightingInformation &second) +inline bool operator==(const HighlightingMark &first, const HighlightingMark &second) { return first.line == second.line && first.column == second.column @@ -79,5 +78,3 @@ inline bool operator==(const HighlightingInformation &first, const HighlightingI } } // namespace ClangBackEnd - -#endif // CLANGBACKEND_HIGHLIGHTINGINFORMATION_H diff --git a/src/tools/clangbackend/ipcsource/highlightinginformations.cpp b/src/tools/clangbackend/ipcsource/highlightingmarks.cpp similarity index 70% rename from src/tools/clangbackend/ipcsource/highlightinginformations.cpp rename to src/tools/clangbackend/ipcsource/highlightingmarks.cpp index 6878b3aee2d..00aac0e3b6a 100644 --- a/src/tools/clangbackend/ipcsource/highlightinginformations.cpp +++ b/src/tools/clangbackend/ipcsource/highlightingmarks.cpp @@ -23,7 +23,7 @@ ** ****************************************************************************/ -#include "highlightinginformations.h" +#include "highlightingmarks.h" #include "highlightingmarkcontainer.h" @@ -31,7 +31,7 @@ namespace ClangBackEnd { -HighlightingInformations::HighlightingInformations(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount) +HighlightingMarks::HighlightingMarks(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount) : cxTranslationUnit(cxTranslationUnit), cxToken(tokens), cxTokenCount(tokensCount) @@ -40,27 +40,27 @@ HighlightingInformations::HighlightingInformations(CXTranslationUnit cxTranslati clang_annotateTokens(cxTranslationUnit, cxToken, cxTokenCount, cxCursor.data()); } -HighlightingInformations::~HighlightingInformations() +HighlightingMarks::~HighlightingMarks() { clang_disposeTokens(cxTranslationUnit, cxToken, cxTokenCount); } -HighlightingInformations::const_iterator HighlightingInformations::begin() const +HighlightingMarks::const_iterator HighlightingMarks::begin() const { return const_iterator(cxCursor.cbegin(), cxToken, cxTranslationUnit); } -HighlightingInformations::const_iterator HighlightingInformations::end() const +HighlightingMarks::const_iterator HighlightingMarks::end() const { return const_iterator(cxCursor.cend(), cxToken + cxTokenCount, cxTranslationUnit); } -QVector HighlightingInformations::toHighlightingMarksContainers() const +QVector HighlightingMarks::toHighlightingMarksContainers() const { QVector containers; containers.reserve(size()); - const auto isValidHighlightMark = [] (const HighlightingInformation &highlightMark) { + const auto isValidHighlightMark = [] (const HighlightingMark &highlightMark) { return !highlightMark.hasType(HighlightingType::Invalid); }; @@ -69,24 +69,24 @@ QVector HighlightingInformations::toHighlightingMarks return containers; } -bool HighlightingInformations::isEmpty() const +bool HighlightingMarks::isEmpty() const { return cxTokenCount == 0; } -bool ClangBackEnd::HighlightingInformations::isNull() const +bool ClangBackEnd::HighlightingMarks::isNull() const { return cxToken == nullptr; } -uint HighlightingInformations::size() const +uint HighlightingMarks::size() const { return cxTokenCount; } -HighlightingInformation HighlightingInformations::operator[](size_t index) const +HighlightingMark HighlightingMarks::operator[](size_t index) const { - return HighlightingInformation(cxCursor[index], cxToken + index, cxTranslationUnit); + return HighlightingMark(cxCursor[index], cxToken + index, cxTranslationUnit); } } // namespace ClangBackEnd diff --git a/src/tools/clangbackend/ipcsource/highlightinginformations.h b/src/tools/clangbackend/ipcsource/highlightingmarks.h similarity index 75% rename from src/tools/clangbackend/ipcsource/highlightinginformations.h rename to src/tools/clangbackend/ipcsource/highlightingmarks.h index 952a8ab3de2..2d77bb86c53 100644 --- a/src/tools/clangbackend/ipcsource/highlightinginformations.h +++ b/src/tools/clangbackend/ipcsource/highlightingmarks.h @@ -23,10 +23,9 @@ ** ****************************************************************************/ -#ifndef CLANGBACKEND_HIGHLIGHTINGINFORMATIONS_H -#define CLANGBACKEND_HIGHLIGHTINGINFORMATIONS_H +#pragma once -#include "highlightinginformationsiterator.h" +#include "highlightingmarksiterator.h" #include @@ -37,22 +36,22 @@ namespace ClangBackEnd { using uint = unsigned int; class HighlightingMarkContainer; -class HighlightingInformations +class HighlightingMarks { public: - using const_iterator = HighlightingInformationsIterator; - using value_type = HighlightingInformation; + using const_iterator = HighlightingMarksIterator; + using value_type = HighlightingMark; public: - HighlightingInformations() = default; - HighlightingInformations(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount); - ~HighlightingInformations(); + HighlightingMarks() = default; + HighlightingMarks(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount); + ~HighlightingMarks(); bool isEmpty() const; bool isNull() const; uint size() const; - HighlightingInformation operator[](size_t index) const; + HighlightingMark operator[](size_t index) const; const_iterator begin() const; const_iterator end() const; @@ -68,5 +67,3 @@ private: }; } // namespace ClangBackEnd - -#endif // CLANGBACKEND_HIGHLIGHTINGINFORMATIONS_H diff --git a/src/tools/clangbackend/ipcsource/highlightinginformationsiterator.h b/src/tools/clangbackend/ipcsource/highlightingmarksiterator.h similarity index 70% rename from src/tools/clangbackend/ipcsource/highlightinginformationsiterator.h rename to src/tools/clangbackend/ipcsource/highlightingmarksiterator.h index 2979f30895c..9cbfcabaad6 100644 --- a/src/tools/clangbackend/ipcsource/highlightinginformationsiterator.h +++ b/src/tools/clangbackend/ipcsource/highlightingmarksiterator.h @@ -23,10 +23,9 @@ ** ****************************************************************************/ -#ifndef HIGHLIGHTINGINFORMATIONSITERATOR_H -#define HIGHLIGHTINGINFORMATIONSITERATOR_H +#pragma once -#include "highlightinginformation.h" +#include "highlightingmark.h" #include #include @@ -40,10 +39,10 @@ using uint = unsigned int; class DiagnosticSet; class Diagnostic; -class HighlightingInformationsIterator : public std::iterator +class HighlightingMarksIterator : public std::iterator { public: - HighlightingInformationsIterator(std::vector::const_iterator cxCursorIterator, + HighlightingMarksIterator(std::vector::const_iterator cxCursorIterator, CXToken *cxToken, CXTranslationUnit cxTranslationUnit) : cxCursorIterator(cxCursorIterator), @@ -51,7 +50,7 @@ public: cxTranslationUnit(cxTranslationUnit) {} - HighlightingInformationsIterator& operator++() + HighlightingMarksIterator& operator++() { ++cxCursorIterator; ++cxToken; @@ -59,24 +58,24 @@ public: return *this; } - HighlightingInformationsIterator operator++(int) + HighlightingMarksIterator operator++(int) { - return HighlightingInformationsIterator(cxCursorIterator++, cxToken++, cxTranslationUnit); + return HighlightingMarksIterator(cxCursorIterator++, cxToken++, cxTranslationUnit); } - bool operator==(HighlightingInformationsIterator other) const + bool operator==(HighlightingMarksIterator other) const { return cxCursorIterator == other.cxCursorIterator; } - bool operator!=(HighlightingInformationsIterator other) const + bool operator!=(HighlightingMarksIterator other) const { return cxCursorIterator != other.cxCursorIterator; } - HighlightingInformation operator*() + HighlightingMark operator*() { - return HighlightingInformation(*cxCursorIterator, cxToken, cxTranslationUnit); + return HighlightingMark(*cxCursorIterator, cxToken, cxTranslationUnit); } private: @@ -86,5 +85,3 @@ private: }; } // namespace ClangBackEnd - -#endif // HIGHLIGHTINGINFORMATIONSITERATOR_H diff --git a/src/tools/clangbackend/ipcsource/sourcerange.h b/src/tools/clangbackend/ipcsource/sourcerange.h index a2f65d178bd..9fe25aa94ae 100644 --- a/src/tools/clangbackend/ipcsource/sourcerange.h +++ b/src/tools/clangbackend/ipcsource/sourcerange.h @@ -37,7 +37,6 @@ class SourceRange friend class Diagnostic; friend class FixIt; friend class Cursor; - friend class HighlightingInformation; friend bool operator==(const SourceRange &first, const SourceRange &second); public: diff --git a/src/tools/clangbackend/ipcsource/translationunits.cpp b/src/tools/clangbackend/ipcsource/translationunits.cpp index 5b118a96529..c6027fa75d3 100644 --- a/src/tools/clangbackend/ipcsource/translationunits.cpp +++ b/src/tools/clangbackend/ipcsource/translationunits.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -199,7 +199,7 @@ namespace { bool translationUnitHasNewDocumentAnnotations(const TranslationUnit &translationUnit) { - return translationUnit.hasNewDiagnostics() || translationUnit.hasNewHighlightingInformations(); + return translationUnit.hasNewDiagnostics() || translationUnit.hasNewHighlightingMarks(); } } @@ -365,7 +365,7 @@ void TranslationUnits::sendDocumentAnnotations(const TranslationUnit &translatio DiagnosticsChangedMessage diagnosticsMessage(fileContainer, translationUnit.mainFileDiagnostics()); HighlightingChangedMessage highlightingsMessage(fileContainer, - translationUnit.highlightingInformations().toHighlightingMarksContainers(), + translationUnit.highlightingMarks().toHighlightingMarksContainers(), translationUnit.skippedSourceRanges().toSourceRangeContainers()); sendDocumentAnnotationsCallback(std::move(diagnosticsMessage), diff --git a/tests/unit/unittest/data/highlightinginformations.cpp b/tests/unit/unittest/data/highlightingmarks.cpp similarity index 98% rename from tests/unit/unittest/data/highlightinginformations.cpp rename to tests/unit/unittest/data/highlightingmarks.cpp index e6121d1c9c2..0fb2ea3bebc 100644 --- a/tests/unit/unittest/data/highlightinginformations.cpp +++ b/tests/unit/unittest/data/highlightingmarks.cpp @@ -236,7 +236,7 @@ void f11() MacroDefinition(2, 4); } -#include "highlightinginformations.h" +#include "highlightingmarks.h" void f12() { GOTO_LABEL: @@ -286,7 +286,7 @@ void f12() OutputParameter(One, 2); } -#include +#include #define FOREACH(variable, container) \ variable; \ diff --git a/tests/unit/unittest/data/highlightinginformations.h b/tests/unit/unittest/data/highlightingmarks.h similarity index 100% rename from tests/unit/unittest/data/highlightinginformations.h rename to tests/unit/unittest/data/highlightingmarks.h diff --git a/tests/unit/unittest/highlightinginformationstest.cpp b/tests/unit/unittest/highlightinginformationstest.cpp deleted file mode 100644 index 379319ec1d3..00000000000 --- a/tests/unit/unittest/highlightinginformationstest.cpp +++ /dev/null @@ -1,1018 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 -** 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. -** -** 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. -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "gtest-qt-printing.h" - -using ClangBackEnd::Cursor; -using ClangBackEnd::HighlightingInformation; -using ClangBackEnd::HighlightingInformations; -using ClangBackEnd::HighlightingType; -using ClangBackEnd::TranslationUnit; -using ClangBackEnd::UnsavedFiles; -using ClangBackEnd::ProjectPart; -using ClangBackEnd::TranslationUnits; -using ClangBackEnd::ClangString; -using ClangBackEnd::SourceRange; - -using testing::PrintToString; -using testing::IsNull; -using testing::NotNull; -using testing::Gt; -using testing::Contains; -using testing::EndsWith; -using testing::AllOf; -using testing::Not; -using testing::IsEmpty; -using testing::SizeIs; - -namespace { - -MATCHER_P4(IsHighlightingInformation, line, column, length, type, - std::string(negation ? "isn't " : "is ") - + PrintToString(HighlightingInformation(line, column, length, type)) - ) -{ - const HighlightingInformation expected(line, column, length, type); - - return arg == expected; -} - -MATCHER_P(HasType, type, - std::string(negation ? "isn't " : "is ") - + PrintToString(type) - ) -{ - return arg.hasType(type); -} - -struct Data { - ClangBackEnd::ProjectParts projects; - ClangBackEnd::UnsavedFiles unsavedFiles; - ClangBackEnd::TranslationUnits translationUnits{projects, unsavedFiles}; - TranslationUnit translationUnit{Utf8StringLiteral(TESTDATA_DIR"/highlightinginformations.cpp"), - ProjectPart(Utf8StringLiteral("projectPartId"), {Utf8StringLiteral("-std=c++14")}), - {}, - translationUnits}; -}; - -class HighlightingInformations : public ::testing::Test -{ -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - - SourceRange sourceRange(uint line, uint columnEnd) const; - -protected: - static Data *d; - const TranslationUnit &translationUnit = d->translationUnit; -}; - -TEST_F(HighlightingInformations, CreateNullInformations) -{ - ::HighlightingInformations infos; - - ASSERT_TRUE(infos.isNull()); -} - -TEST_F(HighlightingInformations, NullInformationsAreEmpty) -{ - ::HighlightingInformations infos; - - ASSERT_TRUE(infos.isEmpty()); -} - -TEST_F(HighlightingInformations, IsNotNull) -{ - const auto aRange = translationUnit.sourceRange(3, 1, 5, 1); - - const auto infos = translationUnit.highlightingInformationsInRange(aRange); - - ASSERT_FALSE(infos.isNull()); -} - -TEST_F(HighlightingInformations, IteratorBeginEnd) -{ - const auto aRange = translationUnit.sourceRange(3, 1, 5, 1); - const auto infos = translationUnit.highlightingInformationsInRange(aRange); - - const auto endIterator = std::next(infos.begin(), infos.size()); - - ASSERT_THAT(infos.end(), endIterator); -} - -TEST_F(HighlightingInformations, ForFullTranslationUnitRange) -{ - const auto infos = translationUnit.highlightingInformations(); - - ASSERT_THAT(infos, AllOf(Contains(IsHighlightingInformation(1u, 1u, 4u, HighlightingType::Keyword)), - Contains(IsHighlightingInformation(277u, 5u, 15u, HighlightingType::Function)))); -} - -TEST_F(HighlightingInformations, Size) -{ - const auto range = translationUnit.sourceRange(5, 5, 5, 10); - - const auto infos = translationUnit.highlightingInformationsInRange(range); - - ASSERT_THAT(infos.size(), 1); -} - -TEST_F(HighlightingInformations, DISABLED_Keyword) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(5, 12)); - - ASSERT_THAT(infos[0], IsHighlightingInformation(5u, 5u, 6u, HighlightingType::Keyword)); -} - -TEST_F(HighlightingInformations, StringLiteral) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(1, 29)); - - ASSERT_THAT(infos[4], IsHighlightingInformation(1u, 24u, 10u, HighlightingType::StringLiteral)); -} - -TEST_F(HighlightingInformations, Utf8StringLiteral) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(2, 33)); - - ASSERT_THAT(infos[4], IsHighlightingInformation(2u, 24u, 12u, HighlightingType::StringLiteral)); -} - -TEST_F(HighlightingInformations, RawStringLiteral) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(3, 34)); - - ASSERT_THAT(infos[4], IsHighlightingInformation(3u, 24u, 13u, HighlightingType::StringLiteral)); -} - -TEST_F(HighlightingInformations, CharacterLiteral) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(4, 28)); - - ASSERT_THAT(infos[3], IsHighlightingInformation(4u, 24u, 3u, HighlightingType::StringLiteral)); -} - -TEST_F(HighlightingInformations, IntegerLiteral) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(23, 26)); - - ASSERT_THAT(infos[3], IsHighlightingInformation(23u, 24u, 1u, HighlightingType::NumberLiteral)); -} - -TEST_F(HighlightingInformations, FloatLiteral) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(24, 29)); - - ASSERT_THAT(infos[3], IsHighlightingInformation(24u, 24u, 4u, HighlightingType::NumberLiteral)); -} - -TEST_F(HighlightingInformations, FunctionDefinition) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(45, 20)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(45u, 5u, 8u, HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, MemberFunctionDefinition) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(52, 29)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(52u, 10u, 14u, HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, FunctionDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(55, 32)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(55u, 5u, 19u, HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, MemberFunctionDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(59, 27)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(59u, 10u, 14u, HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, MemberFunctionReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(104, 35)); - - ASSERT_THAT(infos[0], IsHighlightingInformation(104u, 9u, 23u, HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, FunctionCall) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(64, 16)); - - ASSERT_THAT(infos[0], IsHighlightingInformation(64u, 5u, 8u, HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, TypeConversionFunction) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(68, 20)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(68u, 14u, 3u, HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, InbuiltTypeConversionFunction) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(69, 20)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(69u, 14u, 3u, HighlightingType::Keyword)); -} - -TEST_F(HighlightingInformations, TypeReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(74, 13)); - - ASSERT_THAT(infos[0], IsHighlightingInformation(74u, 5u, 3u, HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, LocalVariable) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(79, 13)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(79u, 9u, 3u, HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, LocalVariableDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(79, 13)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(79u, 9u, 3u, HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, LocalVariableReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(81, 26)); - - ASSERT_THAT(infos[0], IsHighlightingInformation(81u, 5u, 3u, HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, LocalVariableFunctionArgumentDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(84, 45)); - - ASSERT_THAT(infos[5], IsHighlightingInformation(84u, 41u, 3u, HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, LocalVariableFunctionArgumentReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(86, 26)); - - ASSERT_THAT(infos[0], IsHighlightingInformation(86u, 5u, 3u, HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, ClassVariableDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(90, 21)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(90u, 9u, 11u, HighlightingType::Field)); -} - -TEST_F(HighlightingInformations, ClassVariableReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(94, 23)); - - ASSERT_THAT(infos[0], IsHighlightingInformation(94u, 9u, 11u, HighlightingType::Field)); -} - -TEST_F(HighlightingInformations, StaticMethodDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(110, 25)); - - ASSERT_THAT(infos[1], IsHighlightingInformation(110u, 10u, 12u, HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, StaticMethodReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(114, 30)); - - ASSERT_THAT(infos[2], IsHighlightingInformation(114u, 15u, 12u, HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, Enumeration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(118, 17)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, Enumerator) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(120, 15)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Enumeration)); -} - -TEST_F(HighlightingInformations, EnumerationReferenceDeclarationType) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(125, 28)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, EnumerationReferenceDeclarationVariable) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(125, 28)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, EnumerationReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(127, 30)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, EnumeratorReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(127, 30)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Enumeration)); -} - -TEST_F(HighlightingInformations, ClassForwardDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(130, 12)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, ConstructorDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(134, 13)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, DestructorDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(135, 15)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, ClassForwardDeclarationReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(138, 23)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, ClassTypeReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(140, 32)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, ConstructorReferenceVariable) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(140, 32)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, UnionDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(145, 12)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, UnionDeclarationReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(150, 33)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, GlobalVariable) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(150, 33)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::GlobalVariable)); -} - -TEST_F(HighlightingInformations, StructDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(50, 11)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, NameSpace) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(160, 22)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, NameSpaceAlias) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(164, 38)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, UsingStructInNameSpace) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(165, 36)); - - ASSERT_THAT(infos[3], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, NameSpaceReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(166, 35)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, StructInNameSpaceReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(166, 35)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, VirtualFunction) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(170, 35)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::VirtualFunction)); -} - -TEST_F(HighlightingInformations, DISABLED_NonVirtualFunctionCall) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(177, 46)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, DISABLED_NonVirtualFunctionCallPointer) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(180, 54)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, VirtualFunctionCallPointer) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(192, 51)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::VirtualFunction)); -} - -TEST_F(HighlightingInformations, FinalVirtualFunctionCallPointer) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(202, 61)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, NonFinalVirtualFunctionCallPointer) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(207, 61)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::VirtualFunction)); -} - -TEST_F(HighlightingInformations, PlusOperator) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(224, 49)); - - ASSERT_THAT(infos[6], HasType(HighlightingType::Operator)); -} - -TEST_F(HighlightingInformations, PlusAssignOperator) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(226, 24)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Operator)); -} - -TEST_F(HighlightingInformations, Comment) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(229, 14)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Comment)); -} - -TEST_F(HighlightingInformations, PreprocessingDirective) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(231, 37)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Preprocessor)); -} - -TEST_F(HighlightingInformations, PreprocessorMacroDefinition) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(231, 37)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::PreprocessorDefinition)); -} - -TEST_F(HighlightingInformations, PreprocessorFunctionMacroDefinition) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(232, 47)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::PreprocessorDefinition)); -} - -TEST_F(HighlightingInformations, PreprocessorMacroExpansion) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(236, 27)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::PreprocessorExpansion)); -} - -TEST_F(HighlightingInformations, PreprocessorMacroExpansionArgument) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(236, 27)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::NumberLiteral)); -} - -TEST_F(HighlightingInformations, PreprocessorInclusionDirective) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(239, 18)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::StringLiteral)); -} - -TEST_F(HighlightingInformations, GotoLabelStatement) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(242, 12)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Label)); -} - -TEST_F(HighlightingInformations, GotoLabelStatementReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(244, 21)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Label)); -} - -TEST_F(HighlightingInformations, TemplateReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(254, 25)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, TemplateTypeParameter) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(265, 135)); - - ASSERT_THAT(infos[3], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplateDefaultParameter) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(265, 135)); - - ASSERT_THAT(infos[5], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, NonTypeTemplateParameter) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(265, 135)); - - ASSERT_THAT(infos[8], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, NonTypeTemplateParameterDefaultArgument) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(265, 135)); - - ASSERT_THAT(infos[10], HasType(HighlightingType::NumberLiteral)); -} - -TEST_F(HighlightingInformations, TemplateTemplateParameter) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(265, 135)); - - ASSERT_THAT(infos[17], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplateTemplateParameterDefaultArgument) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(265, 135)); - - ASSERT_THAT(infos[19], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplateFunctionDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(266, 63)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, TemplateTypeParameterReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(268, 58)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplateTypeParameterDeclarationReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(268, 58)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, NonTypeTemplateParameterReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(269, 71)); - - ASSERT_THAT(infos[3], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, NonTypeTemplateParameterReferenceReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(269, 71)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, TemplateTemplateParameterReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(270, 89)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplateTemplateContainerParameterReference) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(270, 89)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplateTemplateParameterReferenceVariable) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(270, 89)); - - ASSERT_THAT(infos[4], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, ClassFinalVirtualFunctionCallPointer) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(212, 61)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, ClassFinalVirtualFunctionCall) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(277, 23)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, HasFunctionArguments) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(286, 29)); - - ASSERT_TRUE(infos[1].hasFunctionArguments()); -} - -TEST_F(HighlightingInformations, NoOutputFunctionArguments) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(285, 13)); - - auto outputFunctionArguments = infos[1].outputFunctionArguments(); - - ASSERT_THAT(outputFunctionArguments, IsEmpty()); -} - -TEST_F(HighlightingInformations, DISABLED_OneOutputFunctionArguments) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(285, 13)); - - auto outputFunctionArguments = infos[1].outputFunctionArguments(); - - ASSERT_THAT(outputFunctionArguments, SizeIs(1)); -} - -TEST_F(HighlightingInformations, PreprocessorInclusionDirectiveWithAngleBrackets ) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(289, 38)); - - ASSERT_THAT(infos[3], HasType(HighlightingType::StringLiteral)); -} - -TEST_F(HighlightingInformations, ArgumentInMacroExpansionIsKeyword) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(302, 36)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Keyword)); -} - -TEST_F(HighlightingInformations, DISABLED_FirstArgumentInMacroExpansionIsLocalVariable) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(302, 36)); - - ASSERT_THAT(infos[3], HasType(HighlightingType::Invalid)); -} - -TEST_F(HighlightingInformations, DISABLED_SecondArgumentInMacroExpansionIsLocalVariable) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(302, 36)); - - ASSERT_THAT(infos[5], HasType(HighlightingType::Invalid)); -} - -TEST_F(HighlightingInformations, DISABLED_SecondArgumentInMacroExpansionIsField) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(310, 40)); - - ASSERT_THAT(infos[5], HasType(HighlightingType::Invalid)); -} - - -TEST_F(HighlightingInformations, DISABLED_EnumerationType) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(316, 30)); - - ASSERT_THAT(infos[3], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TypeInStaticCast) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(328, 64)); - - ASSERT_THAT(infos[4], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, StaticCastIsKeyword) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(328, 64)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Keyword)); -} - -TEST_F(HighlightingInformations, StaticCastPunctationIsInvalid) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(328, 64)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Invalid)); - ASSERT_THAT(infos[3], HasType(HighlightingType::Invalid)); - ASSERT_THAT(infos[5], HasType(HighlightingType::Invalid)); -} - -TEST_F(HighlightingInformations, TypeInReinterpretCast) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(329, 69)); - - ASSERT_THAT(infos[4], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, IntegerAliasDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(333, 41)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, IntegerAlias) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(341, 31)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, SecondIntegerAlias) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(342, 43)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, IntegerTypedef) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(343, 35)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, FunctionAlias) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(344, 16)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, FriendTypeDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(350, 28)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Invalid)); -} - -TEST_F(HighlightingInformations, FriendArgumentTypeDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(351, 65)); - - ASSERT_THAT(infos[6], HasType(HighlightingType::Invalid)); -} - -TEST_F(HighlightingInformations, FriendArgumentDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(351, 65)); - - ASSERT_THAT(infos[8], HasType(HighlightingType::Invalid)); -} - -TEST_F(HighlightingInformations, FieldInitialization) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(358, 18)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Field)); -} - -TEST_F(HighlightingInformations, TemplateFunctionCall) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(372, 29)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Function)); -} - -TEST_F(HighlightingInformations, TemplatedType) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(377, 21)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplatedTypeDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(384, 49)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, NoOperator) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(389, 24)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Invalid)); -} - -TEST_F(HighlightingInformations, ScopeOperator) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(400, 33)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::Invalid)); -} - -TEST_F(HighlightingInformations, TemplateClassNamespace) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(413, 78)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplateClass) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(413, 78)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplateClassParameter) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(413, 78)); - - ASSERT_THAT(infos[4], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TemplateClassDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(413, 78)); - - ASSERT_THAT(infos[6], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, TypeDefDeclaration) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(418, 36)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, TypeDefDeclarationUsage) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(419, 48)); - - ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); -} - -TEST_F(HighlightingInformations, DISABLED_EnumerationTypeDef) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(424, 41)); - - ASSERT_THAT(infos[3], HasType(HighlightingType::Type)); -} - -// QTCREATORBUG-15473 -TEST_F(HighlightingInformations, DISABLED_ArgumentToUserDefinedIndexOperator) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(434, 19)); - - ASSERT_THAT(infos[2], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, LambdaCapture) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(442, 47)); - - ASSERT_THAT(infos[4], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, LambdaCapturedVarUsage) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(443, 41)); - - ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, LambdaArgumentUsage) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(443, 41)); - - ASSERT_THAT(infos[3], HasType(HighlightingType::LocalVariable)); -} - -TEST_F(HighlightingInformations, LambdaFieldUsage) -{ - const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(443, 41)); - - ASSERT_THAT(infos[5], HasType(HighlightingType::Field)); -} - -Data *HighlightingInformations::d; - -void HighlightingInformations::SetUpTestCase() -{ - d = new Data; -} - -void HighlightingInformations::TearDownTestCase() -{ - delete d; - d = nullptr; -} - -ClangBackEnd::SourceRange HighlightingInformations::sourceRange(uint line, uint columnEnd) const -{ - return translationUnit.sourceRange(line, 1, line, columnEnd); -} - -} diff --git a/tests/unit/unittest/highlightingmarksreportertest.cpp b/tests/unit/unittest/highlightingmarksreportertest.cpp index 831344b6495..11d1cbf5edd 100644 --- a/tests/unit/unittest/highlightingmarksreportertest.cpp +++ b/tests/unit/unittest/highlightingmarksreportertest.cpp @@ -38,7 +38,7 @@ #include "gtest-qt-printing.h" using ClangBackEnd::Cursor; -using ClangBackEnd::HighlightingInformations; +using ClangBackEnd::HighlightingMarks; using ClangBackEnd::HighlightingMarkContainer; using ClangBackEnd::HighlightingType; using ClangBackEnd::TranslationUnit; @@ -54,7 +54,7 @@ struct Data { ProjectParts projects; UnsavedFiles unsavedFiles; TranslationUnits translationUnits{projects, unsavedFiles}; - TranslationUnit translationUnit{Utf8StringLiteral(TESTDATA_DIR"/highlightinginformations.cpp"), + TranslationUnit translationUnit{Utf8StringLiteral(TESTDATA_DIR"/highlightingmarks.cpp"), ProjectPart(Utf8StringLiteral("projectPartId"), {Utf8StringLiteral("-std=c++14")}), {}, diff --git a/tests/unit/unittest/highlightingmarkstest.cpp b/tests/unit/unittest/highlightingmarkstest.cpp new file mode 100644 index 00000000000..efbbdb680b1 --- /dev/null +++ b/tests/unit/unittest/highlightingmarkstest.cpp @@ -0,0 +1,990 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 +** 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. +** +** 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. +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "gtest-qt-printing.h" + +using ClangBackEnd::Cursor; +using ClangBackEnd::HighlightingMark; +using ClangBackEnd::HighlightingMarks; +using ClangBackEnd::HighlightingType; +using ClangBackEnd::TranslationUnit; +using ClangBackEnd::UnsavedFiles; +using ClangBackEnd::ProjectPart; +using ClangBackEnd::TranslationUnits; +using ClangBackEnd::ClangString; +using ClangBackEnd::SourceRange; + +using testing::PrintToString; +using testing::IsNull; +using testing::NotNull; +using testing::Gt; +using testing::Contains; +using testing::EndsWith; +using testing::AllOf; +using testing::Not; +using testing::IsEmpty; +using testing::SizeIs; + +namespace { + +MATCHER_P4(IsHighlightingMark, line, column, length, type, + std::string(negation ? "isn't " : "is ") + + PrintToString(HighlightingMark(line, column, length, type)) + ) +{ + const HighlightingMark expected(line, column, length, type); + + return arg == expected; +} + +MATCHER_P(HasType, type, + std::string(negation ? "isn't " : "is ") + + PrintToString(type) + ) +{ + return arg.hasType(type); +} + +struct Data { + ClangBackEnd::ProjectParts projects; + ClangBackEnd::UnsavedFiles unsavedFiles; + ClangBackEnd::TranslationUnits translationUnits{projects, unsavedFiles}; + TranslationUnit translationUnit{Utf8StringLiteral(TESTDATA_DIR"/highlightingmarks.cpp"), + ProjectPart(Utf8StringLiteral("projectPartId"), {Utf8StringLiteral("-std=c++14")}), + {}, + translationUnits}; +}; + +class HighlightingMarks : public ::testing::Test +{ +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + SourceRange sourceRange(uint line, uint columnEnd) const; + +protected: + static Data *d; + const TranslationUnit &translationUnit = d->translationUnit; +}; + +TEST_F(HighlightingMarks, CreateNullInformations) +{ + ::HighlightingMarks infos; + + ASSERT_TRUE(infos.isNull()); +} + +TEST_F(HighlightingMarks, NullInformationsAreEmpty) +{ + ::HighlightingMarks infos; + + ASSERT_TRUE(infos.isEmpty()); +} + +TEST_F(HighlightingMarks, IsNotNull) +{ + const auto aRange = translationUnit.sourceRange(3, 1, 5, 1); + + const auto infos = translationUnit.highlightingMarksInRange(aRange); + + ASSERT_FALSE(infos.isNull()); +} + +TEST_F(HighlightingMarks, IteratorBeginEnd) +{ + const auto aRange = translationUnit.sourceRange(3, 1, 5, 1); + const auto infos = translationUnit.highlightingMarksInRange(aRange); + + const auto endIterator = std::next(infos.begin(), infos.size()); + + ASSERT_THAT(infos.end(), endIterator); +} + +TEST_F(HighlightingMarks, ForFullTranslationUnitRange) +{ + const auto infos = translationUnit.highlightingMarks(); + + ASSERT_THAT(infos, AllOf(Contains(IsHighlightingMark(1u, 1u, 4u, HighlightingType::Keyword)), + Contains(IsHighlightingMark(277u, 5u, 15u, HighlightingType::Function)))); +} + +TEST_F(HighlightingMarks, Size) +{ + const auto range = translationUnit.sourceRange(5, 5, 5, 10); + + const auto infos = translationUnit.highlightingMarksInRange(range); + + ASSERT_THAT(infos.size(), 1); +} + +TEST_F(HighlightingMarks, DISABLED_Keyword) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(5, 12)); + + ASSERT_THAT(infos[0], IsHighlightingMark(5u, 5u, 6u, HighlightingType::Keyword)); +} + +TEST_F(HighlightingMarks, StringLiteral) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(1, 29)); + + ASSERT_THAT(infos[4], IsHighlightingMark(1u, 24u, 10u, HighlightingType::StringLiteral)); +} + +TEST_F(HighlightingMarks, Utf8StringLiteral) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(2, 33)); + + ASSERT_THAT(infos[4], IsHighlightingMark(2u, 24u, 12u, HighlightingType::StringLiteral)); +} + +TEST_F(HighlightingMarks, RawStringLiteral) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(3, 34)); + + ASSERT_THAT(infos[4], IsHighlightingMark(3u, 24u, 13u, HighlightingType::StringLiteral)); +} + +TEST_F(HighlightingMarks, CharacterLiteral) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(4, 28)); + + ASSERT_THAT(infos[3], IsHighlightingMark(4u, 24u, 3u, HighlightingType::StringLiteral)); +} + +TEST_F(HighlightingMarks, IntegerLiteral) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(23, 26)); + + ASSERT_THAT(infos[3], IsHighlightingMark(23u, 24u, 1u, HighlightingType::NumberLiteral)); +} + +TEST_F(HighlightingMarks, FloatLiteral) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(24, 29)); + + ASSERT_THAT(infos[3], IsHighlightingMark(24u, 24u, 4u, HighlightingType::NumberLiteral)); +} + +TEST_F(HighlightingMarks, FunctionDefinition) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(45, 20)); + + ASSERT_THAT(infos[1], IsHighlightingMark(45u, 5u, 8u, HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, MemberFunctionDefinition) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(52, 29)); + + ASSERT_THAT(infos[1], IsHighlightingMark(52u, 10u, 14u, HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, FunctionDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(55, 32)); + + ASSERT_THAT(infos[1], IsHighlightingMark(55u, 5u, 19u, HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, MemberFunctionDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(59, 27)); + + ASSERT_THAT(infos[1], IsHighlightingMark(59u, 10u, 14u, HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, MemberFunctionReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(104, 35)); + + ASSERT_THAT(infos[0], IsHighlightingMark(104u, 9u, 23u, HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, FunctionCall) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(64, 16)); + + ASSERT_THAT(infos[0], IsHighlightingMark(64u, 5u, 8u, HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, TypeConversionFunction) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(68, 20)); + + ASSERT_THAT(infos[1], IsHighlightingMark(68u, 14u, 3u, HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, InbuiltTypeConversionFunction) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(69, 20)); + + ASSERT_THAT(infos[1], IsHighlightingMark(69u, 14u, 3u, HighlightingType::Keyword)); +} + +TEST_F(HighlightingMarks, TypeReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(74, 13)); + + ASSERT_THAT(infos[0], IsHighlightingMark(74u, 5u, 3u, HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, LocalVariable) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(79, 13)); + + ASSERT_THAT(infos[1], IsHighlightingMark(79u, 9u, 3u, HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, LocalVariableDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(79, 13)); + + ASSERT_THAT(infos[1], IsHighlightingMark(79u, 9u, 3u, HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, LocalVariableReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(81, 26)); + + ASSERT_THAT(infos[0], IsHighlightingMark(81u, 5u, 3u, HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, LocalVariableFunctionArgumentDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(84, 45)); + + ASSERT_THAT(infos[5], IsHighlightingMark(84u, 41u, 3u, HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, LocalVariableFunctionArgumentReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(86, 26)); + + ASSERT_THAT(infos[0], IsHighlightingMark(86u, 5u, 3u, HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, ClassVariableDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(90, 21)); + + ASSERT_THAT(infos[1], IsHighlightingMark(90u, 9u, 11u, HighlightingType::Field)); +} + +TEST_F(HighlightingMarks, ClassVariableReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(94, 23)); + + ASSERT_THAT(infos[0], IsHighlightingMark(94u, 9u, 11u, HighlightingType::Field)); +} + +TEST_F(HighlightingMarks, StaticMethodDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(110, 25)); + + ASSERT_THAT(infos[1], IsHighlightingMark(110u, 10u, 12u, HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, StaticMethodReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(114, 30)); + + ASSERT_THAT(infos[2], IsHighlightingMark(114u, 15u, 12u, HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, Enumeration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(118, 17)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, Enumerator) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(120, 15)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Enumeration)); +} + +TEST_F(HighlightingMarks, EnumerationReferenceDeclarationType) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(125, 28)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, EnumerationReferenceDeclarationVariable) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(125, 28)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, EnumerationReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(127, 30)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, EnumeratorReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(127, 30)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Enumeration)); +} + +TEST_F(HighlightingMarks, ClassForwardDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(130, 12)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, ConstructorDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(134, 13)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, DestructorDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(135, 15)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, ClassForwardDeclarationReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(138, 23)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, ClassTypeReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(140, 32)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, ConstructorReferenceVariable) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(140, 32)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, UnionDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(145, 12)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, UnionDeclarationReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(150, 33)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, GlobalVariable) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(150, 33)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::GlobalVariable)); +} + +TEST_F(HighlightingMarks, StructDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(50, 11)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, NameSpace) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(160, 22)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, NameSpaceAlias) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(164, 38)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, UsingStructInNameSpace) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(165, 36)); + + ASSERT_THAT(infos[3], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, NameSpaceReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(166, 35)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, StructInNameSpaceReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(166, 35)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, VirtualFunction) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(170, 35)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::VirtualFunction)); +} + +TEST_F(HighlightingMarks, DISABLED_NonVirtualFunctionCall) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(177, 46)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, DISABLED_NonVirtualFunctionCallPointer) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(180, 54)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, VirtualFunctionCallPointer) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(192, 51)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::VirtualFunction)); +} + +TEST_F(HighlightingMarks, FinalVirtualFunctionCallPointer) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(202, 61)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, NonFinalVirtualFunctionCallPointer) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(207, 61)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::VirtualFunction)); +} + +TEST_F(HighlightingMarks, PlusOperator) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(224, 49)); + + ASSERT_THAT(infos[6], HasType(HighlightingType::Operator)); +} + +TEST_F(HighlightingMarks, PlusAssignOperator) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(226, 24)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Operator)); +} + +TEST_F(HighlightingMarks, Comment) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(229, 14)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Comment)); +} + +TEST_F(HighlightingMarks, PreprocessingDirective) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(231, 37)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Preprocessor)); +} + +TEST_F(HighlightingMarks, PreprocessorMacroDefinition) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(231, 37)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::PreprocessorDefinition)); +} + +TEST_F(HighlightingMarks, PreprocessorFunctionMacroDefinition) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(232, 47)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::PreprocessorDefinition)); +} + +TEST_F(HighlightingMarks, PreprocessorMacroExpansion) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(236, 27)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::PreprocessorExpansion)); +} + +TEST_F(HighlightingMarks, PreprocessorMacroExpansionArgument) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(236, 27)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::NumberLiteral)); +} + +TEST_F(HighlightingMarks, PreprocessorInclusionDirective) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(239, 18)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::StringLiteral)); +} + +TEST_F(HighlightingMarks, GotoLabelStatement) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(242, 12)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Label)); +} + +TEST_F(HighlightingMarks, GotoLabelStatementReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(244, 21)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Label)); +} + +TEST_F(HighlightingMarks, TemplateReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(254, 25)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, TemplateTypeParameter) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(265, 135)); + + ASSERT_THAT(infos[3], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplateDefaultParameter) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(265, 135)); + + ASSERT_THAT(infos[5], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, NonTypeTemplateParameter) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(265, 135)); + + ASSERT_THAT(infos[8], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, NonTypeTemplateParameterDefaultArgument) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(265, 135)); + + ASSERT_THAT(infos[10], HasType(HighlightingType::NumberLiteral)); +} + +TEST_F(HighlightingMarks, TemplateTemplateParameter) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(265, 135)); + + ASSERT_THAT(infos[17], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplateTemplateParameterDefaultArgument) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(265, 135)); + + ASSERT_THAT(infos[19], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplateFunctionDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(266, 63)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, TemplateTypeParameterReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(268, 58)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplateTypeParameterDeclarationReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(268, 58)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, NonTypeTemplateParameterReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(269, 71)); + + ASSERT_THAT(infos[3], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, NonTypeTemplateParameterReferenceReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(269, 71)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, TemplateTemplateParameterReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(270, 89)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplateTemplateContainerParameterReference) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(270, 89)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplateTemplateParameterReferenceVariable) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(270, 89)); + + ASSERT_THAT(infos[4], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, ClassFinalVirtualFunctionCallPointer) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(212, 61)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, ClassFinalVirtualFunctionCall) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(277, 23)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, HasFunctionArguments) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(286, 29)); + + ASSERT_TRUE(infos[1].hasFunctionArguments()); +} + +TEST_F(HighlightingMarks, NoOutputFunctionArguments) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(285, 13)); + + auto outputFunctionArguments = infos[1].outputFunctionArguments(); + + ASSERT_THAT(outputFunctionArguments, IsEmpty()); +} + +TEST_F(HighlightingMarks, DISABLED_OneOutputFunctionArguments) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(285, 13)); + + auto outputFunctionArguments = infos[1].outputFunctionArguments(); + + ASSERT_THAT(outputFunctionArguments, SizeIs(1)); +} + +TEST_F(HighlightingMarks, PreprocessorInclusionDirectiveWithAngleBrackets ) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(289, 38)); + + ASSERT_THAT(infos[3], HasType(HighlightingType::StringLiteral)); +} + +TEST_F(HighlightingMarks, ArgumentInMacroExpansionIsKeyword) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(302, 36)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Keyword)); +} + +TEST_F(HighlightingMarks, DISABLED_FirstArgumentInMacroExpansionIsLocalVariable) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(302, 36)); + + ASSERT_THAT(infos[3], HasType(HighlightingType::Invalid)); +} + +TEST_F(HighlightingMarks, DISABLED_SecondArgumentInMacroExpansionIsLocalVariable) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(302, 36)); + + ASSERT_THAT(infos[5], HasType(HighlightingType::Invalid)); +} + +TEST_F(HighlightingMarks, DISABLED_SecondArgumentInMacroExpansionIsField) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(310, 40)); + + ASSERT_THAT(infos[5], HasType(HighlightingType::Invalid)); +} + + +TEST_F(HighlightingMarks, DISABLED_EnumerationType) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(316, 30)); + + ASSERT_THAT(infos[3], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TypeInStaticCast) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(328, 64)); + + ASSERT_THAT(infos[4], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, StaticCastIsKeyword) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(328, 64)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Keyword)); +} + +TEST_F(HighlightingMarks, StaticCastPunctationIsInvalid) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(328, 64)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Invalid)); + ASSERT_THAT(infos[3], HasType(HighlightingType::Invalid)); + ASSERT_THAT(infos[5], HasType(HighlightingType::Invalid)); +} + +TEST_F(HighlightingMarks, TypeInReinterpretCast) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(329, 69)); + + ASSERT_THAT(infos[4], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, IntegerAliasDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(333, 41)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, IntegerAlias) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(341, 31)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, SecondIntegerAlias) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(342, 43)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, IntegerTypedef) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(343, 35)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, FunctionAlias) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(344, 16)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, FriendTypeDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(350, 28)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Invalid)); +} + +TEST_F(HighlightingMarks, FriendArgumentTypeDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(351, 65)); + + ASSERT_THAT(infos[6], HasType(HighlightingType::Invalid)); +} + +TEST_F(HighlightingMarks, FriendArgumentDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(351, 65)); + + ASSERT_THAT(infos[8], HasType(HighlightingType::Invalid)); +} + +TEST_F(HighlightingMarks, FieldInitialization) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(358, 18)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Field)); +} + +TEST_F(HighlightingMarks, TemplateFunctionCall) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(372, 29)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Function)); +} + +TEST_F(HighlightingMarks, TemplatedType) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(377, 21)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplatedTypeDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(384, 49)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, NoOperator) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(389, 24)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Invalid)); +} + +TEST_F(HighlightingMarks, ScopeOperator) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(400, 33)); + + ASSERT_THAT(infos[1], HasType(HighlightingType::Invalid)); +} + +TEST_F(HighlightingMarks, TemplateClassNamespace) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(413, 78)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplateClass) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(413, 78)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplateClassParameter) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(413, 78)); + + ASSERT_THAT(infos[4], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TemplateClassDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(413, 78)); + + ASSERT_THAT(infos[6], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingMarks, TypeDefDeclaration) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(418, 36)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, TypeDefDeclarationUsage) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(419, 48)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingMarks, DISABLED_EnumerationTypeDef) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(424, 41)); + + ASSERT_THAT(infos[3], HasType(HighlightingType::Type)); +} + +// QTCREATORBUG-15473 +TEST_F(HighlightingMarks, DISABLED_ArgumentToUserDefinedIndexOperator) +{ + const auto infos = translationUnit.highlightingMarksInRange(sourceRange(434, 19)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::LocalVariable)); +} + +Data *HighlightingMarks::d; + +void HighlightingMarks::SetUpTestCase() +{ + d = new Data; +} + +void HighlightingMarks::TearDownTestCase() +{ + delete d; + d = nullptr; +} + +ClangBackEnd::SourceRange HighlightingMarks::sourceRange(uint line, uint columnEnd) const +{ + return translationUnit.sourceRange(line, 1, line, columnEnd); +} + +} diff --git a/tests/unit/unittest/translationunitstest.cpp b/tests/unit/unittest/translationunitstest.cpp index 25c64080cdb..84946f4f48e 100644 --- a/tests/unit/unittest/translationunitstest.cpp +++ b/tests/unit/unittest/translationunitstest.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -217,30 +217,30 @@ TEST_F(TranslationUnits, RemoveFileAndCheckForDiagnostics) ASSERT_TRUE(translationUnits.translationUnit(filePath, projectPartId).hasNewDiagnostics()); } -TEST_F(TranslationUnits, UpdateUnsavedFileAndCheckForHighlightingInformations) +TEST_F(TranslationUnits, UpdateUnsavedFileAndCheckForHighlightingMarks) { ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u); ClangBackEnd::FileContainer headerContainer(headerPath, projectPartId, Utf8StringVector(), 74u); ClangBackEnd::FileContainer headerContainerWithUnsavedContent(headerPath, projectPartId, Utf8String(), true, 75u); translationUnits.create({fileContainer, headerContainer}); - translationUnits.translationUnit(filePath, projectPartId).highlightingInformations(); + translationUnits.translationUnit(filePath, projectPartId).highlightingMarks(); translationUnits.update({headerContainerWithUnsavedContent}); - ASSERT_TRUE(translationUnits.translationUnit(filePath, projectPartId).hasNewHighlightingInformations()); + ASSERT_TRUE(translationUnits.translationUnit(filePath, projectPartId).hasNewHighlightingMarks()); } -TEST_F(TranslationUnits, RemoveFileAndCheckForHighlightingInformations) +TEST_F(TranslationUnits, RemoveFileAndCheckForHighlightingMarks) { ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u); ClangBackEnd::FileContainer headerContainer(headerPath, projectPartId, Utf8StringVector(), 74u); ClangBackEnd::FileContainer headerContainerWithUnsavedContent(headerPath, projectPartId, Utf8String(), true, 75u); translationUnits.create({fileContainer, headerContainer}); - translationUnits.translationUnit(filePath, projectPartId).highlightingInformations(); + translationUnits.translationUnit(filePath, projectPartId).highlightingMarks(); translationUnits.remove({headerContainerWithUnsavedContent}); - ASSERT_TRUE(translationUnits.translationUnit(filePath, projectPartId).hasNewHighlightingInformations()); + ASSERT_TRUE(translationUnits.translationUnit(filePath, projectPartId).hasNewHighlightingMarks()); } TEST_F(TranslationUnits, DontGetNewerFileContainerIfRevisionIsTheSame) @@ -402,7 +402,7 @@ TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsAfterGettingDocumentAnnotat auto translationUnit = translationUnits.translationUnit(fileContainer); translationUnit.setIsVisibleInEditor(true); translationUnit.diagnostics(); // Reset - translationUnit.highlightingInformations(); // Reset + translationUnit.highlightingMarks(); // Reset EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(0); @@ -435,7 +435,7 @@ TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsForCurrentEditorAfterGettin auto translationUnit = translationUnits.translationUnit(fileContainer); translationUnit.setIsUsedByCurrentEditor(true); translationUnit.diagnostics(); // Reset - translationUnit.highlightingInformations(); // Reset + translationUnit.highlightingMarks(); // Reset EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(0); @@ -472,7 +472,7 @@ TEST_F(TranslationUnits, SendDocumentAnnotationsOnlyOnceForVisibleEditor) auto headerTranslationUnit = translationUnits.translationUnit(headerContainer); headerTranslationUnit.setIsVisibleInEditor(true); headerTranslationUnit.diagnostics(); // Reset - headerTranslationUnit.highlightingInformations(); // Reset + headerTranslationUnit.highlightingMarks(); // Reset EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(1); @@ -485,7 +485,7 @@ TEST_F(TranslationUnits, SendDocumentAnnotationsAfterProjectPartChange) auto fileTranslationUnit = translationUnits.translationUnit(fileContainer); fileTranslationUnit.setIsVisibleInEditor(true); fileTranslationUnit.diagnostics(); // Reset - fileTranslationUnit.highlightingInformations(); // Reset + fileTranslationUnit.highlightingMarks(); // Reset projects.createOrUpdate({ProjectPartContainer(projectPartId, {Utf8StringLiteral("-DNEW")})}); translationUnits.setTranslationUnitsDirtyIfProjectPartChanged(); diff --git a/tests/unit/unittest/translationunittest.cpp b/tests/unit/unittest/translationunittest.cpp index f4931235d1c..a3fd9ea2d6c 100644 --- a/tests/unit/unittest/translationunittest.cpp +++ b/tests/unit/unittest/translationunittest.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -289,49 +289,49 @@ TEST_F(TranslationUnit, HasNoNewDiagnosticsAfterGettingDiagnostics) ASSERT_FALSE(translationUnit.hasNewDiagnostics()); } -TEST_F(TranslationUnit, HasNewHighlightingInformationsAfterCreation) +TEST_F(TranslationUnit, HasNewHighlightingMarksAfterCreation) { translationUnit.cxTranslationUnit(); - ASSERT_TRUE(translationUnit.hasNewHighlightingInformations()); + ASSERT_TRUE(translationUnit.hasNewHighlightingMarks()); } -TEST_F(TranslationUnit, HasNewHighlightingInformationsForMainFile) +TEST_F(TranslationUnit, HasNewHighlightingMarksForMainFile) { translationUnit.cxTranslationUnit(); translationUnit.setDirtyIfDependencyIsMet(translationUnitFilePath); - ASSERT_TRUE(translationUnit.hasNewHighlightingInformations()); + ASSERT_TRUE(translationUnit.hasNewHighlightingMarks()); } -TEST_F(TranslationUnit, HasNoNewHighlightingInformationsForIndependendFile) +TEST_F(TranslationUnit, HasNoNewHighlightingMarksForIndependendFile) { translationUnit.cxTranslationUnit(); - translationUnit.highlightingInformations(); + translationUnit.highlightingMarks(); translationUnit.setDirtyIfDependencyIsMet(Utf8StringLiteral(TESTDATA_DIR"/otherfiles.h")); - ASSERT_FALSE(translationUnit.hasNewHighlightingInformations()); + ASSERT_FALSE(translationUnit.hasNewHighlightingMarks()); } -TEST_F(TranslationUnit, HasNewHighlightingInformationsForDependendFile) +TEST_F(TranslationUnit, HasNewHighlightingMarksForDependendFile) { translationUnit.cxTranslationUnit(); translationUnit.setDirtyIfDependencyIsMet(Utf8StringLiteral(TESTDATA_DIR"/translationunits.h")); - ASSERT_TRUE(translationUnit.hasNewHighlightingInformations()); + ASSERT_TRUE(translationUnit.hasNewHighlightingMarks()); } -TEST_F(TranslationUnit, HasNoNewHighlightingInformationsAfterGettingHighlightingInformations) +TEST_F(TranslationUnit, HasNoNewHighlightingMarksAfterGettingHighlightingMarks) { translationUnit.cxTranslationUnit(); translationUnit.setDirtyIfDependencyIsMet(translationUnitFilePath); - translationUnit.highlightingInformations(); + translationUnit.highlightingMarks(); - ASSERT_FALSE(translationUnit.hasNewHighlightingInformations()); + ASSERT_FALSE(translationUnit.hasNewHighlightingMarks()); } TEST_F(TranslationUnit, SetDirtyIfProjectPartIsOutdated) diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index 577e7fc3592..c53cc35172c 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -61,13 +61,13 @@ SOURCES += \ utf8test.cpp \ senddocumenttrackertest.cpp \ cursortest.cpp \ - highlightinginformationstest.cpp \ skippedsourcerangestest.cpp \ highlightingmarksreportertest.cpp \ chunksreportedmonitor.cpp \ unsavedfiletest.cpp \ clangisdiagnosticrelatedtolocationtest.cpp \ smallstringtest.cpp \ + highlightingmarkstest.cpp \ sizedarraytest.cpp exists($$GOOGLEBENCHMARK_DIR) {