forked from qt-creator/qt-creator
Clang: Refactor TokenInfos
Remove code duplication. Change-Id: Ib1859f2c3a04f66d0f0b669b4e93a7fc06ab8e61 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -31,8 +31,8 @@ SOURCES += \
|
||||
clangfixitoperationsextractor.cpp \
|
||||
clangfollowsymbol.cpp \
|
||||
clangfunctionhintmodel.cpp \
|
||||
clanghighlightingresultreporter.cpp \
|
||||
clanghoverhandler.cpp \
|
||||
clangtokeninfosreporter.cpp \
|
||||
clangmodelmanagersupport.cpp \
|
||||
clangpreprocessorassistproposalitem.cpp \
|
||||
clangprojectsettings.cpp \
|
||||
@@ -69,6 +69,7 @@ HEADERS += \
|
||||
clangfixitoperationsextractor.h \
|
||||
clangfollowsymbol.h \
|
||||
clangfunctionhintmodel.h \
|
||||
clanghighlightingresultreporter.h \
|
||||
clanghoverhandler.h \
|
||||
clangisdiagnosticrelatedtolocation.h \
|
||||
clangmodelmanagersupport.h \
|
||||
@@ -77,7 +78,6 @@ HEADERS += \
|
||||
clangprojectsettingswidget.h \
|
||||
clangrefactoringengine.h \
|
||||
clangtextmark.h \
|
||||
clangtokeninfosreporter.h \
|
||||
clanguiheaderondiskmanager.h \
|
||||
clangutils.h
|
||||
|
||||
|
||||
@@ -82,10 +82,10 @@ QtcPlugin {
|
||||
"clangfollowsymbol.h",
|
||||
"clangfunctionhintmodel.cpp",
|
||||
"clangfunctionhintmodel.h",
|
||||
"clanghighlightingresultreporter.cpp",
|
||||
"clanghighlightingresultreporter.h",
|
||||
"clanghoverhandler.cpp",
|
||||
"clanghoverhandler.h",
|
||||
"clangtokeninfosreporter.cpp",
|
||||
"clangtokeninfosreporter.h",
|
||||
"clangisdiagnosticrelatedtolocation.h",
|
||||
"clangmodelmanagersupport.cpp",
|
||||
"clangmodelmanagersupport.h",
|
||||
|
||||
@@ -7,7 +7,7 @@ SOURCES += \
|
||||
$$PWD/clangcompletioncontextanalyzer.cpp \
|
||||
$$PWD/clangdiagnosticfilter.cpp \
|
||||
$$PWD/clangfixitoperation.cpp \
|
||||
$$PWD/clangtokeninfosreporter.cpp
|
||||
$$PWD/clanghighlightingresultreporter.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/clangactivationsequencecontextprocessor.h \
|
||||
@@ -16,5 +16,5 @@ HEADERS += \
|
||||
$$PWD/clangcompletioncontextanalyzer.h \
|
||||
$$PWD/clangdiagnosticfilter.h \
|
||||
$$PWD/clangfixitoperation.h \
|
||||
$$PWD/clangtokeninfosreporter.h \
|
||||
$$PWD/clanghighlightingresultreporter.h \
|
||||
$$PWD/clangisdiagnosticrelatedtolocation.h
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "clangfixitoperation.h"
|
||||
#include "clangfixitoperationsextractor.h"
|
||||
#include "clangmodelmanagersupport.h"
|
||||
#include "clangtokeninfosreporter.h"
|
||||
#include "clanghighlightingresultreporter.h"
|
||||
#include "clangprojectsettings.h"
|
||||
#include "clangutils.h"
|
||||
|
||||
@@ -253,7 +253,7 @@ void ClangEditorDocumentProcessor::updateHighlighting(
|
||||
m_tokenInfos = tokenInfos;
|
||||
m_semanticHighlighter.setHighlightingRunner(
|
||||
[tokenInfos]() {
|
||||
auto *reporter = new TokenInfosReporter(tokenInfos);
|
||||
auto *reporter = new HighlightingResultReporter(tokenInfos);
|
||||
return reporter->start();
|
||||
});
|
||||
m_semanticHighlighter.run();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangtokeninfosreporter.h"
|
||||
#include "clanghighlightingresultreporter.h"
|
||||
|
||||
#include <texteditor/textstyles.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -134,14 +134,14 @@ TextEditor::HighlightingResult toHighlightingResult(
|
||||
|
||||
namespace ClangCodeModel {
|
||||
|
||||
TokenInfosReporter::TokenInfosReporter(
|
||||
HighlightingResultReporter::HighlightingResultReporter(
|
||||
const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos)
|
||||
: m_tokenInfos(tokenInfos)
|
||||
{
|
||||
m_chunksToReport.reserve(m_chunkSize + 1);
|
||||
}
|
||||
|
||||
void TokenInfosReporter::reportChunkWise(
|
||||
void HighlightingResultReporter::reportChunkWise(
|
||||
const TextEditor::HighlightingResult &highlightingResult)
|
||||
{
|
||||
if (m_chunksToReport.size() >= m_chunkSize) {
|
||||
@@ -156,7 +156,7 @@ void TokenInfosReporter::reportChunkWise(
|
||||
m_chunksToReport.append(highlightingResult);
|
||||
}
|
||||
|
||||
void TokenInfosReporter::reportAndClearCurrentChunks()
|
||||
void HighlightingResultReporter::reportAndClearCurrentChunks()
|
||||
{
|
||||
m_flushRequested = false;
|
||||
m_flushLine = 0;
|
||||
@@ -167,18 +167,18 @@ void TokenInfosReporter::reportAndClearCurrentChunks()
|
||||
}
|
||||
}
|
||||
|
||||
void TokenInfosReporter::setChunkSize(int chunkSize)
|
||||
void HighlightingResultReporter::setChunkSize(int chunkSize)
|
||||
{
|
||||
m_chunkSize = chunkSize;
|
||||
}
|
||||
|
||||
void TokenInfosReporter::run()
|
||||
void HighlightingResultReporter::run()
|
||||
{
|
||||
run_internal();
|
||||
reportFinished();
|
||||
}
|
||||
|
||||
void TokenInfosReporter::run_internal()
|
||||
void HighlightingResultReporter::run_internal()
|
||||
{
|
||||
if (isCanceled())
|
||||
return;
|
||||
@@ -199,7 +199,7 @@ void TokenInfosReporter::run_internal()
|
||||
reportAndClearCurrentChunks();
|
||||
}
|
||||
|
||||
QFuture<TextEditor::HighlightingResult> TokenInfosReporter::start()
|
||||
QFuture<TextEditor::HighlightingResult> HighlightingResultReporter::start()
|
||||
{
|
||||
this->setRunnable(this);
|
||||
this->reportStarted();
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
namespace ClangCodeModel {
|
||||
|
||||
class TokenInfosReporter:
|
||||
class HighlightingResultReporter:
|
||||
public QObject,
|
||||
public QRunnable,
|
||||
public QFutureInterface<TextEditor::HighlightingResult>
|
||||
@@ -44,7 +44,7 @@ class TokenInfosReporter:
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TokenInfosReporter(const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos);
|
||||
HighlightingResultReporter(const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos);
|
||||
|
||||
void setChunkSize(int chunkSize);
|
||||
|
||||
Reference in New Issue
Block a user