Commit 4dc438db authored by Fawzi Mohamed's avatar Fawzi Mohamed Committed by Kai Koehne
Browse files

qmljs: switch to the new category logging



Change-Id: Id4e43779590939e9d6dd2d0dab536f70e721f097
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent b204c4db
......@@ -33,8 +33,6 @@
#include "qmljsdocument.h"
#include "qmljsmodelmanagerinterface.h"
#include <QDebug>
using namespace LanguageUtils;
using namespace QmlJS;
using namespace QmlJS::AST;
......
......@@ -35,7 +35,6 @@
#include <utils/qtcassert.h>
#include <QDebug>
#include <QDir>
using namespace QmlJS;
......
......@@ -29,12 +29,15 @@
#include "qmljscodeformatter.h"
#include <QDebug>
#include <utils/logging.h>
#include <QMetaEnum>
#include <QTextDocument>
#include <QTextBlock>
using namespace QmlJS;
namespace QmlJS {
Q_LOGGING_CATEGORY(formatterLog, "qtc.qmljs.formatter")
CodeFormatter::BlockData::BlockData()
: m_indentDepth(0)
......@@ -65,13 +68,13 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
m_tokenIndex = 0;
m_newStates.clear();
//qDebug() << "Starting to look at " << block.text() << block.blockNumber() + 1;
//qCDebug(formatterLog) << "Starting to look at " << block.text() << block.blockNumber() + 1;
for (; m_tokenIndex < m_tokens.size(); ) {
m_currentToken = tokenAt(m_tokenIndex);
const int kind = extendedTokenKind(m_currentToken);
//qDebug() << "Token" << m_currentLine.mid(m_currentToken.begin(), m_currentToken.length) << m_tokenIndex << "in line" << block.blockNumber() + 1;
//qCDebug(formatterLog) << "Token" << m_currentLine.mid(m_currentToken.begin(), m_currentToken.length) << m_tokenIndex << "in line" << block.blockNumber() + 1;
//dump();
if (kind == Comment
......@@ -520,7 +523,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
int CodeFormatter::indentFor(const QTextBlock &block)
{
// qDebug() << "indenting for" << block.blockNumber() + 1;
// qCDebug(formatterLog) << "indenting for" << block.blockNumber() + 1;
restoreCurrentState(block.previous());
correctIndentation(block);
......@@ -641,7 +644,7 @@ void CodeFormatter::enter(int newState)
m_currentState.push(s);
m_newStates.push(s);
//qDebug() << "enter state" << stateToString(newState);
//qCDebug(formatterLog) << "enter state" << stateToString(newState);
if (newState == bracket_open)
enter(bracket_element_start);
......@@ -662,7 +665,7 @@ void CodeFormatter::leave(bool statementDone)
int topState = m_currentState.top().type;
//qDebug() << "left state" << stateToString(poppedState.type) << ", now in state" << stateToString(topState);
//qCDebug(formatterLog) << "left state" << stateToString(poppedState.type) << ", now in state" << stateToString(topState);
// if statement is done, may need to leave recursively
if (statementDone) {
......@@ -1003,12 +1006,12 @@ CodeFormatter::TokenKind CodeFormatter::extendedTokenKind(const QmlJS::Token &to
void CodeFormatter::dump() const
{
qDebug() << "Current token index" << m_tokenIndex;
qDebug() << "Current state:";
qCDebug(formatterLog) << "Current token index" << m_tokenIndex;
qCDebug(formatterLog) << "Current state:";
foreach (const State &s, m_currentState) {
qDebug() << stateToString(s.type) << s.savedIndentDepth;
qCDebug(formatterLog) << stateToString(s.type) << s.savedIndentDepth;
}
qDebug() << "Current indent depth:" << m_indentDepth;
qCDebug(formatterLog) << "Current indent depth:" << m_indentDepth;
}
QString CodeFormatter::stateToString(int type) const
......@@ -1339,3 +1342,5 @@ void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int startLex
break;
}
}
} // namespace QmlJS
......@@ -29,7 +29,6 @@
#include "qmljscompletioncontextfinder.h"
#include <QDebug>
#include <QTextDocument>
#include <QStringList>
......@@ -130,7 +129,7 @@ void CompletionContextFinder::checkBinding()
{
YY_SAVE();
//qDebug() << "Start line:" << *yyLine << m_startTokenIndex;
//qCDebug(qmljsLog) << "Start line:" << *yyLine << m_startTokenIndex;
int i = m_startTokenIndex;
int colonCount = 0;
......
......@@ -29,6 +29,9 @@
#ifndef QMLJSCONSTANTS_H
#define QMLJSCONSTANTS_H
#include "qmljs_global.h"
#include <utils/logging.h>
namespace QmlJS {
......@@ -87,5 +90,8 @@ const char TASK_INDEX[] = "QmlJSEditor.TaskIndex";
const char TASK_IMPORT_SCAN[] = "QmlJSEditor.TaskImportScan";
} // namespace Constants
QMLJS_EXPORT Q_DECLARE_LOGGING_CATEGORY(qmljsLog)
} // namespace QmlJS
#endif // QMLJSCONSTANTS_H
......@@ -31,7 +31,6 @@
#include "qmljscontext.h"
#include "qmljsscopechain.h"
#include "parser/qmljsast_p.h"
#include <QDebug>
using namespace QmlJS;
......
......@@ -36,7 +36,6 @@
#include <cplusplus/cppmodelmanagerbase.h>
#include <cplusplus/CppDocument.h>
#include <QDebug>
#include <QList>
//using namespace QmlJS;
......
......@@ -28,8 +28,10 @@
****************************************************************************/
#include "qmljsicons.h"
#include <utils/logging.h>
#include <QIcon>
#include <QDebug>
#include <QDir>
#include <QHash>
#include <QPair>
......@@ -43,6 +45,8 @@ enum {
namespace QmlJS {
Q_LOGGING_CATEGORY(iconsLog, "qtc.qmljs.icons")
Icons *Icons::m_instance = 0;
class IconsPrivate
......@@ -88,22 +92,22 @@ void Icons::setIconFilesPath(const QString &iconPath)
d->resourcePath = iconPath;
if (debug)
qDebug() << "QmlJSIcons -" << "parsing" << iconPath;
qCDebug(iconsLog) << "parsing" << iconPath;
QDir topDir(iconPath);
foreach (const QFileInfo &subDirInfo, topDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
if (debug)
qDebug() << "QmlJSIcons - parsing" << subDirInfo.absoluteFilePath();
qCDebug(iconsLog) << "parsing" << subDirInfo.absoluteFilePath();
const QString packageName = subDirInfo.fileName();
QDir subDir(subDirInfo.absoluteFilePath() + QLatin1String("/16x16"));
foreach (const QFileInfo &iconFile, subDir.entryInfoList(QDir::Files)) {
QIcon icon(iconFile.absoluteFilePath());
if (icon.isNull()) {
if (debug)
qDebug() << "QmlJSIcons - skipping" << iconFile.absoluteFilePath();
qCDebug(iconsLog) << "skipping" << iconFile.absoluteFilePath();
continue;
}
if (debug)
qDebug() << "QmlJSIcons - adding" << packageName << iconFile.baseName() << "icon to database";
qCDebug(iconsLog) << "adding" << packageName << iconFile.baseName() << "icon to database";
QPair<QString,QString> element(packageName, iconFile.baseName());
d->iconHash.insert(element, icon);
}
......@@ -114,7 +118,7 @@ QIcon Icons::icon(const QString &packageName, const QString typeName) const
{
QPair<QString,QString> element(packageName, typeName);
if (debug)
qDebug() << "QmlJSIcons - icon for" << packageName << typeName << "requested" << d->iconHash.contains(element);
qCDebug(iconsLog) << "icon for" << packageName << typeName << "requested" << d->iconHash.contains(element);
return d->iconHash.value(element);
}
......
......@@ -32,6 +32,7 @@
#include "qmljsqrcparser.h"
#include <utils/qtcassert.h>
#include <utils/logging.h>
#include <QCryptographicHash>
......@@ -39,7 +40,7 @@
namespace QmlJS {
static bool debugImportDependencies = false;
Q_LOGGING_CATEGORY(importsLog, "qtc.qmljs.imports")
ImportKind::Enum toImportKind(ImportType::Enum type)
{
......@@ -728,18 +729,18 @@ void ImportDependencies::addCoreImport(const CoreImport &import)
foreach (const Export &e, import.possibleExports)
m_importCache[e.exportName].append(import.importId);
m_coreImports.insert(newImport.importId, newImport);
if (debugImportDependencies) {
QDebug dbg(qDebug());
dbg << "added import "<< newImport.importId << " for";
if (importsLog().isDebugEnabled()) {
QString msg = QString::fromLatin1("added import %1 for").arg(newImport.importId);
foreach (const Export &e, newImport.possibleExports)
dbg << " " << e.exportName.toString() << "(" << e.pathRequired << ")";
msg += QString::fromLatin1("\n %1(%2)").arg(e.exportName.toString(), e.pathRequired);
qCDebug(importsLog) << msg;
}
}
void ImportDependencies::removeCoreImport(const QString &importId)
{
if (!m_coreImports.contains(importId)) {
qDebug() << "missing importId in removeCoreImport(" << importId << ")";
qCWarning(importsLog) << "missing importId in removeCoreImport(" << importId << ")";
return;
}
CoreImport &cImport = m_coreImports[importId];
......@@ -754,16 +755,15 @@ void ImportDependencies::removeCoreImport(const QString &importId)
else
m_coreImports.remove(importId);
if (debugImportDependencies)
qDebug() << "removed import with id:"<< importId;
qCDebug(importsLog) << "removed import with id:"<< importId;
}
void ImportDependencies::removeImportCacheEntry(const ImportKey &importKey, const QString &importId)
{
QStringList &cImp = m_importCache[importKey];
if (!cImp.removeOne(importId)) {
qDebug() << "missing possibleExport backpointer for " << importKey.toString() << " to "
<< importId;
qCWarning(importsLog) << "missing possibleExport backpointer for " << importKey.toString() << " to "
<< importId;
}
if (cImp.isEmpty())
m_importCache.remove(importKey);
......@@ -783,35 +783,33 @@ void ImportDependencies::addExport(const QString &importId, const ImportKey &imp
CoreImport &importValue = m_coreImports[importId];
importValue.possibleExports.append(Export(importKey, requiredPath, false));
m_importCache[importKey].append(importId);
if (debugImportDependencies)
qDebug() << "added export "<< importKey.toString() << " for id " <<importId
<< " (" << requiredPath << ")";
qCDebug(importsLog) << "added export "<< importKey.toString() << " for id " <<importId
<< " (" << requiredPath << ")";
}
void ImportDependencies::removeExport(const QString &importId, const ImportKey &importKey,
const QString &requiredPath)
{
if (!m_coreImports.contains(importId)) {
qDebug() << "non existing core import for removeExport(" << importId << ", "
<< importKey.toString() << ")";
qCWarning(importsLog) << "non existing core import for removeExport(" << importId << ", "
<< importKey.toString() << ")";
} else {
CoreImport &importValue = m_coreImports[importId];
if (!importValue.possibleExports.removeOne(Export(importKey, requiredPath, false))) {
qDebug() << "non existing export for removeExport(" << importId << ", "
<< importKey.toString() << ")";
qCWarning(importsLog) << "non existing export for removeExport(" << importId << ", "
<< importKey.toString() << ")";
}
if (importValue.possibleExports.isEmpty() && importValue.fingerprint.isEmpty())
m_coreImports.remove(importId);
}
if (!m_importCache.contains(importKey)) {
qDebug() << "missing possibleExport for " << importKey.toString() << " when removing export of "
<< importId;
qCWarning(importsLog) << "missing possibleExport for " << importKey.toString()
<< " when removing export of " << importId;
} else {
removeImportCacheEntry(importKey, importId);
}
if (debugImportDependencies)
qDebug() << "removed export "<< importKey.toString() << " for id " << importId
<< " (" << requiredPath << ")";
qCDebug(importsLog) << "removed export "<< importKey.toString() << " for id " << importId
<< " (" << requiredPath << ")";
}
void ImportDependencies::iterateOnCoreImports(
......@@ -838,8 +836,7 @@ void ImportDependencies::iterateOnLibraryImports(
iter_t i = m_importCache.lowerBound(firstLib);
iter_t end = m_importCache.constEnd();
while (i != end && i.key().type == ImportType::Library) {
if (debugImportDependencies)
qDebug() << "libloop:" << i.key().toString() << i.value();
qCDebug(importsLog) << "libloop:" << i.key().toString() << i.value();
foreach (const QString &cImportName, i.value()) {
CoreImport cImport = coreImport(cImportName);
if (vContext.languageIsCompatible(cImport.language)) {
......@@ -847,9 +844,8 @@ void ImportDependencies::iterateOnLibraryImports(
if (e.visibleInVContext(vContext) && e.exportName.type == ImportType::Library) {
ImportMatchStrength m = e.exportName.matchImport(i.key(), vContext);
if (m.hasMatch()) {
if (debugImportDependencies)
qDebug() << "import iterate:" << e.exportName.toString()
<< " (" << e.pathRequired << "), id:" << cImport.importId;
qCDebug(importsLog) << "import iterate:" << e.exportName.toString()
<< " (" << e.pathRequired << "), id:" << cImport.importId;
if (!iterF(m, e, cImport))
return;
}
......@@ -945,16 +941,16 @@ void ImportDependencies::checkConsistency() const
i.next();
foreach (const Export &e, i.value().possibleExports) {
if (!m_importCache.value(e.exportName).contains(i.key())) {
qDebug() << e.exportName.toString();
qDebug() << i.key();
qCWarning(importsLog) << e.exportName.toString();
qCWarning(importsLog) << i.key();
QMapIterator<ImportKey, QStringList> j(m_importCache);
while (j.hasNext()) {
j.next();
qDebug() << j.key().toString() << j.value();
qCWarning(importsLog) << j.key().toString() << j.value();
}
qDebug() << m_importCache.contains(e.exportName);
qDebug() << m_importCache.value(e.exportName);
qCWarning(importsLog) << m_importCache.contains(e.exportName);
qCWarning(importsLog) << m_importCache.value(e.exportName);
}
Q_ASSERT(m_importCache.value(e.exportName).contains(i.key()));
}
......
......@@ -67,7 +67,6 @@
#include <qmljs/qmljsindenter.h>
#include <QDebug>
#include <QTextBlock>
using namespace QmlJS;
......
......@@ -28,6 +28,7 @@
****************************************************************************/
#include "parser/qmljsast_p.h"
#include "qmljsconstants.h"
#include "qmljscontext.h"
#include "qmljsevaluate.h"
#include "qmljsinterpreter.h"
......@@ -41,7 +42,6 @@
#include <utils/qtcassert.h>
#include <QApplication>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QString>
......@@ -2492,38 +2492,38 @@ public:
virtual bool processProperty(const QString &name, const Value *)
{
qDebug() << "property: " << name;
qCDebug(qmljsLog) << "property: " << name;
return true;
}
virtual bool processEnumerator(const QString &name, const Value *)
{
qDebug() << "enumerator: " << name;
qCDebug(qmljsLog) << "enumerator: " << name;
return true;
}
virtual bool processSignal(const QString &name, const Value *)
{
qDebug() << "signal: " << name;
qCDebug(qmljsLog) << "signal: " << name;
return true;
}
virtual bool processSlot(const QString &name, const Value *)
{
qDebug() << "slot: " << name;
qCDebug(qmljsLog) << "slot: " << name;
return true;
}
virtual bool processGeneratedSlot(const QString &name, const Value *)
{
qDebug() << "generated slot: " << name;
qCDebug(qmljsLog) << "generated slot: " << name;
return true;
}
};
void Imports::dump() const
{
qDebug() << "Imports contents, in search order:";
qCDebug(qmljsLog) << "Imports contents, in search order:";
QListIterator<Import> it(m_imports);
it.toBack();
while (it.hasPrevious()) {
......@@ -2531,7 +2531,7 @@ void Imports::dump() const
const ObjectValue *import = i.object;
const ImportInfo &info = i.info;
qDebug() << " " << info.path() << " " << info.version().toString() << " as " << info.as() << " : " << import;
qCDebug(qmljsLog) << " " << info.path() << " " << info.version().toString() << " as " << info.as() << " : " << import;
MemberDumper dumper;
import->processMembers(&dumper);
}
......
......@@ -67,8 +67,6 @@
#include <qmljs/qmljslineinfo.h>
#include <QDebug>
using namespace QmlJS;
/*
......
......@@ -38,7 +38,6 @@
#include "qmljsconstants.h"
#include <QDir>
#include <QDebug>
using namespace LanguageUtils;
using namespace QmlJS;
......
......@@ -39,7 +39,6 @@
#include <utils/hostosinfo.h>
#include <utils/runextensions.h>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QFileInfo>
......@@ -55,6 +54,8 @@
namespace QmlJS {
QMLJS_EXPORT Q_LOGGING_CATEGORY(qmljsLog, "qtc.qmljs.common")
/*!
\class QmlJS::ModelManagerInterface
\brief The ModelManagerInterface class acts as an interface to the
......@@ -184,7 +185,7 @@ void ModelManagerInterface::writeWarning(const QString &msg)
if (ModelManagerInterface *i = instance())
i->writeMessageInternal(msg);
else
qDebug() << msg;
qCWarning(qmljsLog) << msg;
}
ModelManagerInterface::WorkingCopy ModelManagerInterface::workingCopy()
......@@ -209,7 +210,7 @@ QHash<QString, Language::Enum> ModelManagerInterface::languageForSuffix() const
void ModelManagerInterface::writeMessageInternal(const QString &msg) const
{
qDebug() << msg;
qCWarning(qmljsLog) << msg;
}
ModelManagerInterface::WorkingCopy ModelManagerInterface::workingCopyInternal() const
......@@ -222,7 +223,7 @@ void ModelManagerInterface::addTaskInternal(QFuture<void> result, const QString
const char *taskId) const
{
Q_UNUSED(result);
qDebug() << "started " << taskId << " " << msg;
qCDebug(qmljsLog) << "started " << taskId << " " << msg;
}
void ModelManagerInterface::loadQmlTypeDescriptionsInternal(const QString &resourcePath)
......@@ -630,7 +631,7 @@ void ModelManagerInterface::updateDocument(Document::Ptr doc)
void ModelManagerInterface::updateLibraryInfo(const QString &path, const LibraryInfo &info)
{
if (!info.pluginTypeInfoError().isEmpty())
qDebug() << "Dumping errors for " << path << ":" << info.pluginTypeInfoError();
qCWarning(qmljsLog) << "Dumping errors for " << path << ":" << info.pluginTypeInfoError();
{
QMutexLocker locker(&m_mutex);
......
......@@ -28,6 +28,7 @@
****************************************************************************/
#include "qmljsqrcparser.h"
#include "qmljsconstants.h"
#include <QFile>
#include <QDir>
#include <QFileInfo>
......@@ -40,7 +41,6 @@
#include <QMultiHash>
#include <QCoreApplication>
#include <utils/qtcassert.h>
#include <QDebug>
namespace QmlJS {
......@@ -456,7 +456,7 @@ QrcParser::Ptr QrcCachePrivate::addPath(const QString &path)
}
QrcParser::Ptr newParser = QrcParser::parseQrcFile(path);
if (!newParser->isValid())
qDebug() << "adding invalid qrc " << path << " to the cache:" << newParser->errorMessages();
qCWarning(qmljsLog) << "adding invalid qrc " << path << " to the cache:" << newParser->errorMessages();
{
QMutexLocker l(&m_mutex);
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, qMakePair(QrcParser::Ptr(0), 0));
......
......@@ -288,7 +288,7 @@ protected:
result.badnessFromSplits = 0;
result.lines = QStringList(line);
//qDebug() << "trying to split" << line << possibleSplits << context;
//qCDebug(qmljsLog) << "trying to split" << line << possibleSplits << context;
// try to split at every possible position
for (int i = possibleSplits.size() - 1; i >= 0; --i) {
......
......@@ -33,16 +33,14 @@
#include "parser/qmljslexer_p.h"
#include "parser/qmljsengine_p.h"
#include <utils/logging.h>
#include "qmljsutils.h"
#include <QFile>
enum {
debug = false
};
using namespace QmlJS;
namespace QmlJS{
Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader")
QVariant SimpleReaderNode::property(const QString &name) const
{
......@@ -304,8 +302,7 @@ SimpleReaderNode::Ptr SimpleReader::readFromSource(const QString &source)
void SimpleReader::elementStart(const QString &name)
{
if (debug)
qDebug() << "SimpleReader::elementStart()" << name;
qCDebug(simpleReaderLog) << "elementStart()" << name;
SimpleReaderNode::Ptr newNode = SimpleReaderNode::create(name, m_currentNode);
......@@ -321,8 +318,7 @@ void SimpleReader::elementEnd()
{
Q_ASSERT(m_currentNode);
if (debug)
qDebug() << "SimpleReader::elementEnd()" << m_currentNode.data()->name();
qCDebug(simpleReaderLog) << "elementEnd()" << m_currentNode.data()->name();
m_currentNode = m_currentNode.data()->parent();
}
......@@ -331,11 +327,12 @@ void SimpleReader::propertyDefinition(const QString &name, const QVariant &value
{
Q_ASSERT(m_currentNode);
if (debug)
qDebug() << "SimpleReader::propertyDefinition()" << m_currentNode.data()->name() << name << value;
qCDebug(simpleReaderLog) << "propertyDefinition()" << m_currentNode.data()->name() << name << value;
if (m_currentNode.data()->propertyNames().contains(name))
addError(tr("Property is defined twice."), currentSourceLocation());
m_currentNode.data()->setProperty(name, value);
}
} // namespace QmlJS
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