Commit 9cddeef0 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Make use of QLoggingCategory

...for document processing and highlighting.

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