Skip to content
Snippets Groups Projects
Commit 9cddeef0 authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

CppTools: Make use of QLoggingCategory


...for document processing and highlighting.

Change-Id: I31d42a5a5010260643ec76688080fd14a486f7e3
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent 8d6b43bc
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,9 @@ ...@@ -46,7 +46,9 @@
#include <utils/QtConcurrentTools> #include <utils/QtConcurrentTools>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
enum { debug = 0 }; #include <QLoggingCategory>
static Q_LOGGING_CATEGORY(log, "qtc.cpptools.builtineditordocumentprocessor")
namespace { namespace {
...@@ -201,10 +203,7 @@ void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr d ...@@ -201,10 +203,7 @@ void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr d
if (document->editorRevision() != revision()) if (document->editorRevision() != revision())
return; // outdated content, wait for a new document to be parsed return; // outdated content, wait for a new document to be parsed
if (debug) { qCDebug(log) << "document parsed" << document->fileName() << document->editorRevision();
qDebug() << "BuiltinEditorDocumentProcessor: document parsed" << document->fileName()
<< document->editorRevision();
}
// Emit ifdefed out blocks // Emit ifdefed out blocks
const auto ifdefoutBlocks = toTextEditorBlocks(document->skippedBlocks()); const auto ifdefoutBlocks = toTextEditorBlocks(document->skippedBlocks());
...@@ -224,10 +223,8 @@ void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr d ...@@ -224,10 +223,8 @@ void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr d
void BuiltinEditorDocumentProcessor::onSemanticInfoUpdated(const SemanticInfo semanticInfo) void BuiltinEditorDocumentProcessor::onSemanticInfoUpdated(const SemanticInfo semanticInfo)
{ {
if (debug) { qCDebug(log) << "semantic info updated"
qDebug() << "BuiltinEditorDocumentProcessor: semantic info updated"
<< semanticInfo.doc->fileName() << semanticInfo.revision << semanticInfo.complete; << semanticInfo.doc->fileName() << semanticInfo.revision << semanticInfo.complete;
}
emit semanticInfoUpdated(semanticInfo); emit semanticInfoUpdated(semanticInfo);
......
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
using namespace CppTools; using namespace CppTools;
using namespace CppTools::Internal; using namespace CppTools::Internal;
static const bool DumpFileNameWhileParsing = qgetenv("QTC_DUMP_FILENAME_WHILE_PARSING") == "1";
static const bool FindErrorsIndexing = qgetenv("QTC_FIND_ERRORS_INDEXING") == "1"; static const bool FindErrorsIndexing = qgetenv("QTC_FIND_ERRORS_INDEXING") == "1";
namespace { namespace {
...@@ -60,12 +59,8 @@ namespace { ...@@ -60,12 +59,8 @@ namespace {
class ParseParams class ParseParams
{ {
public: public:
ParseParams() ParseParams() : revision(0) {}
: dumpFileNameWhileParsing(DumpFileNameWhileParsing)
, revision(0)
{}
int dumpFileNameWhileParsing;
int revision; int revision;
ProjectPart::HeaderPaths headerPaths; ProjectPart::HeaderPaths headerPaths;
WorkingCopy workingCopy; WorkingCopy workingCopy;
...@@ -192,12 +187,10 @@ void indexFindErrors(QFutureInterface<void> &future, const ParseParams params) ...@@ -192,12 +187,10 @@ void indexFindErrors(QFutureInterface<void> &future, const ParseParams params)
void index(QFutureInterface<void> &future, const ParseParams params) void index(QFutureInterface<void> &future, const ParseParams params)
{ {
QScopedPointer<CppSourceProcessor> sourceProcessor(CppModelManager::createSourceProcessor()); QScopedPointer<CppSourceProcessor> sourceProcessor(CppModelManager::createSourceProcessor());
sourceProcessor->setDumpFileNameWhileParsing(params.dumpFileNameWhileParsing);
sourceProcessor->setRevision(params.revision); sourceProcessor->setRevision(params.revision);
sourceProcessor->setHeaderPaths(params.headerPaths); sourceProcessor->setHeaderPaths(params.headerPaths);
sourceProcessor->setWorkingCopy(params.workingCopy); sourceProcessor->setWorkingCopy(params.workingCopy);
QStringList sources; QStringList sources;
QStringList headers; QStringList headers;
classifyFiles(params.sourceFiles, &headers, &sources); classifyFiles(params.sourceFiles, &headers, &sources);
......
...@@ -39,11 +39,15 @@ ...@@ -39,11 +39,15 @@
#include <cplusplus/CppDocument.h> #include <cplusplus/CppDocument.h>
#include <cplusplus/TranslationUnit.h> #include <cplusplus/TranslationUnit.h>
#include <QLoggingCategory>
enum { debug = 0 }; enum { debug = 0 };
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppTools; using namespace CppTools;
static Q_LOGGING_CATEGORY(log, "qtc.cpptools.semanticinfoupdater")
namespace CppTools { namespace CppTools {
class SemanticInfoUpdaterPrivate class SemanticInfoUpdaterPrivate
...@@ -105,8 +109,7 @@ void SemanticInfoUpdaterPrivate::setSemanticInfo(const SemanticInfo &semanticInf ...@@ -105,8 +109,7 @@ void SemanticInfoUpdaterPrivate::setSemanticInfo(const SemanticInfo &semanticInf
m_semanticInfo = semanticInfo; m_semanticInfo = semanticInfo;
} }
if (emitSignal) { if (emitSignal) {
if (debug) qCDebug(log) << "emiting new info";
qDebug() << "SemanticInfoUpdater: emiting new info";
emit q->updated(semanticInfo); emit q->updated(semanticInfo);
} }
} }
...@@ -115,9 +118,6 @@ SemanticInfo SemanticInfoUpdaterPrivate::update(const SemanticInfo::Source &sour ...@@ -115,9 +118,6 @@ SemanticInfo SemanticInfoUpdaterPrivate::update(const SemanticInfo::Source &sour
bool emitSignalWhenFinished, bool emitSignalWhenFinished,
FuturizedTopLevelDeclarationProcessor *processor) FuturizedTopLevelDeclarationProcessor *processor)
{ {
if (debug)
qDebug() << "SemanticInfoUpdater: update() - source revision" << source.revision;
SemanticInfo newSemanticInfo; SemanticInfo newSemanticInfo;
newSemanticInfo.revision = source.revision; newSemanticInfo.revision = source.revision;
newSemanticInfo.snapshot = source.snapshot; newSemanticInfo.snapshot = source.snapshot;
...@@ -130,9 +130,8 @@ SemanticInfo SemanticInfoUpdaterPrivate::update(const SemanticInfo::Source &sour ...@@ -130,9 +130,8 @@ SemanticInfo SemanticInfoUpdaterPrivate::update(const SemanticInfo::Source &sour
newSemanticInfo.complete = false; newSemanticInfo.complete = false;
newSemanticInfo.doc = doc; newSemanticInfo.doc = doc;
if (debug) qCDebug(log) << "update() for source revision:" << source.revision
qDebug() << "SemanticInfoUpdater: update() - re-calculated document. Canceled =" << "canceled:" << !newSemanticInfo.complete;
<< !newSemanticInfo.complete;
setSemanticInfo(newSemanticInfo, emitSignalWhenFinished); setSemanticInfo(newSemanticInfo, emitSignalWhenFinished);
return newSemanticInfo; return newSemanticInfo;
...@@ -156,9 +155,7 @@ bool SemanticInfoUpdaterPrivate::reuseCurrentSemanticInfo(const SemanticInfo::So ...@@ -156,9 +155,7 @@ bool SemanticInfoUpdaterPrivate::reuseCurrentSemanticInfo(const SemanticInfo::So
newSemanticInfo.snapshot = source.snapshot; newSemanticInfo.snapshot = source.snapshot;
newSemanticInfo.doc = currentSemanticInfo.doc; newSemanticInfo.doc = currentSemanticInfo.doc;
setSemanticInfo(newSemanticInfo, emitSignalWhenFinished); setSemanticInfo(newSemanticInfo, emitSignalWhenFinished);
if (debug) qCDebug(log) << "re-using current semantic info, source revision:" << source.revision;
qDebug() << "SemanticInfoUpdater: re-using current semantic info - source.revision"
<< source.revision;
return true; return true;
} }
...@@ -185,8 +182,7 @@ SemanticInfoUpdater::~SemanticInfoUpdater() ...@@ -185,8 +182,7 @@ SemanticInfoUpdater::~SemanticInfoUpdater()
SemanticInfo SemanticInfoUpdater::update(const SemanticInfo::Source &source) SemanticInfo SemanticInfoUpdater::update(const SemanticInfo::Source &source)
{ {
if (debug) qCDebug(log) << "update() - synchronous";
qDebug() << "SemanticInfoUpdater: update() - synchronous";
d->m_future.cancel(); d->m_future.cancel();
const bool emitSignalWhenFinished = false; const bool emitSignalWhenFinished = false;
...@@ -200,8 +196,7 @@ SemanticInfo SemanticInfoUpdater::update(const SemanticInfo::Source &source) ...@@ -200,8 +196,7 @@ SemanticInfo SemanticInfoUpdater::update(const SemanticInfo::Source &source)
void SemanticInfoUpdater::updateDetached(const SemanticInfo::Source source) void SemanticInfoUpdater::updateDetached(const SemanticInfo::Source source)
{ {
if (debug) qCDebug(log) << "updateDetached() - asynchronous";
qDebug() << "SemanticInfoUpdater: updateDetached() - asynchronous";
d->m_future.cancel(); d->m_future.cancel();
const bool emitSignalWhenFinished = true; const bool emitSignalWhenFinished = true;
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QDir> #include <QDir>
#include <QLoggingCategory>
#include <QTextCodec> #include <QTextCodec>
/*! /*!
...@@ -61,6 +62,8 @@ using namespace CppTools::Internal; ...@@ -61,6 +62,8 @@ using namespace CppTools::Internal;
typedef Document::DiagnosticMessage Message; typedef Document::DiagnosticMessage Message;
static Q_LOGGING_CATEGORY(log, "qtc.cpptools.sourceprocessor")
namespace { namespace {
inline QByteArray generateFingerPrint(const QList<Macro> &definedMacros, const QByteArray &code) inline QByteArray generateFingerPrint(const QList<Macro> &definedMacros, const QByteArray &code)
...@@ -112,7 +115,6 @@ inline const Macro revision(const WorkingCopy &workingCopy, ...@@ -112,7 +115,6 @@ inline const Macro revision(const WorkingCopy &workingCopy,
CppSourceProcessor::CppSourceProcessor(const Snapshot &snapshot, DocumentCallback documentFinished) CppSourceProcessor::CppSourceProcessor(const Snapshot &snapshot, DocumentCallback documentFinished)
: m_snapshot(snapshot), : m_snapshot(snapshot),
m_documentFinished(documentFinished), m_documentFinished(documentFinished),
m_dumpFileNameWhileParsing(false),
m_preprocess(this, &m_env), m_preprocess(this, &m_env),
m_revision(0), m_revision(0),
m_defaultCodec(Core::EditorManager::defaultTextCodec()) m_defaultCodec(Core::EditorManager::defaultTextCodec())
...@@ -445,8 +447,7 @@ void CppSourceProcessor::sourceNeeded(unsigned line, const QString &fileName, In ...@@ -445,8 +447,7 @@ void CppSourceProcessor::sourceNeeded(unsigned line, const QString &fileName, In
return; return;
} }
if (m_dumpFileNameWhileParsing) qCDebug(log) << "Parsing:" << absoluteFileName << "contents:" << contents.size() << "bytes";
qDebug() << "Parsing:" << absoluteFileName << "contents:" << contents.size() << "bytes";
Document::Ptr document = Document::create(absoluteFileName); Document::Ptr document = Document::create(absoluteFileName);
document->setRevision(m_revision); document->setRevision(m_revision);
......
...@@ -65,9 +65,6 @@ public: ...@@ -65,9 +65,6 @@ public:
CppSourceProcessor(const CPlusPlus::Snapshot &snapshot, DocumentCallback documentFinished); CppSourceProcessor(const CPlusPlus::Snapshot &snapshot, DocumentCallback documentFinished);
~CppSourceProcessor(); ~CppSourceProcessor();
void setDumpFileNameWhileParsing(bool onoff)
{ m_dumpFileNameWhileParsing = onoff; }
void setRevision(unsigned revision); void setRevision(unsigned revision);
void setWorkingCopy(const CppTools::WorkingCopy &workingCopy); void setWorkingCopy(const CppTools::WorkingCopy &workingCopy);
void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths); void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
...@@ -117,7 +114,6 @@ private: ...@@ -117,7 +114,6 @@ private:
CPlusPlus::Snapshot m_snapshot; CPlusPlus::Snapshot m_snapshot;
CPlusPlus::Snapshot m_globalSnapshot; CPlusPlus::Snapshot m_globalSnapshot;
DocumentCallback m_documentFinished; DocumentCallback m_documentFinished;
bool m_dumpFileNameWhileParsing;
CPlusPlus::Environment m_env; CPlusPlus::Environment m_env;
CPlusPlus::Preprocessor m_preprocess; CPlusPlus::Preprocessor m_preprocess;
ProjectPart::HeaderPaths m_headerPaths; ProjectPart::HeaderPaths m_headerPaths;
......
...@@ -35,12 +35,14 @@ ...@@ -35,12 +35,14 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
enum { debug = 0 }; #include <QLoggingCategory>
using namespace CPlusPlus; using namespace CPlusPlus;
using TextEditor::SemanticHighlighter::incrementalApplyExtraAdditionalFormats; using TextEditor::SemanticHighlighter::incrementalApplyExtraAdditionalFormats;
using TextEditor::SemanticHighlighter::clearExtraAdditionalFormatsUntilEnd; using TextEditor::SemanticHighlighter::clearExtraAdditionalFormatsUntilEnd;
static Q_LOGGING_CATEGORY(log, "qtc.cpptools.semantichighlighter")
namespace CppTools { namespace CppTools {
SemanticHighlighter::SemanticHighlighter(TextEditor::TextDocument *baseTextDocument) SemanticHighlighter::SemanticHighlighter(TextEditor::TextDocument *baseTextDocument)
...@@ -74,8 +76,7 @@ void SemanticHighlighter::run() ...@@ -74,8 +76,7 @@ void SemanticHighlighter::run()
{ {
QTC_ASSERT(m_highlightingRunner, return); QTC_ASSERT(m_highlightingRunner, return);
if (debug) qCDebug(log) << "SemanticHighlighter: run()";
qDebug() << "SemanticHighlighter: run()";
if (m_watcher) { if (m_watcher) {
disconnectWatcher(); disconnectWatcher();
...@@ -101,8 +102,7 @@ void SemanticHighlighter::onHighlighterResultAvailable(int from, int to) ...@@ -101,8 +102,7 @@ void SemanticHighlighter::onHighlighterResultAvailable(int from, int to)
else if (!m_watcher || m_watcher->isCanceled()) else if (!m_watcher || m_watcher->isCanceled())
return; // aborted return; // aborted
if (debug) qCDebug(log) << "onHighlighterResultAvailable()" << from << to;
qDebug() << "SemanticHighlighter: onHighlighterResultAvailable()" << from << to;
TextEditor::SyntaxHighlighter *highlighter = m_baseTextDocument->syntaxHighlighter(); TextEditor::SyntaxHighlighter *highlighter = m_baseTextDocument->syntaxHighlighter();
QTC_ASSERT(highlighter, return); QTC_ASSERT(highlighter, return);
...@@ -116,8 +116,7 @@ void SemanticHighlighter::onHighlighterFinished() ...@@ -116,8 +116,7 @@ void SemanticHighlighter::onHighlighterFinished()
TextEditor::SyntaxHighlighter *highlighter = m_baseTextDocument->syntaxHighlighter(); TextEditor::SyntaxHighlighter *highlighter = m_baseTextDocument->syntaxHighlighter();
QTC_CHECK(highlighter); QTC_CHECK(highlighter);
if (highlighter) { if (highlighter) {
if (debug) qCDebug(log) << "onHighlighterFinished() - clearing formats";
qDebug() << "SemanticHighlighter: onHighlighterFinished() - clearing formats";
clearExtraAdditionalFormatsUntilEnd(highlighter, m_watcher->future()); clearExtraAdditionalFormatsUntilEnd(highlighter, m_watcher->future());
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment