forked from qt-creator/qt-creator
Clang: Rename HighlightingMark to TokenInfo
Before adding additional members into that class it makes sense to rename it to better represent its content. Other classes serving the same purpose are also renamed to keep the names consistent. Change-Id: I3c8517e42aae29779d71ec9c85b713cff581a473 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -41,7 +41,6 @@ SOURCES += \
|
|||||||
$$PWD/filepath.cpp \
|
$$PWD/filepath.cpp \
|
||||||
$$PWD/fixitcontainer.cpp \
|
$$PWD/fixitcontainer.cpp \
|
||||||
$$PWD/followsymbolmessage.cpp \
|
$$PWD/followsymbolmessage.cpp \
|
||||||
$$PWD/highlightingmarkcontainer.cpp \
|
|
||||||
$$PWD/ipcclientinterface.cpp \
|
$$PWD/ipcclientinterface.cpp \
|
||||||
$$PWD/ipcinterface.cpp \
|
$$PWD/ipcinterface.cpp \
|
||||||
$$PWD/ipcserverinterface.cpp \
|
$$PWD/ipcserverinterface.cpp \
|
||||||
@@ -82,6 +81,7 @@ SOURCES += \
|
|||||||
$$PWD/sourcerangescontainer.cpp \
|
$$PWD/sourcerangescontainer.cpp \
|
||||||
$$PWD/sourcerangesforquerymessage.cpp \
|
$$PWD/sourcerangesforquerymessage.cpp \
|
||||||
$$PWD/sourcerangewithtextcontainer.cpp \
|
$$PWD/sourcerangewithtextcontainer.cpp \
|
||||||
|
$$PWD/tokeninfocontainer.cpp \
|
||||||
$$PWD/unregisterunsavedfilesforeditormessage.cpp \
|
$$PWD/unregisterunsavedfilesforeditormessage.cpp \
|
||||||
$$PWD/updatepchprojectpartsmessage.cpp \
|
$$PWD/updatepchprojectpartsmessage.cpp \
|
||||||
$$PWD/updatetranslationunitsforeditormessage.cpp \
|
$$PWD/updatetranslationunitsforeditormessage.cpp \
|
||||||
@@ -131,7 +131,6 @@ HEADERS += \
|
|||||||
$$PWD/filecontainerv2.h \
|
$$PWD/filecontainerv2.h \
|
||||||
$$PWD/fixitcontainer.h \
|
$$PWD/fixitcontainer.h \
|
||||||
$$PWD/followsymbolmessage.h \
|
$$PWD/followsymbolmessage.h \
|
||||||
$$PWD/highlightingmarkcontainer.h \
|
|
||||||
$$PWD/idpaths.h \
|
$$PWD/idpaths.h \
|
||||||
$$PWD/ipcclientinterface.h \
|
$$PWD/ipcclientinterface.h \
|
||||||
$$PWD/ipcinterface.h \
|
$$PWD/ipcinterface.h \
|
||||||
@@ -176,6 +175,7 @@ HEADERS += \
|
|||||||
$$PWD/sourcerangesforquerymessage.h \
|
$$PWD/sourcerangesforquerymessage.h \
|
||||||
$$PWD/sourcerangewithtextcontainer.h \
|
$$PWD/sourcerangewithtextcontainer.h \
|
||||||
$$PWD/stringcache.h \
|
$$PWD/stringcache.h \
|
||||||
|
$$PWD/tokeninfocontainer.h \
|
||||||
$$PWD/unregisterunsavedfilesforeditormessage.h \
|
$$PWD/unregisterunsavedfilesforeditormessage.h \
|
||||||
$$PWD/updatepchprojectpartsmessage.h \
|
$$PWD/updatepchprojectpartsmessage.h \
|
||||||
$$PWD/updatetranslationunitsforeditormessage.h \
|
$$PWD/updatetranslationunitsforeditormessage.h \
|
||||||
|
@@ -38,7 +38,7 @@ QDebug operator<<(QDebug debug, const DocumentAnnotationsChangedMessage &message
|
|||||||
<< message.fileContainer()
|
<< message.fileContainer()
|
||||||
<< ", " << message.diagnostics().size()
|
<< ", " << message.diagnostics().size()
|
||||||
<< ", " << !message.firstHeaderErrorDiagnostic().text().isEmpty()
|
<< ", " << !message.firstHeaderErrorDiagnostic().text().isEmpty()
|
||||||
<< ", " << message.highlightingMarks().size()
|
<< ", " << message.tokenInfos().size()
|
||||||
<< ", " << message.skippedPreprocessorRanges().size()
|
<< ", " << message.skippedPreprocessorRanges().size()
|
||||||
<< ")";
|
<< ")";
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ std::ostream &operator<<(std::ostream &os, const DocumentAnnotationsChangedMessa
|
|||||||
<< message.fileContainer()
|
<< message.fileContainer()
|
||||||
<< "," << message.diagnostics().size()
|
<< "," << message.diagnostics().size()
|
||||||
<< "," << !message.firstHeaderErrorDiagnostic().text().isEmpty()
|
<< "," << !message.firstHeaderErrorDiagnostic().text().isEmpty()
|
||||||
<< "," << message.highlightingMarks().size()
|
<< "," << message.tokenInfos().size()
|
||||||
<< "," << message.skippedPreprocessorRanges().size()
|
<< "," << message.skippedPreprocessorRanges().size()
|
||||||
<< ")";
|
<< ")";
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "clangsupport_global.h"
|
#include "clangsupport_global.h"
|
||||||
#include "diagnosticcontainer.h"
|
#include "diagnosticcontainer.h"
|
||||||
#include "filecontainer.h"
|
#include "filecontainer.h"
|
||||||
#include "highlightingmarkcontainer.h"
|
#include "tokeninfocontainer.h"
|
||||||
#include "sourcerangecontainer.h"
|
#include "sourcerangecontainer.h"
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
@@ -42,12 +42,12 @@ public:
|
|||||||
DocumentAnnotationsChangedMessage(const FileContainer &fileContainer,
|
DocumentAnnotationsChangedMessage(const FileContainer &fileContainer,
|
||||||
const QVector<DiagnosticContainer> &diagnostics,
|
const QVector<DiagnosticContainer> &diagnostics,
|
||||||
const DiagnosticContainer &firstHeaderErrorDiagnostic,
|
const DiagnosticContainer &firstHeaderErrorDiagnostic,
|
||||||
const QVector<HighlightingMarkContainer> &highlightingMarks,
|
const QVector<TokenInfoContainer> &tokenInfos,
|
||||||
const QVector<SourceRangeContainer> &skippedPreprocessorRanges)
|
const QVector<SourceRangeContainer> &skippedPreprocessorRanges)
|
||||||
: m_fileContainer(fileContainer),
|
: m_fileContainer(fileContainer),
|
||||||
m_diagnostics(diagnostics),
|
m_diagnostics(diagnostics),
|
||||||
m_firstHeaderErrorDiagnostic(firstHeaderErrorDiagnostic),
|
m_firstHeaderErrorDiagnostic(firstHeaderErrorDiagnostic),
|
||||||
m_highlightingMarks(highlightingMarks),
|
m_tokenInfos(tokenInfos),
|
||||||
m_skippedPreprocessorRanges(skippedPreprocessorRanges)
|
m_skippedPreprocessorRanges(skippedPreprocessorRanges)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -67,9 +67,9 @@ public:
|
|||||||
return m_firstHeaderErrorDiagnostic;
|
return m_firstHeaderErrorDiagnostic;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<HighlightingMarkContainer> &highlightingMarks() const
|
const QVector<TokenInfoContainer> &tokenInfos() const
|
||||||
{
|
{
|
||||||
return m_highlightingMarks;
|
return m_tokenInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<SourceRangeContainer> &skippedPreprocessorRanges() const
|
const QVector<SourceRangeContainer> &skippedPreprocessorRanges() const
|
||||||
@@ -82,7 +82,7 @@ public:
|
|||||||
out << message.m_fileContainer;
|
out << message.m_fileContainer;
|
||||||
out << message.m_diagnostics;
|
out << message.m_diagnostics;
|
||||||
out << message.m_firstHeaderErrorDiagnostic;
|
out << message.m_firstHeaderErrorDiagnostic;
|
||||||
out << message.m_highlightingMarks;
|
out << message.m_tokenInfos;
|
||||||
out << message.m_skippedPreprocessorRanges;
|
out << message.m_skippedPreprocessorRanges;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@@ -93,7 +93,7 @@ public:
|
|||||||
in >> message.m_fileContainer;
|
in >> message.m_fileContainer;
|
||||||
in >> message.m_diagnostics;
|
in >> message.m_diagnostics;
|
||||||
in >> message.m_firstHeaderErrorDiagnostic;
|
in >> message.m_firstHeaderErrorDiagnostic;
|
||||||
in >> message.m_highlightingMarks;
|
in >> message.m_tokenInfos;
|
||||||
in >> message.m_skippedPreprocessorRanges;
|
in >> message.m_skippedPreprocessorRanges;
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
@@ -105,7 +105,7 @@ public:
|
|||||||
return first.m_fileContainer == second.m_fileContainer
|
return first.m_fileContainer == second.m_fileContainer
|
||||||
&& first.m_diagnostics == second.m_diagnostics
|
&& first.m_diagnostics == second.m_diagnostics
|
||||||
&& first.m_firstHeaderErrorDiagnostic == second.m_firstHeaderErrorDiagnostic
|
&& first.m_firstHeaderErrorDiagnostic == second.m_firstHeaderErrorDiagnostic
|
||||||
&& first.m_highlightingMarks == second.m_highlightingMarks
|
&& first.m_tokenInfos == second.m_tokenInfos
|
||||||
&& first.m_skippedPreprocessorRanges == second.m_skippedPreprocessorRanges;
|
&& first.m_skippedPreprocessorRanges == second.m_skippedPreprocessorRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ private:
|
|||||||
FileContainer m_fileContainer;
|
FileContainer m_fileContainer;
|
||||||
QVector<DiagnosticContainer> m_diagnostics;
|
QVector<DiagnosticContainer> m_diagnostics;
|
||||||
DiagnosticContainer m_firstHeaderErrorDiagnostic;
|
DiagnosticContainer m_firstHeaderErrorDiagnostic;
|
||||||
QVector<HighlightingMarkContainer> m_highlightingMarks;
|
QVector<TokenInfoContainer> m_tokenInfos;
|
||||||
QVector<SourceRangeContainer> m_skippedPreprocessorRanges;
|
QVector<SourceRangeContainer> m_skippedPreprocessorRanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "highlightingmarkcontainer.h"
|
#include "tokeninfocontainer.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@@ -59,9 +59,9 @@ static const char *highlightingTypeToCStringLiteral(HighlightingType type)
|
|||||||
}
|
}
|
||||||
#undef RETURN_TEXT_FOR_CASE
|
#undef RETURN_TEXT_FOR_CASE
|
||||||
|
|
||||||
QDebug operator<<(QDebug debug, const HighlightingMarkContainer &container)
|
QDebug operator<<(QDebug debug, const TokenInfoContainer &container)
|
||||||
{
|
{
|
||||||
debug.nospace() << "HighlightingMarkContainer("
|
debug.nospace() << "TokenInfosContainer("
|
||||||
<< container.line() << ", "
|
<< container.line() << ", "
|
||||||
<< container.column() << ", "
|
<< container.column() << ", "
|
||||||
<< container.length() << ", "
|
<< container.length() << ", "
|
||||||
@@ -91,7 +91,7 @@ std::ostream &operator<<(std::ostream &os, HighlightingTypes types)
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const HighlightingMarkContainer &container)
|
std::ostream &operator<<(std::ostream &os, const TokenInfoContainer &container)
|
||||||
{
|
{
|
||||||
os << "("
|
os << "("
|
||||||
<< container.line() << ", "
|
<< container.line() << ", "
|
@@ -40,11 +40,11 @@ inline QDataStream &operator>>(QDataStream &in, HighlightingTypes &highlightingT
|
|||||||
inline bool operator==(const MixinHighlightingTypes &first, const MixinHighlightingTypes &second);
|
inline bool operator==(const MixinHighlightingTypes &first, const MixinHighlightingTypes &second);
|
||||||
inline bool operator==(const HighlightingTypes &first, const HighlightingTypes &second);
|
inline bool operator==(const HighlightingTypes &first, const HighlightingTypes &second);
|
||||||
|
|
||||||
class HighlightingMarkContainer
|
class TokenInfoContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HighlightingMarkContainer() = default;
|
TokenInfoContainer() = default;
|
||||||
HighlightingMarkContainer(uint line, uint column, uint length, HighlightingTypes types,
|
TokenInfoContainer(uint line, uint column, uint length, HighlightingTypes types,
|
||||||
bool isIdentifier = false, bool isIncludeDirectivePath = false)
|
bool isIdentifier = false, bool isIncludeDirectivePath = false)
|
||||||
: line_(line),
|
: line_(line),
|
||||||
column_(column),
|
column_(column),
|
||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMarkContainer(uint line, uint column, uint length, HighlightingType type)
|
TokenInfoContainer(uint line, uint column, uint length, HighlightingType type)
|
||||||
: line_(line),
|
: line_(line),
|
||||||
column_(column),
|
column_(column),
|
||||||
length_(length)
|
length_(length)
|
||||||
@@ -98,7 +98,7 @@ public:
|
|||||||
return isIncludeDirectivePath_;
|
return isIncludeDirectivePath_;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend QDataStream &operator<<(QDataStream &out, const HighlightingMarkContainer &container)
|
friend QDataStream &operator<<(QDataStream &out, const TokenInfoContainer &container)
|
||||||
{
|
{
|
||||||
out << container.line_;
|
out << container.line_;
|
||||||
out << container.column_;
|
out << container.column_;
|
||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend QDataStream &operator>>(QDataStream &in, HighlightingMarkContainer &container)
|
friend QDataStream &operator>>(QDataStream &in, TokenInfoContainer &container)
|
||||||
{
|
{
|
||||||
in >> container.line_;
|
in >> container.line_;
|
||||||
in >> container.column_;
|
in >> container.column_;
|
||||||
@@ -122,7 +122,7 @@ public:
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(const HighlightingMarkContainer &first, const HighlightingMarkContainer &second)
|
friend bool operator==(const TokenInfoContainer &first, const TokenInfoContainer &second)
|
||||||
{
|
{
|
||||||
return first.line_ == second.line_
|
return first.line_ == second.line_
|
||||||
&& first.column_ == second.column_
|
&& first.column_ == second.column_
|
||||||
@@ -200,9 +200,9 @@ inline bool operator==(const HighlightingTypes &first, const HighlightingTypes &
|
|||||||
&& first.mixinHighlightingTypes == second.mixinHighlightingTypes;
|
&& first.mixinHighlightingTypes == second.mixinHighlightingTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const HighlightingMarkContainer &container);
|
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const TokenInfoContainer &container);
|
||||||
CLANGSUPPORT_EXPORT std::ostream &operator<<(std::ostream &os, HighlightingType highlightingType);
|
CLANGSUPPORT_EXPORT std::ostream &operator<<(std::ostream &os, HighlightingType highlightingType);
|
||||||
CLANGSUPPORT_EXPORT std::ostream &operator<<(std::ostream &os, HighlightingTypes types);
|
CLANGSUPPORT_EXPORT std::ostream &operator<<(std::ostream &os, HighlightingTypes types);
|
||||||
std::ostream &operator<<(std::ostream &os, const HighlightingMarkContainer &container);
|
std::ostream &operator<<(std::ostream &os, const TokenInfoContainer &container);
|
||||||
|
|
||||||
} // namespace ClangBackEnd
|
} // namespace ClangBackEnd
|
@@ -181,7 +181,7 @@ void BackendReceiver::documentAnnotationsChanged(const DocumentAnnotationsChange
|
|||||||
{
|
{
|
||||||
qCDebug(log) << "<<< DocumentAnnotationsChangedMessage with"
|
qCDebug(log) << "<<< DocumentAnnotationsChangedMessage with"
|
||||||
<< message.diagnostics().size() << "diagnostics"
|
<< message.diagnostics().size() << "diagnostics"
|
||||||
<< message.highlightingMarks().size() << "highlighting marks"
|
<< message.tokenInfos().size() << "highlighting marks"
|
||||||
<< message.skippedPreprocessorRanges().size() << "skipped preprocessor ranges";
|
<< message.skippedPreprocessorRanges().size() << "skipped preprocessor ranges";
|
||||||
|
|
||||||
auto processor = ClangEditorDocumentProcessor::get(message.fileContainer().filePath());
|
auto processor = ClangEditorDocumentProcessor::get(message.fileContainer().filePath());
|
||||||
@@ -195,7 +195,7 @@ void BackendReceiver::documentAnnotationsChanged(const DocumentAnnotationsChange
|
|||||||
processor->updateCodeWarnings(message.diagnostics(),
|
processor->updateCodeWarnings(message.diagnostics(),
|
||||||
message.firstHeaderErrorDiagnostic(),
|
message.firstHeaderErrorDiagnostic(),
|
||||||
documentRevision);
|
documentRevision);
|
||||||
processor->updateHighlighting(message.highlightingMarks(),
|
processor->updateHighlighting(message.tokenInfos(),
|
||||||
message.skippedPreprocessorRanges(),
|
message.skippedPreprocessorRanges(),
|
||||||
documentRevision);
|
documentRevision);
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ SOURCES += \
|
|||||||
clangfixitoperationsextractor.cpp \
|
clangfixitoperationsextractor.cpp \
|
||||||
clangfollowsymbol.cpp \
|
clangfollowsymbol.cpp \
|
||||||
clangfunctionhintmodel.cpp \
|
clangfunctionhintmodel.cpp \
|
||||||
clanghighlightingmarksreporter.cpp \
|
clangtokeninfosreporter.cpp \
|
||||||
clangmodelmanagersupport.cpp \
|
clangmodelmanagersupport.cpp \
|
||||||
clangpreprocessorassistproposalitem.cpp \
|
clangpreprocessorassistproposalitem.cpp \
|
||||||
clangprojectsettings.cpp \
|
clangprojectsettings.cpp \
|
||||||
@@ -66,7 +66,6 @@ HEADERS += \
|
|||||||
clangfixitoperationsextractor.h \
|
clangfixitoperationsextractor.h \
|
||||||
clangfollowsymbol.h \
|
clangfollowsymbol.h \
|
||||||
clangfunctionhintmodel.h \
|
clangfunctionhintmodel.h \
|
||||||
clanghighlightingmarksreporter.h \
|
|
||||||
clangisdiagnosticrelatedtolocation.h \
|
clangisdiagnosticrelatedtolocation.h \
|
||||||
clangmodelmanagersupport.h \
|
clangmodelmanagersupport.h \
|
||||||
clangpreprocessorassistproposalitem.h \
|
clangpreprocessorassistproposalitem.h \
|
||||||
@@ -75,7 +74,8 @@ HEADERS += \
|
|||||||
clangrefactoringengine.h \
|
clangrefactoringengine.h \
|
||||||
clangtextmark.h \
|
clangtextmark.h \
|
||||||
clanguiheaderondiskmanager.h \
|
clanguiheaderondiskmanager.h \
|
||||||
clangutils.h
|
clangutils.h \
|
||||||
|
clangtokeninfosreporter.h
|
||||||
|
|
||||||
FORMS += clangprojectsettingswidget.ui
|
FORMS += clangprojectsettingswidget.ui
|
||||||
|
|
||||||
|
@@ -80,8 +80,8 @@ QtcPlugin {
|
|||||||
"clangfollowsymbol.h",
|
"clangfollowsymbol.h",
|
||||||
"clangfunctionhintmodel.cpp",
|
"clangfunctionhintmodel.cpp",
|
||||||
"clangfunctionhintmodel.h",
|
"clangfunctionhintmodel.h",
|
||||||
"clanghighlightingmarksreporter.cpp",
|
"clangtokeninfosreporter.cpp",
|
||||||
"clanghighlightingmarksreporter.h",
|
"clangtokeninfosreporter.h",
|
||||||
"clangisdiagnosticrelatedtolocation.h",
|
"clangisdiagnosticrelatedtolocation.h",
|
||||||
"clangmodelmanagersupport.cpp",
|
"clangmodelmanagersupport.cpp",
|
||||||
"clangmodelmanagersupport.h",
|
"clangmodelmanagersupport.h",
|
||||||
|
@@ -7,7 +7,7 @@ SOURCES += \
|
|||||||
$$PWD/clangcompletioncontextanalyzer.cpp \
|
$$PWD/clangcompletioncontextanalyzer.cpp \
|
||||||
$$PWD/clangdiagnosticfilter.cpp \
|
$$PWD/clangdiagnosticfilter.cpp \
|
||||||
$$PWD/clangfixitoperation.cpp \
|
$$PWD/clangfixitoperation.cpp \
|
||||||
$$PWD/clanghighlightingmarksreporter.cpp
|
$$PWD/clangtokeninfosreporter.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/clangactivationsequencecontextprocessor.h \
|
$$PWD/clangactivationsequencecontextprocessor.h \
|
||||||
@@ -16,5 +16,5 @@ HEADERS += \
|
|||||||
$$PWD/clangcompletioncontextanalyzer.h \
|
$$PWD/clangcompletioncontextanalyzer.h \
|
||||||
$$PWD/clangdiagnosticfilter.h \
|
$$PWD/clangdiagnosticfilter.h \
|
||||||
$$PWD/clangfixitoperation.h \
|
$$PWD/clangfixitoperation.h \
|
||||||
$$PWD/clanghighlightingmarksreporter.h \
|
$$PWD/clangtokeninfosreporter.h \
|
||||||
$$PWD/clangisdiagnosticrelatedtolocation.h
|
$$PWD/clangisdiagnosticrelatedtolocation.h
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include "clangdiagnostictooltipwidget.h"
|
#include "clangdiagnostictooltipwidget.h"
|
||||||
#include "clangfixitoperation.h"
|
#include "clangfixitoperation.h"
|
||||||
#include "clangfixitoperationsextractor.h"
|
#include "clangfixitoperationsextractor.h"
|
||||||
#include "clanghighlightingmarksreporter.h"
|
#include "clangtokeninfosreporter.h"
|
||||||
#include "clangprojectsettings.h"
|
#include "clangprojectsettings.h"
|
||||||
#include "clangutils.h"
|
#include "clangutils.h"
|
||||||
|
|
||||||
@@ -225,14 +225,14 @@ toTextEditorBlocks(QTextDocument *textDocument,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<ClangBackEnd::HighlightingMarkContainer>
|
const QVector<ClangBackEnd::TokenInfoContainer>
|
||||||
&ClangEditorDocumentProcessor::highlightingMarks() const
|
&ClangEditorDocumentProcessor::tokenInfos() const
|
||||||
{
|
{
|
||||||
return m_highlightingMarks;
|
return m_tokenInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangEditorDocumentProcessor::updateHighlighting(
|
void ClangEditorDocumentProcessor::updateHighlighting(
|
||||||
const QVector<ClangBackEnd::HighlightingMarkContainer> &highlightingMarks,
|
const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos,
|
||||||
const QVector<ClangBackEnd::SourceRangeContainer> &skippedPreprocessorRanges,
|
const QVector<ClangBackEnd::SourceRangeContainer> &skippedPreprocessorRanges,
|
||||||
uint documentRevision)
|
uint documentRevision)
|
||||||
{
|
{
|
||||||
@@ -240,10 +240,10 @@ void ClangEditorDocumentProcessor::updateHighlighting(
|
|||||||
const auto skippedPreprocessorBlocks = toTextEditorBlocks(textDocument(), skippedPreprocessorRanges);
|
const auto skippedPreprocessorBlocks = toTextEditorBlocks(textDocument(), skippedPreprocessorRanges);
|
||||||
emit ifdefedOutBlocksUpdated(documentRevision, skippedPreprocessorBlocks);
|
emit ifdefedOutBlocksUpdated(documentRevision, skippedPreprocessorBlocks);
|
||||||
|
|
||||||
m_highlightingMarks = highlightingMarks;
|
m_tokenInfos = tokenInfos;
|
||||||
m_semanticHighlighter.setHighlightingRunner(
|
m_semanticHighlighter.setHighlightingRunner(
|
||||||
[highlightingMarks]() {
|
[tokenInfos]() {
|
||||||
auto *reporter = new HighlightingMarksReporter(highlightingMarks);
|
auto *reporter = new TokenInfosReporter(tokenInfos);
|
||||||
return reporter->start();
|
return reporter->start();
|
||||||
});
|
});
|
||||||
m_semanticHighlighter.run();
|
m_semanticHighlighter.run();
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
class DiagnosticContainer;
|
class DiagnosticContainer;
|
||||||
class HighlightingMarkContainer;
|
class TokenInfoContainer;
|
||||||
class FileContainer;
|
class FileContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
void updateCodeWarnings(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
void updateCodeWarnings(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
||||||
const ClangBackEnd::DiagnosticContainer &firstHeaderErrorDiagnostic,
|
const ClangBackEnd::DiagnosticContainer &firstHeaderErrorDiagnostic,
|
||||||
uint documentRevision);
|
uint documentRevision);
|
||||||
void updateHighlighting(const QVector<ClangBackEnd::HighlightingMarkContainer> &highlightingMarks,
|
void updateHighlighting(const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos,
|
||||||
const QVector<ClangBackEnd::SourceRangeContainer> &skippedPreprocessorRanges,
|
const QVector<ClangBackEnd::SourceRangeContainer> &skippedPreprocessorRanges,
|
||||||
uint documentRevision);
|
uint documentRevision);
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ public:
|
|||||||
|
|
||||||
void clearDiagnosticsWithFixIts();
|
void clearDiagnosticsWithFixIts();
|
||||||
|
|
||||||
const QVector<ClangBackEnd::HighlightingMarkContainer> &highlightingMarks() const;
|
const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ClangEditorDocumentProcessor *get(const QString &filePath);
|
static ClangEditorDocumentProcessor *get(const QString &filePath);
|
||||||
@@ -123,7 +123,7 @@ private:
|
|||||||
QTimer m_updateTranslationUnitTimer;
|
QTimer m_updateTranslationUnitTimer;
|
||||||
unsigned m_parserRevision;
|
unsigned m_parserRevision;
|
||||||
|
|
||||||
QVector<ClangBackEnd::HighlightingMarkContainer> m_highlightingMarks;
|
QVector<ClangBackEnd::TokenInfoContainer> m_tokenInfos;
|
||||||
CppTools::SemanticHighlighter m_semanticHighlighter;
|
CppTools::SemanticHighlighter m_semanticHighlighter;
|
||||||
CppTools::BuiltinEditorDocumentProcessor m_builtinProcessor;
|
CppTools::BuiltinEditorDocumentProcessor m_builtinProcessor;
|
||||||
};
|
};
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
|
|
||||||
#include <clangsupport/highlightingmarkcontainer.h>
|
#include <clangsupport/tokeninfocontainer.h>
|
||||||
|
|
||||||
#include <utils/textutils.h>
|
#include <utils/textutils.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -37,13 +37,13 @@ namespace ClangCodeModel {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// Returns invalid Mark if it is not found at (line, column)
|
// Returns invalid Mark if it is not found at (line, column)
|
||||||
static bool findMark(const QVector<ClangBackEnd::HighlightingMarkContainer> &marks,
|
static bool findMark(const QVector<ClangBackEnd::TokenInfoContainer> &marks,
|
||||||
uint line,
|
uint line,
|
||||||
uint column,
|
uint column,
|
||||||
ClangBackEnd::HighlightingMarkContainer &mark)
|
ClangBackEnd::TokenInfoContainer &mark)
|
||||||
{
|
{
|
||||||
mark = Utils::findOrDefault(marks,
|
mark = Utils::findOrDefault(marks,
|
||||||
[line, column](const ClangBackEnd::HighlightingMarkContainer &curMark) {
|
[line, column](const ClangBackEnd::TokenInfoContainer &curMark) {
|
||||||
if (curMark.line() != line)
|
if (curMark.line() != line)
|
||||||
return false;
|
return false;
|
||||||
if (curMark.column() == column)
|
if (curMark.column() == column)
|
||||||
@@ -57,7 +57,7 @@ static bool findMark(const QVector<ClangBackEnd::HighlightingMarkContainer> &mar
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getMarkPos(QTextCursor cursor, const ClangBackEnd::HighlightingMarkContainer &mark)
|
static int getMarkPos(QTextCursor cursor, const ClangBackEnd::TokenInfoContainer &mark)
|
||||||
{
|
{
|
||||||
cursor.setPosition(0);
|
cursor.setPosition(0);
|
||||||
cursor.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, mark.line() - 1);
|
cursor.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, mark.line() - 1);
|
||||||
@@ -70,9 +70,9 @@ static Utils::Link linkAtCursor(QTextCursor cursor, const QString &filePath, uin
|
|||||||
{
|
{
|
||||||
using Link = Utils::Link;
|
using Link = Utils::Link;
|
||||||
|
|
||||||
const QVector<ClangBackEnd::HighlightingMarkContainer> &marks
|
const QVector<ClangBackEnd::TokenInfoContainer> &marks
|
||||||
= processor->highlightingMarks();
|
= processor->tokenInfos();
|
||||||
ClangBackEnd::HighlightingMarkContainer mark;
|
ClangBackEnd::TokenInfoContainer mark;
|
||||||
if (!findMark(marks, line, column, mark))
|
if (!findMark(marks, line, column, mark))
|
||||||
return Link();
|
return Link();
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "clanghighlightingmarksreporter.h"
|
#include "clangtokeninfosreporter.h"
|
||||||
|
|
||||||
#include <texteditor/textstyles.h>
|
#include <texteditor/textstyles.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -97,13 +97,13 @@ TextEditor::TextStyles toTextStyles(ClangBackEnd::HighlightingTypes types)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextEditor::HighlightingResult toHighlightingResult(
|
TextEditor::HighlightingResult toHighlightingResult(
|
||||||
const ClangBackEnd::HighlightingMarkContainer &highlightingMark)
|
const ClangBackEnd::TokenInfoContainer &tokenInfo)
|
||||||
{
|
{
|
||||||
const auto textStyles = toTextStyles(highlightingMark.types());
|
const auto textStyles = toTextStyles(tokenInfo.types());
|
||||||
|
|
||||||
return TextEditor::HighlightingResult(highlightingMark.line(),
|
return TextEditor::HighlightingResult(tokenInfo.line(),
|
||||||
highlightingMark.column(),
|
tokenInfo.column(),
|
||||||
highlightingMark.length(),
|
tokenInfo.length(),
|
||||||
textStyles);
|
textStyles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,14 +111,14 @@ TextEditor::HighlightingResult toHighlightingResult(
|
|||||||
|
|
||||||
namespace ClangCodeModel {
|
namespace ClangCodeModel {
|
||||||
|
|
||||||
HighlightingMarksReporter::HighlightingMarksReporter(
|
TokenInfosReporter::TokenInfosReporter(
|
||||||
const QVector<ClangBackEnd::HighlightingMarkContainer> &highlightingMarks)
|
const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos)
|
||||||
: m_highlightingMarks(highlightingMarks)
|
: m_tokenInfos(tokenInfos)
|
||||||
{
|
{
|
||||||
m_chunksToReport.reserve(m_chunkSize + 1);
|
m_chunksToReport.reserve(m_chunkSize + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMarksReporter::reportChunkWise(
|
void TokenInfosReporter::reportChunkWise(
|
||||||
const TextEditor::HighlightingResult &highlightingResult)
|
const TextEditor::HighlightingResult &highlightingResult)
|
||||||
{
|
{
|
||||||
if (m_chunksToReport.size() >= m_chunkSize) {
|
if (m_chunksToReport.size() >= m_chunkSize) {
|
||||||
@@ -133,7 +133,7 @@ void HighlightingMarksReporter::reportChunkWise(
|
|||||||
m_chunksToReport.append(highlightingResult);
|
m_chunksToReport.append(highlightingResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMarksReporter::reportAndClearCurrentChunks()
|
void TokenInfosReporter::reportAndClearCurrentChunks()
|
||||||
{
|
{
|
||||||
m_flushRequested = false;
|
m_flushRequested = false;
|
||||||
m_flushLine = 0;
|
m_flushLine = 0;
|
||||||
@@ -144,30 +144,30 @@ void HighlightingMarksReporter::reportAndClearCurrentChunks()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMarksReporter::setChunkSize(int chunkSize)
|
void TokenInfosReporter::setChunkSize(int chunkSize)
|
||||||
{
|
{
|
||||||
m_chunkSize = chunkSize;
|
m_chunkSize = chunkSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMarksReporter::run()
|
void TokenInfosReporter::run()
|
||||||
{
|
{
|
||||||
run_internal();
|
run_internal();
|
||||||
reportFinished();
|
reportFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMarksReporter::run_internal()
|
void TokenInfosReporter::run_internal()
|
||||||
{
|
{
|
||||||
if (isCanceled())
|
if (isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using ClangBackEnd::HighlightingType;
|
using ClangBackEnd::HighlightingType;
|
||||||
|
|
||||||
for (const auto &highlightingMark : m_highlightingMarks) {
|
for (const auto &tokenInfo : m_tokenInfos) {
|
||||||
const HighlightingType mainType = highlightingMark.types().mainHighlightingType;
|
const HighlightingType mainType = tokenInfo.types().mainHighlightingType;
|
||||||
if (mainType == HighlightingType::StringLiteral)
|
if (mainType == HighlightingType::StringLiteral)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
reportChunkWise(toHighlightingResult(highlightingMark));
|
reportChunkWise(toHighlightingResult(tokenInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCanceled())
|
if (isCanceled())
|
||||||
@@ -176,7 +176,7 @@ void HighlightingMarksReporter::run_internal()
|
|||||||
reportAndClearCurrentChunks();
|
reportAndClearCurrentChunks();
|
||||||
}
|
}
|
||||||
|
|
||||||
QFuture<TextEditor::HighlightingResult> HighlightingMarksReporter::start()
|
QFuture<TextEditor::HighlightingResult> TokenInfosReporter::start()
|
||||||
{
|
{
|
||||||
this->setRunnable(this);
|
this->setRunnable(this);
|
||||||
this->reportStarted();
|
this->reportStarted();
|
@@ -32,11 +32,11 @@
|
|||||||
|
|
||||||
#include <texteditor/semantichighlighter.h>
|
#include <texteditor/semantichighlighter.h>
|
||||||
|
|
||||||
#include <clangsupport/highlightingmarkcontainer.h>
|
#include <clangsupport/tokeninfocontainer.h>
|
||||||
|
|
||||||
namespace ClangCodeModel {
|
namespace ClangCodeModel {
|
||||||
|
|
||||||
class HighlightingMarksReporter:
|
class TokenInfosReporter:
|
||||||
public QObject,
|
public QObject,
|
||||||
public QRunnable,
|
public QRunnable,
|
||||||
public QFutureInterface<TextEditor::HighlightingResult>
|
public QFutureInterface<TextEditor::HighlightingResult>
|
||||||
@@ -44,7 +44,7 @@ class HighlightingMarksReporter:
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HighlightingMarksReporter(const QVector<ClangBackEnd::HighlightingMarkContainer> &highlightingMarks);
|
TokenInfosReporter(const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos);
|
||||||
|
|
||||||
void setChunkSize(int chunkSize);
|
void setChunkSize(int chunkSize);
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ private:
|
|||||||
void reportAndClearCurrentChunks();
|
void reportAndClearCurrentChunks();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<ClangBackEnd::HighlightingMarkContainer> m_highlightingMarks;
|
QVector<ClangBackEnd::TokenInfoContainer> m_tokenInfos;
|
||||||
QVector<TextEditor::HighlightingResult> m_chunksToReport;
|
QVector<TextEditor::HighlightingResult> m_chunksToReport;
|
||||||
|
|
||||||
int m_chunkSize = 100;
|
int m_chunkSize = 100;
|
@@ -48,14 +48,14 @@ HEADERS += \
|
|||||||
$$PWD/diagnosticset.h \
|
$$PWD/diagnosticset.h \
|
||||||
$$PWD/diagnosticsetiterator.h \
|
$$PWD/diagnosticsetiterator.h \
|
||||||
$$PWD/fixit.h \
|
$$PWD/fixit.h \
|
||||||
$$PWD/highlightingmark.h \
|
|
||||||
$$PWD/highlightingmarks.h \
|
|
||||||
$$PWD/highlightingmarksiterator.h \
|
|
||||||
$$PWD/projectpart.h \
|
$$PWD/projectpart.h \
|
||||||
$$PWD/projects.h \
|
$$PWD/projects.h \
|
||||||
$$PWD/skippedsourceranges.h \
|
$$PWD/skippedsourceranges.h \
|
||||||
$$PWD/sourcelocation.h \
|
$$PWD/sourcelocation.h \
|
||||||
$$PWD/sourcerange.h \
|
$$PWD/sourcerange.h \
|
||||||
|
$$PWD/tokeninfo.h \
|
||||||
|
$$PWD/tokeninfos.h \
|
||||||
|
$$PWD/tokeninfositerator.h \
|
||||||
$$PWD/unsavedfile.h \
|
$$PWD/unsavedfile.h \
|
||||||
$$PWD/unsavedfiles.h \
|
$$PWD/unsavedfiles.h \
|
||||||
$$PWD/utf8positionfromlinecolumn.h
|
$$PWD/utf8positionfromlinecolumn.h
|
||||||
@@ -102,13 +102,13 @@ SOURCES += \
|
|||||||
$$PWD/diagnostic.cpp \
|
$$PWD/diagnostic.cpp \
|
||||||
$$PWD/diagnosticset.cpp \
|
$$PWD/diagnosticset.cpp \
|
||||||
$$PWD/fixit.cpp \
|
$$PWD/fixit.cpp \
|
||||||
$$PWD/highlightingmark.cpp \
|
|
||||||
$$PWD/highlightingmarks.cpp \
|
|
||||||
$$PWD/projectpart.cpp \
|
$$PWD/projectpart.cpp \
|
||||||
$$PWD/projects.cpp \
|
$$PWD/projects.cpp \
|
||||||
$$PWD/skippedsourceranges.cpp \
|
$$PWD/skippedsourceranges.cpp \
|
||||||
$$PWD/sourcelocation.cpp \
|
$$PWD/sourcelocation.cpp \
|
||||||
$$PWD/sourcerange.cpp \
|
$$PWD/sourcerange.cpp \
|
||||||
|
$$PWD/tokeninfo.cpp \
|
||||||
|
$$PWD/tokeninfos.cpp \
|
||||||
$$PWD/unsavedfile.cpp \
|
$$PWD/unsavedfile.cpp \
|
||||||
$$PWD/unsavedfiles.cpp \
|
$$PWD/unsavedfiles.cpp \
|
||||||
$$PWD/utf8positionfromlinecolumn.cpp
|
$$PWD/utf8positionfromlinecolumn.cpp
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#include "clangtranslationunits.h"
|
#include "clangtranslationunits.h"
|
||||||
#include "codecompleter.h"
|
#include "codecompleter.h"
|
||||||
#include "diagnosticset.h"
|
#include "diagnosticset.h"
|
||||||
#include "highlightingmarks.h"
|
#include "tokeninfos.h"
|
||||||
#include "clangexceptions.h"
|
#include "clangexceptions.h"
|
||||||
#include "skippedsourceranges.h"
|
#include "skippedsourceranges.h"
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#include "clangdocuments.h"
|
#include "clangdocuments.h"
|
||||||
|
|
||||||
#include <diagnosticset.h>
|
#include <diagnosticset.h>
|
||||||
#include <highlightingmarks.h>
|
#include <tokeninfos.h>
|
||||||
#include <clangexceptions.h>
|
#include <clangexceptions.h>
|
||||||
#include <projects.h>
|
#include <projects.h>
|
||||||
#include <skippedsourceranges.h>
|
#include <skippedsourceranges.h>
|
||||||
|
@@ -47,7 +47,7 @@ IAsyncJob::AsyncPrepareResult RequestDocumentAnnotationsJob::prepareAsyncRun()
|
|||||||
RequestDocumentAnnotationsJob::AsyncResult asyncResult;
|
RequestDocumentAnnotationsJob::AsyncResult asyncResult;
|
||||||
translationUnit.extractDocumentAnnotations(asyncResult.firstHeaderErrorDiagnostic,
|
translationUnit.extractDocumentAnnotations(asyncResult.firstHeaderErrorDiagnostic,
|
||||||
asyncResult.diagnostics,
|
asyncResult.diagnostics,
|
||||||
asyncResult.highlightingMarks,
|
asyncResult.tokenInfos,
|
||||||
asyncResult.skippedSourceRanges);
|
asyncResult.skippedSourceRanges);
|
||||||
return asyncResult;
|
return asyncResult;
|
||||||
});
|
});
|
||||||
@@ -63,7 +63,7 @@ void RequestDocumentAnnotationsJob::finalizeAsyncRun()
|
|||||||
DocumentAnnotationsChangedMessage(m_pinnedFileContainer,
|
DocumentAnnotationsChangedMessage(m_pinnedFileContainer,
|
||||||
result.diagnostics,
|
result.diagnostics,
|
||||||
result.firstHeaderErrorDiagnostic,
|
result.firstHeaderErrorDiagnostic,
|
||||||
result.highlightingMarks,
|
result.tokenInfos,
|
||||||
result.skippedSourceRanges));
|
result.skippedSourceRanges));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "clangdocumentjob.h"
|
#include "clangdocumentjob.h"
|
||||||
|
|
||||||
#include <clangsupport/diagnosticcontainer.h>
|
#include <clangsupport/diagnosticcontainer.h>
|
||||||
#include <clangsupport/highlightingmarkcontainer.h>
|
#include <clangsupport/tokeninfocontainer.h>
|
||||||
#include <clangsupport/sourcerangecontainer.h>
|
#include <clangsupport/sourcerangecontainer.h>
|
||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
@@ -37,7 +37,7 @@ struct RequestDocumentAnnotationsJobResult
|
|||||||
{
|
{
|
||||||
ClangBackEnd::DiagnosticContainer firstHeaderErrorDiagnostic;
|
ClangBackEnd::DiagnosticContainer firstHeaderErrorDiagnostic;
|
||||||
QVector<ClangBackEnd::DiagnosticContainer> diagnostics;
|
QVector<ClangBackEnd::DiagnosticContainer> diagnostics;
|
||||||
QVector<HighlightingMarkContainer> highlightingMarks;
|
QVector<TokenInfoContainer> tokenInfos;
|
||||||
QVector<SourceRangeContainer> skippedSourceRanges;
|
QVector<SourceRangeContainer> skippedSourceRanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -35,8 +35,8 @@
|
|||||||
#include <cursor.h>
|
#include <cursor.h>
|
||||||
#include <diagnosticcontainer.h>
|
#include <diagnosticcontainer.h>
|
||||||
#include <diagnosticset.h>
|
#include <diagnosticset.h>
|
||||||
#include <highlightingmark.h>
|
#include <tokeninfo.h>
|
||||||
#include <highlightingmarks.h>
|
#include <tokeninfos.h>
|
||||||
#include <skippedsourceranges.h>
|
#include <skippedsourceranges.h>
|
||||||
#include <sourcelocation.h>
|
#include <sourcelocation.h>
|
||||||
#include <sourcerange.h>
|
#include <sourcerange.h>
|
||||||
@@ -131,11 +131,11 @@ TranslationUnit::CodeCompletionResult TranslationUnit::complete(
|
|||||||
void TranslationUnit::extractDocumentAnnotations(
|
void TranslationUnit::extractDocumentAnnotations(
|
||||||
DiagnosticContainer &firstHeaderErrorDiagnostic,
|
DiagnosticContainer &firstHeaderErrorDiagnostic,
|
||||||
QVector<DiagnosticContainer> &mainFileDiagnostics,
|
QVector<DiagnosticContainer> &mainFileDiagnostics,
|
||||||
QVector<HighlightingMarkContainer> &highlightingMarks,
|
QVector<TokenInfoContainer> &tokenInfos,
|
||||||
QVector<SourceRangeContainer> &skippedSourceRanges) const
|
QVector<SourceRangeContainer> &skippedSourceRanges) const
|
||||||
{
|
{
|
||||||
extractDiagnostics(firstHeaderErrorDiagnostic, mainFileDiagnostics);
|
extractDiagnostics(firstHeaderErrorDiagnostic, mainFileDiagnostics);
|
||||||
highlightingMarks = this->highlightingMarks().toHighlightingMarksContainers();
|
tokenInfos = this->tokenInfos().toTokenInfoContainers();
|
||||||
skippedSourceRanges = this->skippedSourceRanges().toSourceRangeContainers();
|
skippedSourceRanges = this->skippedSourceRanges().toSourceRangeContainers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,19 +187,19 @@ Cursor TranslationUnit::cursor() const
|
|||||||
return clang_getTranslationUnitCursor(m_cxTranslationUnit);
|
return clang_getTranslationUnitCursor(m_cxTranslationUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMarks TranslationUnit::highlightingMarks() const
|
TokenInfos TranslationUnit::tokenInfos() const
|
||||||
{
|
{
|
||||||
return highlightingMarksInRange(cursor().sourceRange());
|
return tokenInfosInRange(cursor().sourceRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMarks TranslationUnit::highlightingMarksInRange(const SourceRange &range) const
|
TokenInfos TranslationUnit::tokenInfosInRange(const SourceRange &range) const
|
||||||
{
|
{
|
||||||
CXToken *cxTokens = 0;
|
CXToken *cxTokens = 0;
|
||||||
uint cxTokensCount = 0;
|
uint cxTokensCount = 0;
|
||||||
|
|
||||||
clang_tokenize(m_cxTranslationUnit, range, &cxTokens, &cxTokensCount);
|
clang_tokenize(m_cxTranslationUnit, range, &cxTokens, &cxTokensCount);
|
||||||
|
|
||||||
return HighlightingMarks(m_cxTranslationUnit, cxTokens, cxTokensCount);
|
return TokenInfos(m_cxTranslationUnit, cxTokens, cxTokensCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkippedSourceRanges TranslationUnit::skippedSourceRanges() const
|
SkippedSourceRanges TranslationUnit::skippedSourceRanges() const
|
||||||
|
@@ -34,8 +34,8 @@ namespace ClangBackEnd {
|
|||||||
class Cursor;
|
class Cursor;
|
||||||
class DiagnosticContainer;
|
class DiagnosticContainer;
|
||||||
class DiagnosticSet;
|
class DiagnosticSet;
|
||||||
class HighlightingMarkContainer;
|
class TokenInfoContainer;
|
||||||
class HighlightingMarks;
|
class TokenInfos;
|
||||||
class ReferencesResult;
|
class ReferencesResult;
|
||||||
class SkippedSourceRanges;
|
class SkippedSourceRanges;
|
||||||
class SourceLocation;
|
class SourceLocation;
|
||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
QVector<DiagnosticContainer> &mainFileDiagnostics) const;
|
QVector<DiagnosticContainer> &mainFileDiagnostics) const;
|
||||||
void extractDocumentAnnotations(DiagnosticContainer &firstHeaderErrorDiagnostic,
|
void extractDocumentAnnotations(DiagnosticContainer &firstHeaderErrorDiagnostic,
|
||||||
QVector<DiagnosticContainer> &mainFileDiagnostics,
|
QVector<DiagnosticContainer> &mainFileDiagnostics,
|
||||||
QVector<HighlightingMarkContainer> &highlightingMarks,
|
QVector<TokenInfoContainer> &tokenInfos,
|
||||||
QVector<SourceRangeContainer> &skippedSourceRanges) const;
|
QVector<SourceRangeContainer> &skippedSourceRanges) const;
|
||||||
|
|
||||||
|
|
||||||
@@ -96,8 +96,8 @@ public:
|
|||||||
Cursor cursorAt(const Utf8String &filePath, uint line, uint column) const;
|
Cursor cursorAt(const Utf8String &filePath, uint line, uint column) const;
|
||||||
Cursor cursor() const;
|
Cursor cursor() const;
|
||||||
|
|
||||||
HighlightingMarks highlightingMarks() const;
|
TokenInfos tokenInfos() const;
|
||||||
HighlightingMarks highlightingMarksInRange(const SourceRange &range) const;
|
TokenInfos tokenInfosInRange(const SourceRange &range) const;
|
||||||
|
|
||||||
SkippedSourceRanges skippedSourceRanges() const;
|
SkippedSourceRanges skippedSourceRanges() const;
|
||||||
SourceRangeContainer followSymbol(uint line,
|
SourceRangeContainer followSymbol(uint line,
|
||||||
|
@@ -51,7 +51,7 @@ IAsyncJob::AsyncPrepareResult UpdateDocumentAnnotationsJob::prepareAsyncRun()
|
|||||||
// Collect
|
// Collect
|
||||||
translationUnit.extractDocumentAnnotations(asyncResult.firstHeaderErrorDiagnostic,
|
translationUnit.extractDocumentAnnotations(asyncResult.firstHeaderErrorDiagnostic,
|
||||||
asyncResult.diagnostics,
|
asyncResult.diagnostics,
|
||||||
asyncResult.highlightingMarks,
|
asyncResult.tokenInfos,
|
||||||
asyncResult.skippedSourceRanges);
|
asyncResult.skippedSourceRanges);
|
||||||
|
|
||||||
return asyncResult;
|
return asyncResult;
|
||||||
@@ -70,7 +70,7 @@ void UpdateDocumentAnnotationsJob::finalizeAsyncRun()
|
|||||||
DocumentAnnotationsChangedMessage(m_pinnedFileContainer,
|
DocumentAnnotationsChangedMessage(m_pinnedFileContainer,
|
||||||
result.diagnostics,
|
result.diagnostics,
|
||||||
result.firstHeaderErrorDiagnostic,
|
result.firstHeaderErrorDiagnostic,
|
||||||
result.highlightingMarks,
|
result.tokenInfos,
|
||||||
result.skippedSourceRanges));
|
result.skippedSourceRanges));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "clangdocumentjob.h"
|
#include "clangdocumentjob.h"
|
||||||
|
|
||||||
#include <clangsupport/diagnosticcontainer.h>
|
#include <clangsupport/diagnosticcontainer.h>
|
||||||
#include <clangsupport/highlightingmarkcontainer.h>
|
#include <clangsupport/tokeninfocontainer.h>
|
||||||
#include <clangsupport/sourcerangecontainer.h>
|
#include <clangsupport/sourcerangecontainer.h>
|
||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
@@ -39,7 +39,7 @@ struct UpdateDocumentAnnotationsJobResult
|
|||||||
|
|
||||||
ClangBackEnd::DiagnosticContainer firstHeaderErrorDiagnostic;
|
ClangBackEnd::DiagnosticContainer firstHeaderErrorDiagnostic;
|
||||||
QVector<ClangBackEnd::DiagnosticContainer> diagnostics;
|
QVector<ClangBackEnd::DiagnosticContainer> diagnostics;
|
||||||
QVector<HighlightingMarkContainer> highlightingMarks;
|
QVector<TokenInfoContainer> tokenInfos;
|
||||||
QVector<SourceRangeContainer> skippedSourceRanges;
|
QVector<SourceRangeContainer> skippedSourceRanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -23,11 +23,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <highlightingmarkcontainer.h>
|
#include <tokeninfocontainer.h>
|
||||||
|
|
||||||
#include "clangstring.h"
|
#include "clangstring.h"
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
#include "highlightingmark.h"
|
#include "tokeninfo.h"
|
||||||
#include "sourcelocation.h"
|
#include "sourcelocation.h"
|
||||||
#include "sourcerange.h"
|
#include "sourcerange.h"
|
||||||
#include "sourcerangecontainer.h"
|
#include "sourcerangecontainer.h"
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
HighlightingMark::HighlightingMark(const CXCursor &cxCursor,
|
TokenInfo::TokenInfo(const CXCursor &cxCursor,
|
||||||
CXToken *cxToken,
|
CXToken *cxToken,
|
||||||
CXTranslationUnit cxTranslationUnit,
|
CXTranslationUnit cxTranslationUnit,
|
||||||
std::vector<CXSourceRange> ¤tOutputArgumentRanges)
|
std::vector<CXSourceRange> ¤tOutputArgumentRanges)
|
||||||
@@ -57,7 +57,7 @@ HighlightingMark::HighlightingMark(const CXCursor &cxCursor,
|
|||||||
collectKinds(cxTranslationUnit, cxToken, m_originalCursor);
|
collectKinds(cxTranslationUnit, cxToken, m_originalCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMark::HighlightingMark(uint line, uint column, uint length, HighlightingTypes types)
|
TokenInfo::TokenInfo(uint line, uint column, uint length, HighlightingTypes types)
|
||||||
: m_line(line),
|
: m_line(line),
|
||||||
m_column(column),
|
m_column(column),
|
||||||
m_length(length),
|
m_length(length),
|
||||||
@@ -65,7 +65,7 @@ HighlightingMark::HighlightingMark(uint line, uint column, uint length, Highligh
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMark::HighlightingMark(uint line, uint column, uint length, HighlightingType type)
|
TokenInfo::TokenInfo(uint line, uint column, uint length, HighlightingType type)
|
||||||
: m_line(line),
|
: m_line(line),
|
||||||
m_column(column),
|
m_column(column),
|
||||||
m_length(length),
|
m_length(length),
|
||||||
@@ -74,21 +74,21 @@ HighlightingMark::HighlightingMark(uint line, uint column, uint length, Highligh
|
|||||||
m_types.mainHighlightingType = type;
|
m_types.mainHighlightingType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::hasInvalidMainType() const
|
bool TokenInfo::hasInvalidMainType() const
|
||||||
{
|
{
|
||||||
return m_types.mainHighlightingType == HighlightingType::Invalid;
|
return m_types.mainHighlightingType == HighlightingType::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::hasMainType(HighlightingType type) const
|
bool TokenInfo::hasMainType(HighlightingType type) const
|
||||||
{
|
{
|
||||||
return m_types.mainHighlightingType == type;
|
return m_types.mainHighlightingType == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned HighlightingMark::mixinSize() const {
|
unsigned TokenInfo::mixinSize() const {
|
||||||
return m_types.mixinHighlightingTypes.size();
|
return m_types.mixinHighlightingTypes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::hasMixinType(HighlightingType type) const
|
bool TokenInfo::hasMixinType(HighlightingType type) const
|
||||||
{
|
{
|
||||||
auto found = std::find(m_types.mixinHighlightingTypes.begin(),
|
auto found = std::find(m_types.mixinHighlightingTypes.begin(),
|
||||||
m_types.mixinHighlightingTypes.end(),
|
m_types.mixinHighlightingTypes.end(),
|
||||||
@@ -97,25 +97,25 @@ bool HighlightingMark::hasMixinType(HighlightingType type) const
|
|||||||
return found != m_types.mixinHighlightingTypes.end();
|
return found != m_types.mixinHighlightingTypes.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::hasMixinTypeAt(uint position, HighlightingType type) const
|
bool TokenInfo::hasMixinTypeAt(uint position, HighlightingType type) const
|
||||||
{
|
{
|
||||||
return m_types.mixinHighlightingTypes.size() > position &&
|
return m_types.mixinHighlightingTypes.size() > position &&
|
||||||
m_types.mixinHighlightingTypes.at(position) == type;
|
m_types.mixinHighlightingTypes.at(position) == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::hasOnlyType(HighlightingType type) const
|
bool TokenInfo::hasOnlyType(HighlightingType type) const
|
||||||
{
|
{
|
||||||
return m_types.mixinHighlightingTypes.size() == 0 && hasMainType(type);
|
return m_types.mixinHighlightingTypes.size() == 0 && hasMainType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::hasFunctionArguments() const
|
bool TokenInfo::hasFunctionArguments() const
|
||||||
{
|
{
|
||||||
return m_originalCursor.argumentCount() > 0;
|
return m_originalCursor.argumentCount() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMark::operator HighlightingMarkContainer() const
|
TokenInfo::operator TokenInfoContainer() const
|
||||||
{
|
{
|
||||||
return HighlightingMarkContainer(m_line, m_column, m_length, m_types, m_isIdentifier,
|
return TokenInfoContainer(m_line, m_column, m_length, m_types, m_isIdentifier,
|
||||||
m_isInclusion);
|
m_isInclusion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ bool isFunctionInFinalClass(const Cursor &cursor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::memberReferenceKind(const Cursor &cursor)
|
void TokenInfo::memberReferenceKind(const Cursor &cursor)
|
||||||
{
|
{
|
||||||
if (cursor.isDynamicCall()) {
|
if (cursor.isDynamicCall()) {
|
||||||
if (isFinalFunction(cursor) || isFunctionInFinalClass(cursor))
|
if (isFinalFunction(cursor) || isFunctionInFinalClass(cursor))
|
||||||
@@ -152,7 +152,7 @@ void HighlightingMark::memberReferenceKind(const Cursor &cursor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::referencedTypeKind(const Cursor &cursor)
|
void TokenInfo::referencedTypeKind(const Cursor &cursor)
|
||||||
{
|
{
|
||||||
const Cursor referencedCursor = cursor.referenced();
|
const Cursor referencedCursor = cursor.referenced();
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ void HighlightingMark::referencedTypeKind(const Cursor &cursor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::overloadedDeclRefKind(const Cursor &cursor)
|
void TokenInfo::overloadedDeclRefKind(const Cursor &cursor)
|
||||||
{
|
{
|
||||||
m_types.mainHighlightingType = HighlightingType::Function;
|
m_types.mainHighlightingType = HighlightingType::Function;
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ void HighlightingMark::overloadedDeclRefKind(const Cursor &cursor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::variableKind(const Cursor &cursor)
|
void TokenInfo::variableKind(const Cursor &cursor)
|
||||||
{
|
{
|
||||||
if (cursor.isLocalVariable())
|
if (cursor.isLocalVariable())
|
||||||
m_types.mainHighlightingType = HighlightingType::LocalVariable;
|
m_types.mainHighlightingType = HighlightingType::LocalVariable;
|
||||||
@@ -193,7 +193,7 @@ void HighlightingMark::variableKind(const Cursor &cursor)
|
|||||||
m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument);
|
m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::fieldKind(const Cursor &)
|
void TokenInfo::fieldKind(const Cursor &)
|
||||||
{
|
{
|
||||||
m_types.mainHighlightingType = HighlightingType::Field;
|
m_types.mainHighlightingType = HighlightingType::Field;
|
||||||
|
|
||||||
@@ -201,12 +201,12 @@ void HighlightingMark::fieldKind(const Cursor &)
|
|||||||
m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument);
|
m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::isDefinition() const
|
bool TokenInfo::isDefinition() const
|
||||||
{
|
{
|
||||||
return m_originalCursor.isDefinition();
|
return m_originalCursor.isDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::isVirtualMethodDeclarationOrDefinition(const Cursor &cursor) const
|
bool TokenInfo::isVirtualMethodDeclarationOrDefinition(const Cursor &cursor) const
|
||||||
{
|
{
|
||||||
return cursor.isVirtualMethod()
|
return cursor.isVirtualMethod()
|
||||||
&& (m_originalCursor.isDeclaration() || m_originalCursor.isDefinition());
|
&& (m_originalCursor.isDeclaration() || m_originalCursor.isDefinition());
|
||||||
@@ -218,19 +218,19 @@ bool isNotFinalFunction(const Cursor &cursor)
|
|||||||
return !cursor.hasFinalFunctionAttribute();
|
return !cursor.hasFinalFunctionAttribute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool HighlightingMark::isRealDynamicCall(const Cursor &cursor) const
|
bool TokenInfo::isRealDynamicCall(const Cursor &cursor) const
|
||||||
{
|
{
|
||||||
return m_originalCursor.isDynamicCall() && isNotFinalFunction(cursor);
|
return m_originalCursor.isDynamicCall() && isNotFinalFunction(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::addExtraTypeIfFirstPass(HighlightingType type,
|
void TokenInfo::addExtraTypeIfFirstPass(HighlightingType type,
|
||||||
Recursion recursion)
|
Recursion recursion)
|
||||||
{
|
{
|
||||||
if (recursion == Recursion::FirstPass)
|
if (recursion == Recursion::FirstPass)
|
||||||
m_types.mixinHighlightingTypes.push_back(type);
|
m_types.mixinHighlightingTypes.push_back(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::isArgumentInCurrentOutputArgumentLocations() const
|
bool TokenInfo::isArgumentInCurrentOutputArgumentLocations() const
|
||||||
{
|
{
|
||||||
auto originalSourceLocation = m_originalCursor.cxSourceLocation();
|
auto originalSourceLocation = m_originalCursor.cxSourceLocation();
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ bool HighlightingMark::isArgumentInCurrentOutputArgumentLocations() const
|
|||||||
return isOutputArgument;
|
return isOutputArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMark::isOutputArgument() const
|
bool TokenInfo::isOutputArgument() const
|
||||||
{
|
{
|
||||||
if (m_currentOutputArgumentRanges->empty())
|
if (m_currentOutputArgumentRanges->empty())
|
||||||
return false;
|
return false;
|
||||||
@@ -256,7 +256,7 @@ bool HighlightingMark::isOutputArgument() const
|
|||||||
return isArgumentInCurrentOutputArgumentLocations();
|
return isArgumentInCurrentOutputArgumentLocations();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::collectOutputArguments(const Cursor &cursor)
|
void TokenInfo::collectOutputArguments(const Cursor &cursor)
|
||||||
{
|
{
|
||||||
cursor.collectOutputArgumentRangesTo(*m_currentOutputArgumentRanges);
|
cursor.collectOutputArgumentRangesTo(*m_currentOutputArgumentRanges);
|
||||||
filterOutPreviousOutputArguments();
|
filterOutPreviousOutputArguments();
|
||||||
@@ -276,7 +276,7 @@ uint getEnd(CXSourceRange cxSourceRange)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::filterOutPreviousOutputArguments()
|
void TokenInfo::filterOutPreviousOutputArguments()
|
||||||
{
|
{
|
||||||
auto isAfterLocation = [this] (CXSourceRange outputRange) {
|
auto isAfterLocation = [this] (CXSourceRange outputRange) {
|
||||||
return getEnd(outputRange) > m_offset;
|
return getEnd(outputRange) > m_offset;
|
||||||
@@ -289,7 +289,7 @@ void HighlightingMark::filterOutPreviousOutputArguments()
|
|||||||
m_currentOutputArgumentRanges->erase(precedingBegin, m_currentOutputArgumentRanges->end());
|
m_currentOutputArgumentRanges->erase(precedingBegin, m_currentOutputArgumentRanges->end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::functionKind(const Cursor &cursor, Recursion recursion)
|
void TokenInfo::functionKind(const Cursor &cursor, Recursion recursion)
|
||||||
{
|
{
|
||||||
if (isRealDynamicCall(cursor) || isVirtualMethodDeclarationOrDefinition(cursor))
|
if (isRealDynamicCall(cursor) || isVirtualMethodDeclarationOrDefinition(cursor))
|
||||||
m_types.mainHighlightingType = HighlightingType::VirtualFunction;
|
m_types.mainHighlightingType = HighlightingType::VirtualFunction;
|
||||||
@@ -305,7 +305,7 @@ void HighlightingMark::functionKind(const Cursor &cursor, Recursion recursion)
|
|||||||
addExtraTypeIfFirstPass(HighlightingType::FunctionDefinition, recursion);
|
addExtraTypeIfFirstPass(HighlightingType::FunctionDefinition, recursion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::identifierKind(const Cursor &cursor, Recursion recursion)
|
void TokenInfo::identifierKind(const Cursor &cursor, Recursion recursion)
|
||||||
{
|
{
|
||||||
m_isIdentifier = (cursor.kind() != CXCursor_PreprocessingDirective);
|
m_isIdentifier = (cursor.kind() != CXCursor_PreprocessingDirective);
|
||||||
|
|
||||||
@@ -398,7 +398,7 @@ HighlightingType operatorKind(const Cursor &cursor)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingType HighlightingMark::punctuationKind(const Cursor &cursor)
|
HighlightingType TokenInfo::punctuationKind(const Cursor &cursor)
|
||||||
{
|
{
|
||||||
HighlightingType highlightingType = HighlightingType::Invalid;
|
HighlightingType highlightingType = HighlightingType::Invalid;
|
||||||
|
|
||||||
@@ -445,7 +445,7 @@ static HighlightingType highlightingTypeForKeyword(CXTranslationUnit cxTranslati
|
|||||||
return HighlightingType::Keyword;
|
return HighlightingType::Keyword;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMark::collectKinds(CXTranslationUnit cxTranslationUnit,
|
void TokenInfo::collectKinds(CXTranslationUnit cxTranslationUnit,
|
||||||
CXToken *cxToken, const Cursor &cursor)
|
CXToken *cxToken, const Cursor &cursor)
|
||||||
{
|
{
|
||||||
auto cxTokenKind = clang_getTokenKind(*cxToken);
|
auto cxTokenKind = clang_getTokenKind(*cxToken);
|
||||||
@@ -463,12 +463,12 @@ void HighlightingMark::collectKinds(CXTranslationUnit cxTranslationUnit,
|
|||||||
m_isInclusion = (cursor.kind() == CXCursor_InclusionDirective);
|
m_isInclusion = (cursor.kind() == CXCursor_InclusionDirective);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const HighlightingMark& highlightingMark)
|
std::ostream &operator<<(std::ostream &os, const TokenInfo& tokenInfo)
|
||||||
{
|
{
|
||||||
os << "(type: " << highlightingMark.m_types << ", "
|
os << "(type: " << tokenInfo.m_types << ", "
|
||||||
<< " line: " << highlightingMark.m_line << ", "
|
<< " line: " << tokenInfo.m_line << ", "
|
||||||
<< " column: " << highlightingMark.m_column << ", "
|
<< " column: " << tokenInfo.m_column << ", "
|
||||||
<< " length: " << highlightingMark.m_length
|
<< " length: " << tokenInfo.m_length
|
||||||
<< ")";
|
<< ")";
|
||||||
|
|
||||||
return os;
|
return os;
|
@@ -26,7 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <clangsupport_global.h>
|
#include <clangsupport_global.h>
|
||||||
#include <highlightingmarkcontainer.h>
|
#include <tokeninfocontainer.h>
|
||||||
|
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
|
|
||||||
@@ -34,9 +34,9 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
class HighlightingMark
|
class TokenInfo
|
||||||
{
|
{
|
||||||
friend bool operator==(const HighlightingMark &first, const HighlightingMark &second);
|
friend bool operator==(const TokenInfo &first, const TokenInfo &second);
|
||||||
|
|
||||||
enum class Recursion {
|
enum class Recursion {
|
||||||
FirstPass,
|
FirstPass,
|
||||||
@@ -44,12 +44,12 @@ class HighlightingMark
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HighlightingMark(const CXCursor &cxCursor,
|
TokenInfo(const CXCursor &cxCursor,
|
||||||
CXToken *cxToken,
|
CXToken *cxToken,
|
||||||
CXTranslationUnit cxTranslationUnit,
|
CXTranslationUnit cxTranslationUnit,
|
||||||
std::vector<CXSourceRange> &m_currentOutputArgumentRanges);
|
std::vector<CXSourceRange> &m_currentOutputArgumentRanges);
|
||||||
HighlightingMark(uint m_line, uint m_column, uint m_length, HighlightingTypes m_types);
|
TokenInfo(uint m_line, uint m_column, uint m_length, HighlightingTypes m_types);
|
||||||
HighlightingMark(uint m_line, uint m_column, uint m_length, HighlightingType type);
|
TokenInfo(uint m_line, uint m_column, uint m_length, HighlightingType type);
|
||||||
|
|
||||||
bool hasInvalidMainType() const;
|
bool hasInvalidMainType() const;
|
||||||
bool hasMainType(HighlightingType type) const;
|
bool hasMainType(HighlightingType type) const;
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
bool hasOnlyType(HighlightingType type) const;
|
bool hasOnlyType(HighlightingType type) const;
|
||||||
bool hasFunctionArguments() const;
|
bool hasFunctionArguments() const;
|
||||||
|
|
||||||
operator HighlightingMarkContainer() const;
|
operator TokenInfoContainer() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void identifierKind(const Cursor &cursor, Recursion recursion);
|
void identifierKind(const Cursor &cursor, Recursion recursion);
|
||||||
@@ -80,7 +80,7 @@ private:
|
|||||||
void filterOutPreviousOutputArguments();
|
void filterOutPreviousOutputArguments();
|
||||||
bool isArgumentInCurrentOutputArgumentLocations() const;
|
bool isArgumentInCurrentOutputArgumentLocations() const;
|
||||||
|
|
||||||
friend std::ostream &operator<<(std::ostream &os, const HighlightingMark& highlightingMark);
|
friend std::ostream &operator<<(std::ostream &os, const TokenInfo& tokenInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<CXSourceRange> *m_currentOutputArgumentRanges = nullptr;
|
std::vector<CXSourceRange> *m_currentOutputArgumentRanges = nullptr;
|
||||||
@@ -95,7 +95,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline bool operator==(const HighlightingMark &first, const HighlightingMark &second)
|
inline bool operator==(const TokenInfo &first, const TokenInfo &second)
|
||||||
{
|
{
|
||||||
return first.m_line == second.m_line
|
return first.m_line == second.m_line
|
||||||
&& first.m_column == second.m_column
|
&& first.m_column == second.m_column
|
@@ -23,15 +23,15 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "highlightingmarks.h"
|
#include "tokeninfos.h"
|
||||||
|
|
||||||
#include "highlightingmarkcontainer.h"
|
#include "tokeninfocontainer.h"
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
HighlightingMarks::HighlightingMarks(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount)
|
TokenInfos::TokenInfos(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount)
|
||||||
: cxTranslationUnit(cxTranslationUnit),
|
: cxTranslationUnit(cxTranslationUnit),
|
||||||
cxToken(tokens),
|
cxToken(tokens),
|
||||||
cxTokenCount(tokensCount)
|
cxTokenCount(tokensCount)
|
||||||
@@ -40,12 +40,12 @@ HighlightingMarks::HighlightingMarks(CXTranslationUnit cxTranslationUnit, CXToke
|
|||||||
clang_annotateTokens(cxTranslationUnit, cxToken, cxTokenCount, cxCursor.data());
|
clang_annotateTokens(cxTranslationUnit, cxToken, cxTokenCount, cxCursor.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMarks::~HighlightingMarks()
|
TokenInfos::~TokenInfos()
|
||||||
{
|
{
|
||||||
clang_disposeTokens(cxTranslationUnit, cxToken, cxTokenCount);
|
clang_disposeTokens(cxTranslationUnit, cxToken, cxTokenCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMarks::const_iterator HighlightingMarks::begin() const
|
TokenInfos::const_iterator TokenInfos::begin() const
|
||||||
{
|
{
|
||||||
return const_iterator(cxCursor.cbegin(),
|
return const_iterator(cxCursor.cbegin(),
|
||||||
cxToken,
|
cxToken,
|
||||||
@@ -53,7 +53,7 @@ HighlightingMarks::const_iterator HighlightingMarks::begin() const
|
|||||||
currentOutputArgumentRanges);
|
currentOutputArgumentRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMarks::const_iterator HighlightingMarks::end() const
|
TokenInfos::const_iterator TokenInfos::end() const
|
||||||
{
|
{
|
||||||
return const_iterator(cxCursor.cend(),
|
return const_iterator(cxCursor.cend(),
|
||||||
cxToken + cxTokenCount,
|
cxToken + cxTokenCount,
|
||||||
@@ -61,56 +61,56 @@ HighlightingMarks::const_iterator HighlightingMarks::end() const
|
|||||||
currentOutputArgumentRanges);
|
currentOutputArgumentRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<HighlightingMarkContainer> HighlightingMarks::toHighlightingMarksContainers() const
|
QVector<TokenInfoContainer> TokenInfos::toTokenInfoContainers() const
|
||||||
{
|
{
|
||||||
QVector<HighlightingMarkContainer> containers;
|
QVector<TokenInfoContainer> containers;
|
||||||
containers.reserve(size());
|
containers.reserve(size());
|
||||||
|
|
||||||
const auto isValidHighlightMark = [] (const HighlightingMark &highlightMark) {
|
const auto isValidTokenInfo = [] (const TokenInfo &tokenInfo) {
|
||||||
return !highlightMark.hasInvalidMainType()
|
return !tokenInfo.hasInvalidMainType()
|
||||||
&& !highlightMark.hasMainType(HighlightingType::NumberLiteral)
|
&& !tokenInfo.hasMainType(HighlightingType::NumberLiteral)
|
||||||
&& !highlightMark.hasMainType(HighlightingType::Comment);
|
&& !tokenInfo.hasMainType(HighlightingType::Comment);
|
||||||
};
|
};
|
||||||
for (const HighlightingMark &highlightMark : *this)
|
for (const TokenInfo &tokenInfo : *this)
|
||||||
if (isValidHighlightMark(highlightMark))
|
if (isValidTokenInfo(tokenInfo))
|
||||||
containers.push_back(highlightMark);
|
containers.push_back(tokenInfo);
|
||||||
|
|
||||||
return containers;
|
return containers;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMarks::currentOutputArgumentRangesAreEmpty() const
|
bool TokenInfos::currentOutputArgumentRangesAreEmpty() const
|
||||||
{
|
{
|
||||||
return currentOutputArgumentRanges.empty();
|
return currentOutputArgumentRanges.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HighlightingMarks::isEmpty() const
|
bool TokenInfos::isEmpty() const
|
||||||
{
|
{
|
||||||
return cxTokenCount == 0;
|
return cxTokenCount == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClangBackEnd::HighlightingMarks::isNull() const
|
bool ClangBackEnd::TokenInfos::isNull() const
|
||||||
{
|
{
|
||||||
return cxToken == nullptr;
|
return cxToken == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint HighlightingMarks::size() const
|
uint TokenInfos::size() const
|
||||||
{
|
{
|
||||||
return cxTokenCount;
|
return cxTokenCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMark HighlightingMarks::operator[](size_t index) const
|
TokenInfo TokenInfos::operator[](size_t index) const
|
||||||
{
|
{
|
||||||
return HighlightingMark(cxCursor[index],
|
return TokenInfo(cxCursor[index],
|
||||||
cxToken + index,
|
cxToken + index,
|
||||||
cxTranslationUnit,
|
cxTranslationUnit,
|
||||||
currentOutputArgumentRanges);
|
currentOutputArgumentRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const HighlightingMarks &marks)
|
std::ostream &operator<<(std::ostream &out, const TokenInfos &marks)
|
||||||
{
|
{
|
||||||
out << "[";
|
out << "[";
|
||||||
|
|
||||||
for (const HighlightingMark entry : marks)
|
for (const TokenInfo entry : marks)
|
||||||
out << entry;
|
out << entry;
|
||||||
|
|
||||||
out << "]";
|
out << "]";
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "highlightingmarksiterator.h"
|
#include "tokeninfositerator.h"
|
||||||
|
|
||||||
#include <clang-c/Index.h>
|
#include <clang-c/Index.h>
|
||||||
|
|
||||||
@@ -34,29 +34,29 @@
|
|||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
using uint = unsigned int;
|
using uint = unsigned int;
|
||||||
class HighlightingMarkContainer;
|
class TokenInfoContainer;
|
||||||
|
|
||||||
class HighlightingMarks
|
class TokenInfos
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using const_iterator = HighlightingMarksIterator;
|
using const_iterator = TokenInfosIterator;
|
||||||
using value_type = HighlightingMark;
|
using value_type = TokenInfo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HighlightingMarks() = default;
|
TokenInfos() = default;
|
||||||
HighlightingMarks(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount);
|
TokenInfos(CXTranslationUnit cxTranslationUnit, CXToken *tokens, uint tokensCount);
|
||||||
~HighlightingMarks();
|
~TokenInfos();
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
uint size() const;
|
uint size() const;
|
||||||
|
|
||||||
HighlightingMark operator[](size_t index) const;
|
TokenInfo operator[](size_t index) const;
|
||||||
|
|
||||||
const_iterator begin() const;
|
const_iterator begin() const;
|
||||||
const_iterator end() const;
|
const_iterator end() const;
|
||||||
|
|
||||||
QVector<HighlightingMarkContainer> toHighlightingMarksContainers() const;
|
QVector<TokenInfoContainer> toTokenInfoContainers() const;
|
||||||
|
|
||||||
bool currentOutputArgumentRangesAreEmpty() const;
|
bool currentOutputArgumentRangesAreEmpty() const;
|
||||||
|
|
||||||
@@ -69,6 +69,6 @@ private:
|
|||||||
std::vector<CXCursor> cxCursor;
|
std::vector<CXCursor> cxCursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const HighlightingMarks &marks);
|
std::ostream &operator<<(std::ostream &out, const TokenInfos &marks);
|
||||||
|
|
||||||
} // namespace ClangBackEnd
|
} // namespace ClangBackEnd
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "highlightingmark.h"
|
#include "tokeninfo.h"
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -39,10 +39,10 @@ using uint = unsigned int;
|
|||||||
class DiagnosticSet;
|
class DiagnosticSet;
|
||||||
class Diagnostic;
|
class Diagnostic;
|
||||||
|
|
||||||
class HighlightingMarksIterator : public std::iterator<std::forward_iterator_tag, HighlightingMark, uint>
|
class TokenInfosIterator : public std::iterator<std::forward_iterator_tag, TokenInfo, uint>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HighlightingMarksIterator(std::vector<CXCursor>::const_iterator cxCursorIterator,
|
TokenInfosIterator(std::vector<CXCursor>::const_iterator cxCursorIterator,
|
||||||
CXToken *cxToken,
|
CXToken *cxToken,
|
||||||
CXTranslationUnit cxTranslationUnit,
|
CXTranslationUnit cxTranslationUnit,
|
||||||
std::vector<CXSourceRange> ¤tOutputArgumentRanges)
|
std::vector<CXSourceRange> ¤tOutputArgumentRanges)
|
||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
currentOutputArgumentRanges(currentOutputArgumentRanges)
|
currentOutputArgumentRanges(currentOutputArgumentRanges)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
HighlightingMarksIterator& operator++()
|
TokenInfosIterator& operator++()
|
||||||
{
|
{
|
||||||
++cxCursorIterator;
|
++cxCursorIterator;
|
||||||
++cxToken;
|
++cxToken;
|
||||||
@@ -60,27 +60,27 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMarksIterator operator++(int)
|
TokenInfosIterator operator++(int)
|
||||||
{
|
{
|
||||||
return HighlightingMarksIterator(cxCursorIterator++,
|
return TokenInfosIterator(cxCursorIterator++,
|
||||||
cxToken++,
|
cxToken++,
|
||||||
cxTranslationUnit,
|
cxTranslationUnit,
|
||||||
currentOutputArgumentRanges);
|
currentOutputArgumentRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(HighlightingMarksIterator other) const
|
bool operator==(TokenInfosIterator other) const
|
||||||
{
|
{
|
||||||
return cxCursorIterator == other.cxCursorIterator;
|
return cxCursorIterator == other.cxCursorIterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(HighlightingMarksIterator other) const
|
bool operator!=(TokenInfosIterator other) const
|
||||||
{
|
{
|
||||||
return cxCursorIterator != other.cxCursorIterator;
|
return cxCursorIterator != other.cxCursorIterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightingMark operator*()
|
TokenInfo operator*()
|
||||||
{
|
{
|
||||||
return HighlightingMark(*cxCursorIterator,
|
return TokenInfo(*cxCursorIterator,
|
||||||
cxToken,
|
cxToken,
|
||||||
cxTranslationUnit,
|
cxTranslationUnit,
|
||||||
currentOutputArgumentRanges);
|
currentOutputArgumentRanges);
|
@@ -29,7 +29,7 @@
|
|||||||
#include "processevents-utilities.h"
|
#include "processevents-utilities.h"
|
||||||
|
|
||||||
#include <clangcodemodelserver.h>
|
#include <clangcodemodelserver.h>
|
||||||
#include <highlightingmarkcontainer.h>
|
#include <tokeninfocontainer.h>
|
||||||
#include <clangcodemodelclientproxy.h>
|
#include <clangcodemodelclientproxy.h>
|
||||||
#include <clangcodemodelserverproxy.h>
|
#include <clangcodemodelserverproxy.h>
|
||||||
#include <clangtranslationunits.h>
|
#include <clangtranslationunits.h>
|
||||||
@@ -630,12 +630,12 @@ void ClangCodeModelServer::expectDocumentAnnotationsChangedForFileBWithSpecificH
|
|||||||
types.mainHighlightingType = ClangBackEnd::HighlightingType::Function;
|
types.mainHighlightingType = ClangBackEnd::HighlightingType::Function;
|
||||||
types.mixinHighlightingTypes.push_back(ClangBackEnd::HighlightingType::Declaration);
|
types.mixinHighlightingTypes.push_back(ClangBackEnd::HighlightingType::Declaration);
|
||||||
types.mixinHighlightingTypes.push_back(ClangBackEnd::HighlightingType::FunctionDefinition);
|
types.mixinHighlightingTypes.push_back(ClangBackEnd::HighlightingType::FunctionDefinition);
|
||||||
const HighlightingMarkContainer highlightingMark(1, 6, 8, types, true);
|
const TokenInfoContainer tokenInfo(1, 6, 8, types, true);
|
||||||
|
|
||||||
EXPECT_CALL(mockClangCodeModelClient,
|
EXPECT_CALL(mockClangCodeModelClient,
|
||||||
documentAnnotationsChanged(
|
documentAnnotationsChanged(
|
||||||
Property(&DocumentAnnotationsChangedMessage::highlightingMarks,
|
Property(&DocumentAnnotationsChangedMessage::tokenInfos,
|
||||||
Contains(highlightingMark))))
|
Contains(tokenInfo))))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
#include <clangtranslationunit.h>
|
#include <clangtranslationunit.h>
|
||||||
#include <commandlinearguments.h>
|
#include <commandlinearguments.h>
|
||||||
#include <diagnosticset.h>
|
#include <diagnosticset.h>
|
||||||
#include <highlightingmarks.h>
|
#include <tokeninfos.h>
|
||||||
#include <filecontainer.h>
|
#include <filecontainer.h>
|
||||||
#include <projectpart.h>
|
#include <projectpart.h>
|
||||||
#include <projectpartcontainer.h>
|
#include <projectpartcontainer.h>
|
||||||
|
@@ -227,7 +227,7 @@ TEST_F(ClientServerInProcess, UpdateVisibleTranslationUnitsMessage)
|
|||||||
|
|
||||||
TEST_F(ClientServerInProcess, SendDocumentAnnotationsChangedMessage)
|
TEST_F(ClientServerInProcess, SendDocumentAnnotationsChangedMessage)
|
||||||
{
|
{
|
||||||
ClangBackEnd::HighlightingMarkContainer highlightingMark(1, 1, 1, ClangBackEnd::HighlightingType::Keyword);
|
ClangBackEnd::TokenInfoContainer tokenInfo(1, 1, 1, ClangBackEnd::HighlightingType::Keyword);
|
||||||
ClangBackEnd::DiagnosticContainer diagnostic(Utf8StringLiteral("don't do that"),
|
ClangBackEnd::DiagnosticContainer diagnostic(Utf8StringLiteral("don't do that"),
|
||||||
Utf8StringLiteral("warning"),
|
Utf8StringLiteral("warning"),
|
||||||
{Utf8StringLiteral("-Wpadded"), Utf8StringLiteral("-Wno-padded")},
|
{Utf8StringLiteral("-Wpadded"), Utf8StringLiteral("-Wno-padded")},
|
||||||
@@ -240,7 +240,7 @@ TEST_F(ClientServerInProcess, SendDocumentAnnotationsChangedMessage)
|
|||||||
ClangBackEnd::DocumentAnnotationsChangedMessage message(fileContainer,
|
ClangBackEnd::DocumentAnnotationsChangedMessage message(fileContainer,
|
||||||
{diagnostic},
|
{diagnostic},
|
||||||
{},
|
{},
|
||||||
{highlightingMark},
|
{tokenInfo},
|
||||||
QVector<SourceRangeContainer>());
|
QVector<SourceRangeContainer>());
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,7 @@
|
|||||||
#include <clangcodemodelservermessages.h>
|
#include <clangcodemodelservermessages.h>
|
||||||
|
|
||||||
#include <diagnosticcontainer.h>
|
#include <diagnosticcontainer.h>
|
||||||
#include <highlightingmarkcontainer.h>
|
#include <tokeninfocontainer.h>
|
||||||
#include <messageenvelop.h>
|
#include <messageenvelop.h>
|
||||||
#include <readmessageblock.h>
|
#include <readmessageblock.h>
|
||||||
#include <writemessageblock.h>
|
#include <writemessageblock.h>
|
||||||
@@ -174,12 +174,12 @@ TEST_F(ReadAndWriteMessageBlock, CompareDocumentAnnotationsChangedMessage)
|
|||||||
{},
|
{},
|
||||||
{});
|
{});
|
||||||
|
|
||||||
ClangBackEnd::HighlightingMarkContainer highlightingMark(1, 1, 1, ClangBackEnd::HighlightingType::Keyword);
|
ClangBackEnd::TokenInfoContainer tokenInfo(1, 1, 1, ClangBackEnd::HighlightingType::Keyword);
|
||||||
|
|
||||||
CompareMessage(ClangBackEnd::DocumentAnnotationsChangedMessage(fileContainer,
|
CompareMessage(ClangBackEnd::DocumentAnnotationsChangedMessage(fileContainer,
|
||||||
{diagnostic},
|
{diagnostic},
|
||||||
{},
|
{},
|
||||||
{highlightingMark},
|
{tokenInfo},
|
||||||
QVector<ClangBackEnd::SourceRangeContainer>()));
|
QVector<ClangBackEnd::SourceRangeContainer>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1267
tests/unit/unittest/tokeninfos-test.cpp
Normal file
1267
tests/unit/unittest/tokeninfos-test.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -30,16 +30,16 @@
|
|||||||
#include <clangdocument.h>
|
#include <clangdocument.h>
|
||||||
#include <clangdocuments.h>
|
#include <clangdocuments.h>
|
||||||
#include <cursor.h>
|
#include <cursor.h>
|
||||||
#include <highlightingmarkcontainer.h>
|
#include <tokeninfocontainer.h>
|
||||||
#include <highlightingmarks.h>
|
#include <tokeninfos.h>
|
||||||
#include <clanghighlightingmarksreporter.h>
|
#include <clangtokeninfosreporter.h>
|
||||||
#include <projectpart.h>
|
#include <projectpart.h>
|
||||||
#include <projects.h>
|
#include <projects.h>
|
||||||
#include <unsavedfiles.h>
|
#include <unsavedfiles.h>
|
||||||
|
|
||||||
using ClangBackEnd::Cursor;
|
using ClangBackEnd::Cursor;
|
||||||
using ClangBackEnd::HighlightingMarks;
|
using ClangBackEnd::TokenInfos;
|
||||||
using ClangBackEnd::HighlightingMarkContainer;
|
using ClangBackEnd::TokenInfoContainer;
|
||||||
using ClangBackEnd::HighlightingType;
|
using ClangBackEnd::HighlightingType;
|
||||||
using ClangBackEnd::Document;
|
using ClangBackEnd::Document;
|
||||||
using ClangBackEnd::Documents;
|
using ClangBackEnd::Documents;
|
||||||
@@ -61,7 +61,7 @@ struct Data {
|
|||||||
documents};
|
documents};
|
||||||
};
|
};
|
||||||
|
|
||||||
class HighlightingMarksReporter : public ::testing::Test
|
class TokenInfosReporter : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void SetUpTestCase();
|
static void SetUpTestCase();
|
||||||
@@ -71,26 +71,26 @@ protected:
|
|||||||
static Data *d;
|
static Data *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
QVector<HighlightingMarkContainer> noHighlightingMarks()
|
QVector<TokenInfoContainer> noTokenInfos()
|
||||||
{
|
{
|
||||||
return QVector<HighlightingMarkContainer>();
|
return QVector<TokenInfoContainer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<HighlightingMarkContainer> generateHighlightingMarks(uint count)
|
QVector<TokenInfoContainer> generateTokenInfos(uint count)
|
||||||
{
|
{
|
||||||
auto container = QVector<HighlightingMarkContainer>();
|
auto container = QVector<TokenInfoContainer>();
|
||||||
|
|
||||||
for (uint i = 0; i < count; ++i) {
|
for (uint i = 0; i < count; ++i) {
|
||||||
const uint line = i + 1;
|
const uint line = i + 1;
|
||||||
container.append(HighlightingMarkContainer(line, 1, 1, HighlightingType::Type));
|
container.append(TokenInfoContainer(line, 1, 1, HighlightingType::Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HighlightingMarksReporter, StartAndFinish)
|
TEST_F(TokenInfosReporter, StartAndFinish)
|
||||||
{
|
{
|
||||||
auto reporter = new ClangCodeModel::HighlightingMarksReporter(noHighlightingMarks());
|
auto reporter = new ClangCodeModel::TokenInfosReporter(noTokenInfos());
|
||||||
|
|
||||||
auto future = reporter->start();
|
auto future = reporter->start();
|
||||||
|
|
||||||
@@ -98,9 +98,9 @@ TEST_F(HighlightingMarksReporter, StartAndFinish)
|
|||||||
ASSERT_THAT(future.isFinished(), true);
|
ASSERT_THAT(future.isFinished(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HighlightingMarksReporter, ReportNothingIfNothingToReport)
|
TEST_F(TokenInfosReporter, ReportNothingIfNothingToReport)
|
||||||
{
|
{
|
||||||
auto reporter = new ClangCodeModel::HighlightingMarksReporter(generateHighlightingMarks(0));
|
auto reporter = new ClangCodeModel::TokenInfosReporter(generateTokenInfos(0));
|
||||||
|
|
||||||
auto future = reporter->start();
|
auto future = reporter->start();
|
||||||
|
|
||||||
@@ -108,9 +108,9 @@ TEST_F(HighlightingMarksReporter, ReportNothingIfNothingToReport)
|
|||||||
ASSERT_THAT(monitor.resultsReadyCounter(), 0L);
|
ASSERT_THAT(monitor.resultsReadyCounter(), 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HighlightingMarksReporter, ReportSingleResultAsOneChunk)
|
TEST_F(TokenInfosReporter, ReportSingleResultAsOneChunk)
|
||||||
{
|
{
|
||||||
auto reporter = new ClangCodeModel::HighlightingMarksReporter(generateHighlightingMarks(1));
|
auto reporter = new ClangCodeModel::TokenInfosReporter(generateTokenInfos(1));
|
||||||
reporter->setChunkSize(1);
|
reporter->setChunkSize(1);
|
||||||
|
|
||||||
auto future = reporter->start();
|
auto future = reporter->start();
|
||||||
@@ -119,9 +119,9 @@ TEST_F(HighlightingMarksReporter, ReportSingleResultAsOneChunk)
|
|||||||
ASSERT_THAT(monitor.resultsReadyCounter(), 1L);
|
ASSERT_THAT(monitor.resultsReadyCounter(), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HighlightingMarksReporter, ReportRestIfChunkSizeNotReached)
|
TEST_F(TokenInfosReporter, ReportRestIfChunkSizeNotReached)
|
||||||
{
|
{
|
||||||
auto reporter = new ClangCodeModel::HighlightingMarksReporter(generateHighlightingMarks(1));
|
auto reporter = new ClangCodeModel::TokenInfosReporter(generateTokenInfos(1));
|
||||||
const int notReachedChunkSize = 100;
|
const int notReachedChunkSize = 100;
|
||||||
reporter->setChunkSize(notReachedChunkSize);
|
reporter->setChunkSize(notReachedChunkSize);
|
||||||
|
|
||||||
@@ -131,9 +131,9 @@ TEST_F(HighlightingMarksReporter, ReportRestIfChunkSizeNotReached)
|
|||||||
ASSERT_THAT(monitor.resultsReadyCounter(), 1L);
|
ASSERT_THAT(monitor.resultsReadyCounter(), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HighlightingMarksReporter, ReportChunksWithoutRest)
|
TEST_F(TokenInfosReporter, ReportChunksWithoutRest)
|
||||||
{
|
{
|
||||||
auto reporter = new ClangCodeModel::HighlightingMarksReporter(generateHighlightingMarks(4));
|
auto reporter = new ClangCodeModel::TokenInfosReporter(generateTokenInfos(4));
|
||||||
reporter->setChunkSize(1);
|
reporter->setChunkSize(1);
|
||||||
|
|
||||||
auto future = reporter->start();
|
auto future = reporter->start();
|
||||||
@@ -142,9 +142,9 @@ TEST_F(HighlightingMarksReporter, ReportChunksWithoutRest)
|
|||||||
ASSERT_THAT(monitor.resultsReadyCounter(), 2L);
|
ASSERT_THAT(monitor.resultsReadyCounter(), 2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HighlightingMarksReporter, ReportSingleChunkAndRest)
|
TEST_F(TokenInfosReporter, ReportSingleChunkAndRest)
|
||||||
{
|
{
|
||||||
auto reporter = new ClangCodeModel::HighlightingMarksReporter(generateHighlightingMarks(5));
|
auto reporter = new ClangCodeModel::TokenInfosReporter(generateTokenInfos(5));
|
||||||
reporter->setChunkSize(2);
|
reporter->setChunkSize(2);
|
||||||
|
|
||||||
auto future = reporter->start();
|
auto future = reporter->start();
|
||||||
@@ -153,14 +153,14 @@ TEST_F(HighlightingMarksReporter, ReportSingleChunkAndRest)
|
|||||||
ASSERT_THAT(monitor.resultsReadyCounter(), 2L);
|
ASSERT_THAT(monitor.resultsReadyCounter(), 2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HighlightingMarksReporter, ReportCompleteLines)
|
TEST_F(TokenInfosReporter, ReportCompleteLines)
|
||||||
{
|
{
|
||||||
QVector<HighlightingMarkContainer> highlightingMarks {
|
QVector<TokenInfoContainer> tokenInfos {
|
||||||
HighlightingMarkContainer(1, 1, 1, HighlightingType::Type),
|
TokenInfoContainer(1, 1, 1, HighlightingType::Type),
|
||||||
HighlightingMarkContainer(1, 2, 1, HighlightingType::Type),
|
TokenInfoContainer(1, 2, 1, HighlightingType::Type),
|
||||||
HighlightingMarkContainer(2, 1, 1, HighlightingType::Type),
|
TokenInfoContainer(2, 1, 1, HighlightingType::Type),
|
||||||
};
|
};
|
||||||
auto reporter = new ClangCodeModel::HighlightingMarksReporter(highlightingMarks);
|
auto reporter = new ClangCodeModel::TokenInfosReporter(tokenInfos);
|
||||||
reporter->setChunkSize(1);
|
reporter->setChunkSize(1);
|
||||||
|
|
||||||
auto future = reporter->start();
|
auto future = reporter->start();
|
||||||
@@ -169,14 +169,14 @@ TEST_F(HighlightingMarksReporter, ReportCompleteLines)
|
|||||||
ASSERT_THAT(monitor.resultsReadyCounter(), 2L);
|
ASSERT_THAT(monitor.resultsReadyCounter(), 2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
Data *HighlightingMarksReporter::d;
|
Data *TokenInfosReporter::d;
|
||||||
|
|
||||||
void HighlightingMarksReporter::SetUpTestCase()
|
void TokenInfosReporter::SetUpTestCase()
|
||||||
{
|
{
|
||||||
d = new Data;
|
d = new Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingMarksReporter::TearDownTestCase()
|
void TokenInfosReporter::TearDownTestCase()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
d = nullptr;
|
d = nullptr;
|
@@ -129,8 +129,6 @@ SOURCES += \
|
|||||||
diagnosticset-test.cpp \
|
diagnosticset-test.cpp \
|
||||||
diagnostic-test.cpp \
|
diagnostic-test.cpp \
|
||||||
fixit-test.cpp \
|
fixit-test.cpp \
|
||||||
highlightingmarksreporter-test.cpp \
|
|
||||||
highlightingmarks-test.cpp \
|
|
||||||
projectpart-test.cpp \
|
projectpart-test.cpp \
|
||||||
senddocumenttracker-test.cpp \
|
senddocumenttracker-test.cpp \
|
||||||
skippedsourceranges-test.cpp \
|
skippedsourceranges-test.cpp \
|
||||||
@@ -142,6 +140,8 @@ SOURCES += \
|
|||||||
sqlitestatement-test.cpp \
|
sqlitestatement-test.cpp \
|
||||||
sqlitetable-test.cpp \
|
sqlitetable-test.cpp \
|
||||||
sqlstatementbuilder-test.cpp \
|
sqlstatementbuilder-test.cpp \
|
||||||
|
tokeninfos-test.cpp \
|
||||||
|
tokeninfosreporter-test.cpp \
|
||||||
translationunitupdater-test.cpp \
|
translationunitupdater-test.cpp \
|
||||||
unsavedfiles-test.cpp \
|
unsavedfiles-test.cpp \
|
||||||
unsavedfile-test.cpp \
|
unsavedfile-test.cpp \
|
||||||
|
Reference in New Issue
Block a user