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