Commit bf3c55be authored by Nikolai Kosjar's avatar Nikolai Kosjar

ClangCodeModel: Make use of QLoggingCategory

Change-Id: I28d50e224803096c032ae6e387bf1346db4cc216
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent 9cddeef0
......@@ -61,11 +61,10 @@
#include <QCoreApplication>
#include <QDirIterator>
#include <QLoggingCategory>
#include <QTextCursor>
#include <QTextDocument>
static const bool DebugTiming = qgetenv("QTC_CLANG_VERBOSE") == "1";
using namespace ClangCodeModel;
using namespace ClangCodeModel::Internal;
using namespace CPlusPlus;
......@@ -73,6 +72,7 @@ using namespace CppTools;
using namespace TextEditor;
static const char SNIPPET_ICON_PATH[] = ":/texteditor/images/snippet.png";
static Q_LOGGING_CATEGORY(log, "qtc.clangcodemodel.completion")
namespace {
......@@ -170,17 +170,13 @@ static QList<CodeCompletionResult> unfilteredCompletion(const ClangCompletionAss
if (!modifiedInput.isEmpty())
unsavedFiles.insert(fileName, modifiedInput);
QTime t;
if (DebugTiming) {
qDebug() << "Here we go with ClangCompletionAssistProcessor....";
t.start();
}
qCDebug(log) << "Starting completion...";
QTime t; t.start();
QList<CodeCompletionResult> result = wrapper->codeCompleteAt(line, column + 1, unsavedFiles);
::Utils::sort(result);
if (DebugTiming)
qDebug() << "... Completion done in" << t.elapsed() << "ms, with" << result.count() << "items.";
qCDebug(log) << "Completion done in" << t.elapsed() << "ms, with" << result.count() << "items.";
return result;
}
......@@ -977,8 +973,7 @@ int ClangCompletionAssistProcessor::startCompletionInternal(const QString fileNa
int l = line, c = column;
Convenience::convertPosition(m_interface->textDocument(), nameStart, &l, &c);
if (DebugTiming)
qDebug()<<"complete constructor or function @" << line<<":"<<column << "->"<<l<<":"<<c;
qCDebug(log)<<"complete constructor or function @" << line<<":"<<column << "->"<<l<<":"<<c;
const QList<CodeCompletionResult> completions = unfilteredCompletion(
m_interface.data(), fileName, l, c, QByteArray(), signalCompletion || slotCompletion);
......
......@@ -40,7 +40,9 @@
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
static const bool DebugTiming = qgetenv("QTC_CLANG_VERBOSE") == "1";
#include <QLoggingCategory>
static Q_LOGGING_CATEGORY(log, "qtc.clangcodemodel.clangeditordocumentparser")
namespace {
......@@ -91,20 +93,16 @@ void ClangEditorDocumentParser::update(CppTools::WorkingCopy workingCopy)
updateProjectPart();
const QStringList options = createOptions(filePath(), projectPart());
QTime t;
if (DebugTiming) {
qDebug("*** Reparse options (cmd line equivalent): %s",
commandLine(options, filePath()).toUtf8().constData());
t.start();
}
qCDebug(log, "Reparse options (cmd line equivalent): %s",
commandLine(options, filePath()).toUtf8().constData());
QTime t; t.start();
m_marker->setFileName(filePath());
m_marker->setCompilationOptions(options);
const Internal::UnsavedFiles unsavedFiles = Utils::createUnsavedFiles(workingCopy);
m_marker->reparse(unsavedFiles);
if (DebugTiming)
qDebug() << "*** Reparse took" << t.elapsed() << "ms.";
qCDebug(log) << "Reparse took" << t.elapsed() << "ms.";
}
QList<Diagnostic> ClangEditorDocumentParser::diagnostics() const
......
......@@ -42,7 +42,9 @@
#include <utils/qtcassert.h>
#include <utils/QtConcurrentTools>
static const bool DebugTiming = qgetenv("QTC_CLANG_VERBOSE") == "1";
#include <QLoggingCategory>
static Q_LOGGING_CATEGORY(log, "qtc.clangcodemodel.clangeditordocumentprocessor")
namespace {
......@@ -55,8 +57,7 @@ QList<CppToolsDiagnostic> toCppToolsDiagnostics(
QList<CppToolsDiagnostic> converted;
foreach (const ClangCodeModel::Diagnostic &d, diagnostics) {
if (DebugTiming)
qDebug() << d.severityAsString() << d.location() << d.spelling();
qCDebug(log) << "diagnostic" << d.severityAsString() << d.location() << d.spelling();
if (d.location().fileName() != filePath)
continue;
......
......@@ -41,6 +41,7 @@
#include <QDir>
#include <QFile>
#include <QLoggingCategory>
#include <QSet>
#include <QString>
......@@ -49,11 +50,11 @@ using namespace ClangCodeModel::Internal;
using namespace Core;
using namespace CppTools;
static const bool BeVerbose = qgetenv("QTC_CLANG_VERBOSE") == "1";
namespace ClangCodeModel {
namespace Utils {
Q_LOGGING_CATEGORY(verboseRunLog, "qtc.clangcodemodel.verboserun")
namespace {
bool isBlacklisted(const QString &path)
{
......@@ -139,7 +140,7 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind
if (pPart.isNull())
return result;
if (BeVerbose)
if (verboseRunLog().isDebugEnabled())
result << QLatin1String("-v");
const bool objcExt = pPart->languageExtensions & ProjectPart::ObjectiveCExtensions;
......
......@@ -36,9 +36,13 @@
#include <cpptools/cppmodelmanager.h>
#include <QLoggingCategory>
namespace ClangCodeModel {
namespace Utils {
Q_DECLARE_LOGGING_CATEGORY(verboseRunLog)
ClangCodeModel::Internal::UnsavedFiles createUnsavedFiles(CppTools::WorkingCopy workingCopy);
QStringList createClangOptions(const CppTools::ProjectPart::Ptr &pPart,
......
......@@ -35,17 +35,18 @@
#include <utils/runextensions.h>
#include <QCoreApplication>
#include <QLoggingCategory>
#include <QMutexLocker>
#include <QThreadPool>
#include <QDebug>
static const bool DebugTiming = qgetenv("QTC_CLANG_VERBOSE") == "1";
using namespace ClangCodeModel;
using namespace ClangCodeModel::Internal;
using namespace CppTools;
static Q_LOGGING_CATEGORY(log, "qtc.clangcodemodel.createmarkers")
CreateMarkers *CreateMarkers::create(SemanticMarker::Ptr semanticMarker,
const QString &fileName,
unsigned firstLine, unsigned lastLine)
......@@ -79,11 +80,9 @@ void CreateMarkers::run()
if (isCanceled())
return;
QTime t;
if (DebugTiming) {
qDebug() << "*** Highlighting from" << m_firstLine << "to" << m_lastLine << "of" << m_fileName;
t.start();
}
qCDebug(log) << "Creating markers from" << m_firstLine << "to" << m_lastLine
<< "of" << m_fileName;
QTime t; t.start();
m_usages.clear();
......@@ -105,10 +104,7 @@ void CreateMarkers::run()
flush();
reportFinished();
if (DebugTiming) {
qDebug() << "*** Highlighting took" << t.elapsed() << "ms in total.";
t.restart();
}
qCDebug(log) << "Creating markers took" << t.elapsed() << "ms in total.";
}
void CreateMarkers::addUse(const SourceMarker &marker)
......
......@@ -29,6 +29,8 @@
****************************************************************************/
#include "unit.h"
#include "clangutils.h"
#include "unsavedfiledata.h"
#include "utils_p.h"
......@@ -47,8 +49,6 @@ static QBasicAtomicInt unitDataCount = Q_BASIC_ATOMIC_INITIALIZER(0);
using namespace ClangCodeModel;
using namespace ClangCodeModel::Internal;
static const int DisplayDiagnostics = (qgetenv("QTC_CLANG_VERBOSE") == "1") ? 1 : 0;
Unit::Unit()
: m_index(0)
, m_tu(0)
......@@ -56,7 +56,7 @@ Unit::Unit()
{}
Unit::Unit(const QString &fileName)
: m_index(clang_createIndex(/*excludeDeclsFromPCH*/ 1, DisplayDiagnostics))
: m_index(clang_createIndex(/*excludeDeclsFromPCH*/ 1, Utils::verboseRunLog().isDebugEnabled()))
, m_tu(0)
, m_fileName(fileName.toUtf8())
, m_managementOptions(0)
......
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