diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index fd618d27065d344ce434c82328b0c320c9b5ab1f..83386e8079c5fca868024acb4be07b4e74a58cc1 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -164,7 +164,15 @@ protected: bool process_primary() { if ((*_lex)->is(T_INT_LITERAL)) { - _value.set_long(tokenSpell().toLong()); + int base = 10; + const QByteArray spell = tokenSpell(); + if (spell.at(0) == '0') { + if (spell.size() > 1 && (spell.at(1) == 'x' || spell.at(1) == 'X')) + base = 16; + else + base = 8; + } + _value.set_long(tokenSpell().toLong(0, base)); ++(*_lex); return true; } else if (isTokenDefined()) { @@ -367,7 +375,7 @@ protected: { process_xor(); - while ((*_lex)->is(T_CARET)) { + while ((*_lex)->is(T_PIPE)) { const Token op = *(*_lex); ++(*_lex); @@ -481,12 +489,12 @@ void pp::operator () (const QByteArray &filename, const QByteArray &source, QByteArray *result) { - const QByteArray previousFile = env.current_file; - env.current_file = filename; + const QByteArray previousFile = env.currentFile; + env.currentFile = filename; operator () (source, result); - env.current_file = previousFile; + env.currentFile = previousFile; } pp::State pp::createStateFromSource(const QByteArray &source) const @@ -518,7 +526,7 @@ void pp::operator()(const QByteArray &source, QByteArray *result) result->append(QByteArray::number(_dot->lineno)); result->append(' '); result->append('"'); - result->append(env.current_file); + result->append(env.currentFile); result->append('"'); result->append('\n'); } else { @@ -844,6 +852,8 @@ void pp::processDefine(TokenIterator firstToken, TokenIterator lastToken) } Macro macro; + macro.fileName = env.currentFile; + macro.line = env.currentLine; macro.name = tokenText(*tk); ++tk; // skip T_IDENTIFIER diff --git a/src/libs/cplusplus/pp-environment.cpp b/src/libs/cplusplus/pp-environment.cpp index ff2ca77e4f2d604ca88572efbac1b77e57029f71..20491727a4ceb2cb9be060cc0d7e9a998ea92794 100644 --- a/src/libs/cplusplus/pp-environment.cpp +++ b/src/libs/cplusplus/pp-environment.cpp @@ -97,8 +97,6 @@ Macro *Environment::bind(const Macro &__macro) Macro *m = new Macro (__macro); m->hashcode = hash_code(m->name); - m->fileName = current_file; - m->line = currentLine; if (++_macro_count == _allocated_macros) { if (! _allocated_macros) @@ -122,11 +120,13 @@ Macro *Environment::bind(const Macro &__macro) return m; } -Macro *Environment::remove (const QByteArray &name) +Macro *Environment::remove(const QByteArray &name) { Macro macro; macro.name = name; macro.hidden = true; + macro.fileName = currentFile; + macro.line = currentLine; return bind(macro); } diff --git a/src/libs/cplusplus/pp-environment.h b/src/libs/cplusplus/pp-environment.h index e2a75d29b819f4990b649ac428e8bd928e30c83f..4200b5ea0ff0548852535b699eb9680444599d5e 100644 --- a/src/libs/cplusplus/pp-environment.h +++ b/src/libs/cplusplus/pp-environment.h @@ -94,7 +94,7 @@ private: void rehash(); public: - QByteArray current_file; + QByteArray currentFile; unsigned currentLine; bool hide_next; diff --git a/src/libs/cplusplus/pp-macro-expander.cpp b/src/libs/cplusplus/pp-macro-expander.cpp index 9ae9702fe18fa21dcd240b0f6c4d59ee21fbf5aa..e17dd873dba8e12370165e06285e3d157baa7350 100644 --- a/src/libs/cplusplus/pp-macro-expander.cpp +++ b/src/libs/cplusplus/pp-macro-expander.cpp @@ -73,7 +73,7 @@ const char *MacroExpander::operator () (const char *__first, const char *__last, __result->append(QByteArray::number(env.currentLine)); __result->append(' '); __result->append('"'); - __result->append(env.current_file); + __result->append(env.currentFile); __result->append('"'); __result->append('\n'); ++lines; @@ -218,7 +218,7 @@ const char *MacroExpander::operator () (const char *__first, const char *__last, else if (fast_name == "__FILE__") { __result->append('"'); - __result->append(env.current_file); + __result->append(env.currentFile); __result->append('"'); continue; } diff --git a/src/libs/cplusplus/pp-macro.h b/src/libs/cplusplus/pp-macro.h index 73cdab7e3a08dffa62de64b1f53342d5307c5855..887fff53b0a6128d13ebf439d872863e28207e11 100644 --- a/src/libs/cplusplus/pp-macro.h +++ b/src/libs/cplusplus/pp-macro.h @@ -111,7 +111,7 @@ public: } if (variadics) text += QLatin1String("..."); - text += QLatin1Char(' '); + text += QLatin1Char(')'); } text += QLatin1Char(' '); text += QString::fromUtf8(definition.constData(), definition.size()); diff --git a/src/libs/utils/qtcassert.h b/src/libs/utils/qtcassert.h index d05be20df812dd26c742a0e84e9bafe5ad87b35d..f75d225f6e65ae19db688e04b833b69e18842f21 100644 --- a/src/libs/utils/qtcassert.h +++ b/src/libs/utils/qtcassert.h @@ -36,13 +36,11 @@ #include <QtCore/QDebug> -#ifdef Q_OS_UNIX +// we do not use the 'do {...} while (0)' idiom here to be able to use +// 'break' and 'continue' as 'actions'. + #define QTC_ASSERT(cond, action) \ if(cond){}else{qDebug()<<"ASSERTION"<<#cond<<"FAILED"<<__FILE__<<__LINE__;action;} -#else -#define QTC_ASSERT(cond, action) \ - if(cond){}else{qDebug()<<"ASSERTION"<<#cond<<"FAILED";action;} -#endif #endif // QTC_ASSERT_H diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index ff68bd0bac27e8f9e2c1574ea1f598ae970b9f4e..8d4a36178ce5150221d75c93bbe216532d935dc0 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -520,6 +520,15 @@ void CPPEditor::jumpToDefinition() #endif } } else { + foreach (const Document::MacroUse use, doc->macroUses()) { + if (use.contains(endOfName - 1)) { + const Macro ¯o = use.macro(); + const QString fileName = QString::fromUtf8(macro.fileName); + if (TextEditor::BaseTextEditor::openEditorAt(fileName, macro.line, 0)) + return; // done + } + } + qDebug() << "No results for expression:" << expression; } } diff --git a/src/plugins/cpptools/cppfunctionsfilter.cpp b/src/plugins/cpptools/cppfunctionsfilter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..61bb8e2d00d2f66e55a0ce350b82fd6a70bd18e2 --- /dev/null +++ b/src/plugins/cpptools/cppfunctionsfilter.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.2, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ + +#include "cppfunctionsfilter.h" + +using namespace CppTools::Internal; + +CppFunctionsFilter::CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager) + : CppQuickOpenFilter(manager, editorManager) +{ + setShortcutString("m"); + setIncludedByDefault(false); + + search.setSymbolsToSearchFor(SearchSymbols::Functions); + search.setSeparateScope(true); +} + +CppFunctionsFilter::~CppFunctionsFilter() +{ +} diff --git a/src/plugins/cpptools/cppfunctionsfilter.h b/src/plugins/cpptools/cppfunctionsfilter.h new file mode 100644 index 0000000000000000000000000000000000000000..6e48d65b26ff0fb3307e2fe645741c2d924c1e97 --- /dev/null +++ b/src/plugins/cpptools/cppfunctionsfilter.h @@ -0,0 +1,58 @@ +/*************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** +** Non-Open Source Usage +** +** Licensees may use this file in accordance with the Qt Beta Version +** License Agreement, Agreement version 2.2 provided with the Software or, +** alternatively, in accordance with the terms contained in a written +** agreement between you and Nokia. +** +** GNU General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the packaging +** of this file. Please review the following information to ensure GNU +** General Public Licensing requirements will be met: +** +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt GPL Exception +** version 1.2, included in the file GPL_EXCEPTION.txt in this package. +** +***************************************************************************/ + +#ifndef CPPFUNCTIONSFILTER_H +#define CPPFUNCTIONSFILTER_H + +#include <cppquickopenfilter.h> + +namespace CppTools { +namespace Internal { + +class CppFunctionsFilter : public CppQuickOpenFilter +{ + Q_OBJECT + +public: + CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager); + ~CppFunctionsFilter(); + + QString trName() const { return tr("Methods"); } + QString name() const { return QLatin1String("Methods"); } + Priority priority() const { return Medium; } +}; + +} // namespace Internal +} // namespace CppTools + +#endif // CPPFUNCTIONSFILTER_H diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 5111aa3199673b0f8bca8e6dfa33645517c75f04..40888d99f3f770af4f6461e007a6230503ce0eb9 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -390,17 +390,17 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type) } else { Document::Ptr previousDoc = switchDocument(Document::create(fileName)); - const QByteArray previousFile = env.current_file; + const QByteArray previousFile = env.currentFile; const unsigned previousLine = env.currentLine; - env.current_file = QByteArray(m_currentDoc->translationUnit()->fileName(), - m_currentDoc->translationUnit()->fileNameLength()); + env.currentFile = QByteArray(m_currentDoc->translationUnit()->fileName(), + m_currentDoc->translationUnit()->fileNameLength()); QByteArray preprocessedCode; m_proc(contents, &preprocessedCode); //qDebug() << preprocessedCode; - env.current_file = previousFile; + env.currentFile = previousFile; env.currentLine = previousLine; m_currentDoc->setSource(preprocessedCode); diff --git a/src/plugins/cpptools/cppquickopenfilter.cpp b/src/plugins/cpptools/cppquickopenfilter.cpp index a1f1a9b3713e00c76a967d2922dad17875c48034..ac69c9cc6df9119aff415aed84a08e8de54c9ade 100644 --- a/src/plugins/cpptools/cppquickopenfilter.cpp +++ b/src/plugins/cpptools/cppquickopenfilter.cpp @@ -75,6 +75,12 @@ void CppQuickOpenFilter::refresh(QFutureInterface<void> &future) Q_UNUSED(future); } +static bool compareLexigraphically(const QuickOpen::FilterEntry &a, + const QuickOpen::FilterEntry &b) +{ + return a.displayName < b.displayName; +} + QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &origEntry) { QString entry = trimWildcards(origEntry); @@ -109,6 +115,9 @@ QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &orig } } + if (entries.size() < 1000) + qSort(entries.begin(), entries.end(), compareLexigraphically); + return entries; } diff --git a/src/plugins/cpptools/cpptools.cpp b/src/plugins/cpptools/cpptools.cpp index 957f0cae9b07ed7bf97842baaf316c2dd7bd53a2..5e9f6dca45f2ab3fd333099d4e59822c85bf265c 100644 --- a/src/plugins/cpptools/cpptools.cpp +++ b/src/plugins/cpptools/cpptools.cpp @@ -34,6 +34,7 @@ #include "cpptools.h" #include "cppclassesfilter.h" #include "cppcodecompletion.h" +#include "cppfunctionsfilter.h" #include "cpphoverhandler.h" #include "cppmodelmanager.h" #include "cpptoolsconstants.h" @@ -89,6 +90,7 @@ bool CppToolsPlugin::initialize(const QStringList & /*arguments*/, QString *) m_core->editorManager()); addAutoReleasedObject(quickOpenFilter); addAutoReleasedObject(new CppClassesFilter(m_modelManager, m_core->editorManager())); + addAutoReleasedObject(new CppFunctionsFilter(m_modelManager, m_core->editorManager())); // Menus Core::IActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS); diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro index 92905e42ef9af7659dd58358a3fd7c7d50694b3d..74112379e3904c195bdc5431077e08c6ec32a9b2 100644 --- a/src/plugins/cpptools/cpptools.pro +++ b/src/plugins/cpptools/cpptools.pro @@ -10,15 +10,16 @@ unix:QMAKE_CXXFLAGS_DEBUG += -O3 INCLUDEPATH += . DEFINES += CPPTOOLS_LIBRARY CONFIG += help - HEADERS += cpptools_global.h \ cppquickopenfilter.h \ cppclassesfilter.h \ - searchsymbols.h + searchsymbols.h \ + cppfunctionsfilter.h SOURCES += cppquickopenfilter.cpp \ cpptoolseditorsupport.cpp \ cppclassesfilter.cpp \ - searchsymbols.cpp + searchsymbols.cpp \ + cppfunctionsfilter.cpp # Input SOURCES += cpptools.cpp \ diff --git a/src/plugins/cpptools/searchsymbols.cpp b/src/plugins/cpptools/searchsymbols.cpp index 308449ab581d84738b2c2aff50ae885a6166c78a..2669ea7bc79b70c72f37942faa65d57636a243ac 100644 --- a/src/plugins/cpptools/searchsymbols.cpp +++ b/src/plugins/cpptools/searchsymbols.cpp @@ -35,6 +35,7 @@ #include <Literals.h> #include <Scope.h> +#include <Names.h> using namespace CPlusPlus; using namespace CppTools::Internal; @@ -97,12 +98,24 @@ bool SearchSymbols::visit(Function *symbol) if (!(symbolsToSearchFor & Functions)) return false; + QString extraScope; + if (Name *name = symbol->name()) { + if (QualifiedNameId *nameId = name->asQualifiedNameId()) { + if (nameId->nameCount() > 1) { + extraScope = overview.prettyName(nameId->nameAt(nameId->nameCount() - 2)); + } + } + } + QString fullScope = _scope; + if (!_scope.isEmpty() && !extraScope.isEmpty()) + fullScope += QLatin1String("::"); + fullScope += extraScope; QString name = symbolName(symbol); QString scopedName = scopedSymbolName(name); QString type = overview.prettyType(symbol->type(), - separateScope ? symbol->name() : 0); + separateScope ? symbol->identity() : 0); appendItem(separateScope ? type : scopedName, - separateScope ? _scope : type, + separateScope ? fullScope : type, ModelItemInfo::Method, symbol); return false; } @@ -153,7 +166,7 @@ bool SearchSymbols::visit(Class *symbol) QString SearchSymbols::scopedSymbolName(const QString &symbolName) const { QString name = _scope; - if (! name.isEmpty()) + if (!name.isEmpty()) name += QLatin1String("::"); name += symbolName; return name; @@ -196,6 +209,9 @@ void SearchSymbols::appendItem(const QString &name, ModelItemInfo::ItemType type, const Symbol *symbol) { + if (!symbol->name()) + return; + const QIcon icon = icons.iconForSymbol(symbol); items.append(ModelItemInfo(name, info, type, QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()), diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 926568517daabea3ebae63d3506fda87e2f49d62..e27aa5ec41dd7941e15f6f0bf4ddaeb7114851a4 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -34,7 +34,8 @@ #include "breakhandler.h" #include "imports.h" // TextEditor::BaseTextMark -#include "qtcassert.h" + +#include <utils/qtcassert.h> #include <QtCore/QDebug> #include <QtCore/QFileInfo> diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 6b8c2e74ca45f204ef14028aeb91540da3dd1e22..3d67e19c6aae2337f008e5416c5d18d99ba5c729 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -10,8 +10,6 @@ include(../../plugins/texteditor/texteditor.pri) include(../../plugins/cpptools/cpptools.pri) include(../../libs/cplusplus/cplusplus.pri) -INCLUDEPATH += ../../libs/utils - # DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII QT += gui network script diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 03f86bec2492ed19e0edc4363d8dad7965378551..37406f70cc1a6678e9506c75d320adea5711d544 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -39,7 +39,6 @@ #include "gdboptionpage.h" #include "gdbengine.h" #include "mode.h" -#include "qtcassert.h" #include <coreplugin/actionmanager/actionmanagerinterface.h> #include <coreplugin/coreconstants.h> @@ -48,20 +47,27 @@ #include <coreplugin/messagemanager.h> #include <coreplugin/modemanager.h> #include <coreplugin/uniqueidmanager.h> + #include <cplusplus/ExpressionUnderCursor.h> + #include <cppeditor/cppeditorconstants.h> + #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/session.h> + +#include <texteditor/basetexteditor.h> #include <texteditor/basetextmark.h> #include <texteditor/itexteditor.h> #include <texteditor/texteditorconstants.h> -#include <texteditor/basetexteditor.h> + +#include <utils/qtcassert.h> #include <QtCore/QDebug> #include <QtCore/qplugin.h> #include <QtCore/QObject> #include <QtCore/QPoint> #include <QtCore/QSettings> + #include <QtGui/QPlainTextEdit> #include <QtGui/QTextBlock> #include <QtGui/QTextCursor> diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 13af8e3075bd145450f3d081a6de47567958185d..d7ac5b1aaa1b4897e1c51bcdcb415aefc75ec271 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -37,7 +37,6 @@ #include "debuggermanager.h" #include "gdbmi.h" #include "procinterrupt.h" -#include "qtcassert.h" #include "disassemblerhandler.h" #include "breakhandler.h" @@ -49,6 +48,8 @@ #include "startexternaldialog.h" #include "attachexternaldialog.h" +#include <utils/qtcassert.h> + #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFileInfo> diff --git a/src/plugins/debugger/gdbmi.cpp b/src/plugins/debugger/gdbmi.cpp index 3beadc385fa8067186ac4f5c1f01515c753cd2cf..f14bb752e3e94f8e6b246c13988554cc697d5353 100644 --- a/src/plugins/debugger/gdbmi.cpp +++ b/src/plugins/debugger/gdbmi.cpp @@ -32,10 +32,10 @@ ***************************************************************************/ #include "gdbmi.h" -#include "qtcassert.h" + +#include <utils/qtcassert.h> #include <QtCore/QByteArray> -#include <QtCore/QDebug> #include <QtCore/QTextStream> namespace Debugger { diff --git a/src/plugins/debugger/mode.cpp b/src/plugins/debugger/mode.cpp index c1bbdd550f1039e8d97debd6199d66b0d9377f16..234f09c207931573e8bf8beec889944b410a00bb 100644 --- a/src/plugins/debugger/mode.cpp +++ b/src/plugins/debugger/mode.cpp @@ -35,7 +35,6 @@ #include "debuggerconstants.h" #include "debuggermanager.h" -#include "qtcassert.h" #include <coreplugin/coreconstants.h> #include <coreplugin/icore.h> @@ -48,10 +47,14 @@ #include <coreplugin/outputpane.h> #include <coreplugin/navigationwidget.h> #include <coreplugin/rightpane.h> + #include <projectexplorer/projectexplorerconstants.h> +#include <utils/qtcassert.h> + #include <QtCore/QDebug> #include <QtCore/QSettings> + #include <QtGui/QDockWidget> #include <QtGui/QLabel> #include <QtGui/QMainWindow> diff --git a/src/plugins/debugger/scriptengine.cpp b/src/plugins/debugger/scriptengine.cpp index 50f9dcdf4e27bc1f37c4a71b2b22e1a6d9afaa98..e6387bfdda9a4fa7d09e2d4ab631777cf7f672f1 100644 --- a/src/plugins/debugger/scriptengine.cpp +++ b/src/plugins/debugger/scriptengine.cpp @@ -33,19 +33,18 @@ #include "scriptengine.h" -#include "qtcassert.h" +#include "attachexternaldialog.h" +#include "breakhandler.h" #include "debuggerconstants.h" #include "debuggermanager.h" - #include "disassemblerhandler.h" -#include "breakhandler.h" #include "moduleshandler.h" #include "registerhandler.h" #include "stackhandler.h" +#include "startexternaldialog.h" #include "watchhandler.h" -#include "startexternaldialog.h" -#include "attachexternaldialog.h" +#include <utils/qtcassert.h> #include <QtCore/QDateTime> #include <QtCore/QDebug> diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp index 818b6b6188822020f9f314e2fd0c32818aa80371..fd70e1e1ab9c8f785690b0cfcdd6c28da4cc6595 100644 --- a/src/plugins/debugger/stackhandler.cpp +++ b/src/plugins/debugger/stackhandler.cpp @@ -33,7 +33,7 @@ #include "stackhandler.h" -#include "qtcassert.h" +#include <utils/qtcassert.h> #include <QtCore/QAbstractTableModel> #include <QtCore/QDebug> diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index e03c91f71003e04d15325b20dbba770071bb0b51..053fcadcd199ea8915dc09342b8b9d4462239ec7 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -37,7 +37,7 @@ #include "modeltest.h" #endif -#include "qtcassert.h" +#include <utils/qtcassert.h> #include <QtCore/QDebug> #include <QtCore/QEvent> @@ -118,7 +118,7 @@ static QByteArray quoteUnprintable(const QByteArray &ba) QByteArray res; char buf[10]; for (int i = 0, n = ba.size(); i != n; ++i) { - char c = ba.at(i); + unsigned char c = ba.at(i); if (isprint(c)) { res += c; } else { diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp index 1c30bbe10944bb3a5230931fcb911133291336bf..7c85aae6ae36a04e85c350bbb0c4dfbf2754d297 100644 --- a/src/plugins/projectexplorer/projectnodes.cpp +++ b/src/plugins/projectexplorer/projectnodes.cpp @@ -314,8 +314,8 @@ void ProjectNode::addProjectNodes(const QList<ProjectNode*> &subProjects) emit watcher->foldersAboutToBeAdded(this, folderNodes); foreach (ProjectNode *project, subProjects) { - Q_ASSERT_X(!project->parentFolderNode(), "addProjectNodes", - "Project node has already a parent"); + QTC_ASSERT(!project->parentFolderNode(), + qDebug("Project node has already a parent")); project->setParentFolderNode(this); foreach (NodesWatcher *watcher, m_watchers) project->registerWatcher(watcher); @@ -353,13 +353,13 @@ void ProjectNode::removeProjectNodes(const QList<ProjectNode*> &subProjects) for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) { while ((*projectIter)->path() != (*toRemoveIter)->path()) { ++projectIter; - Q_ASSERT_X(projectIter != m_subProjectNodes.end(), "removeProjectNodes", - "Project to remove is not part of specified folder!"); + QTC_ASSERT(projectIter != m_subProjectNodes.end(), + qDebug("Project to remove is not part of specified folder!")); } while ((*folderIter)->path() != (*toRemoveIter)->path()) { ++folderIter; - Q_ASSERT_X(folderIter != m_subFolderNodes.end(), "removeProjectNodes", - "Project to remove is not part of specified folder!"); + QTC_ASSERT(folderIter != m_subFolderNodes.end(), + qDebug("Project to remove is not part of specified folder!")); } delete *projectIter; projectIter = m_subProjectNodes.erase(projectIter); @@ -386,15 +386,15 @@ void ProjectNode::addFolderNodes(const QList<FolderNode*> &subFolders, FolderNod watcher->foldersAboutToBeAdded(parentFolder, subFolders); foreach (FolderNode *folder, subFolders) { - Q_ASSERT_X(!folder->parentFolderNode(), "addFolderNodes", - "Project node has already a parent folder"); + QTC_ASSERT(!folder->parentFolderNode(), + qDebug("Project node has already a parent folder")); folder->setParentFolderNode(parentFolder); folder->setProjectNode(this); parentFolder->m_subFolderNodes.append(folder); // project nodes have to be added via addProjectNodes - Q_ASSERT_X(folder->nodeType() != ProjectNodeType, "addFolderNodes", - "project nodes have to be added via addProjectNodes"); + QTC_ASSERT(folder->nodeType() != ProjectNodeType, + qDebug("project nodes have to be added via addProjectNodes")); } qSort(parentFolder->m_subFolderNodes.begin(), parentFolder->m_subFolderNodes.end(), sortNodesByPath); @@ -427,12 +427,12 @@ void ProjectNode::removeFolderNodes(const QList<FolderNode*> &subFolders, QList<FolderNode*>::const_iterator toRemoveIter = toRemove.constBegin(); QList<FolderNode*>::iterator folderIter = parentFolder->m_subFolderNodes.begin(); for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) { - Q_ASSERT_X(((*toRemoveIter)->nodeType() != ProjectNodeType), "removeFolderNodes", - "project nodes have to be removed via removeProjectNodes"); + QTC_ASSERT((*toRemoveIter)->nodeType() != ProjectNodeType, + qDebug("project nodes have to be removed via removeProjectNodes")); while ((*folderIter)->path() != (*toRemoveIter)->path()) { ++folderIter; - Q_ASSERT_X(folderIter != parentFolder->m_subFolderNodes.end(), "removeFileNodes", - "Folder to remove is not part of specified folder!"); + QTC_ASSERT(folderIter != parentFolder->m_subFolderNodes.end(), + qDebug("Folder to remove is not part of specified folder!")); } delete *folderIter; folderIter = parentFolder->m_subFolderNodes.erase(folderIter); @@ -460,8 +460,8 @@ void ProjectNode::addFileNodes(const QList<FileNode*> &files, FolderNode *folder emit watcher->filesAboutToBeAdded(folder, files); foreach (FileNode *file, files) { - Q_ASSERT_X(!file->parentFolderNode(), "addFileNodes", - "File node has already a parent folder"); + QTC_ASSERT(!file->parentFolderNode(), + qDebug("File node has already a parent folder")); file->setParentFolderNode(folder); file->setProjectNode(this); @@ -499,8 +499,8 @@ void ProjectNode::removeFileNodes(const QList<FileNode*> &files, FolderNode *fol for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) { while ((*filesIter)->path() != (*toRemoveIter)->path()) { ++filesIter; - Q_ASSERT_X(filesIter != folder->m_fileNodes.end(), "removeFileNodes", - "File to remove is not part of specified folder!"); + QTC_ASSERT(filesIter != folder->m_fileNodes.end(), + qDebug("File to remove is not part of specified folder!")); } delete *filesIter; filesIter = folder->m_fileNodes.erase(filesIter); @@ -591,8 +591,8 @@ void SessionNode::addProjectNodes(const QList<ProjectNode*> &projectNodes) emit watcher->foldersAboutToBeAdded(this, folderNodes); foreach (ProjectNode *project, projectNodes) { - Q_ASSERT_X(!project->parentFolderNode(), "addProjectNodes", - "Project node has already a parent folder"); + QTC_ASSERT(!project->parentFolderNode(), + qDebug("Project node has already a parent folder")); project->setParentFolderNode(this); foreach (NodesWatcher *watcher, m_watchers) project->registerWatcher(watcher); @@ -621,13 +621,13 @@ void SessionNode::removeProjectNodes(const QList<ProjectNode*> &projectNodes) for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) { while ((*projectIter)->path() != (*toRemoveIter)->path()) { ++projectIter; - Q_ASSERT_X(projectIter != m_projectNodes.end(), "removeProjectNodes", - "Project to remove is not part of specified folder!"); + QTC_ASSERT(projectIter != m_projectNodes.end(), + qDebug("Project to remove is not part of specified folder!")); } while ((*folderIter)->path() != (*toRemoveIter)->path()) { ++folderIter; - Q_ASSERT_X(folderIter != m_subFolderNodes.end(), "removeProjectNodes", - "Project to remove is not part of specified folder!"); + QTC_ASSERT(folderIter != m_subFolderNodes.end(), + qDebug("Project to remove is not part of specified folder!")); } projectIter = m_projectNodes.erase(projectIter); folderIter = m_subFolderNodes.erase(folderIter); diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 236b2069ae003da21c929f6083b0aca6e31ad783..2e3131e36fc1e634be08786b62d15ec4d28a5092 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -257,7 +257,7 @@ TaskWindow::TaskWindow() m_listview->setModel(m_model); m_listview->setFrameStyle(QFrame::NoFrame); - m_listview->setWindowTitle(tr("Problems")); + m_listview->setWindowTitle(tr("Build Issues")); m_listview->setSelectionMode(QAbstractItemView::SingleSelection); TaskDelegate *tld = new TaskDelegate(this); m_listview->setItemDelegate(tld); diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index 702534115309eb1b95c137dd9c34025faa5f42af..a3bdf47621dcccfa5bd6261a29b2e2a630d134b7 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -63,7 +63,7 @@ public: QWidget *outputWidget(QWidget *); QList<QWidget*> toolBarWidgets(void) const; - QString name() const { return tr("Problems"); } + QString name() const { return tr("Build Issues"); } int priorityInStatusBar() const; void clearContents(); void visibilityChanged(bool visible); diff --git a/src/plugins/qt4projectmanager/directorywatcher.cpp b/src/plugins/qt4projectmanager/directorywatcher.cpp index 689cd0dfd036e8dadfeef940a2058ff3d9e3bebc..daf478348381c889e06768a0edae9578d2904d62 100644 --- a/src/plugins/qt4projectmanager/directorywatcher.cpp +++ b/src/plugins/qt4projectmanager/directorywatcher.cpp @@ -203,5 +203,59 @@ void DirectoryWatcher::updateFileList(const QString &dir) } } +int FileWatcher::m_objectCount = 0; +QHash<QString,int> FileWatcher::m_fileCount; +QFileSystemWatcher *FileWatcher::m_watcher = 0; + +FileWatcher::FileWatcher(QObject *parent) +{ + if (!m_watcher) + m_watcher = new QFileSystemWatcher(); + ++m_objectCount; + connect(m_watcher, SIGNAL(fileChanged(QString)), + this, SLOT(slotFileChanged(QString))); +} + +FileWatcher::~FileWatcher() +{ + foreach (const QString &file, m_files) + removeFile(file); + if (--m_objectCount == 0) { + delete m_watcher; + m_watcher = 0; + } +} + +void FileWatcher::slotFileChanged(const QString &file) +{ + if (m_files.contains(file)) + emit fileChanged(file); +} + +QStringList FileWatcher::files() +{ + return m_files; +} + +void FileWatcher::addFile(const QString &file) +{ + if (m_files.contains(file)) + return; + m_files += file; + if (m_fileCount[file] == 0) + m_watcher->addPath(file); + m_fileCount[file] += 1; +} + +void FileWatcher::removeFile(const QString &file) +{ + m_files.removeOne(file); + m_fileCount[file] -= 1; + if (m_fileCount[file] == 0) + m_watcher->removePath(file); +} + + + } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/directorywatcher.h b/src/plugins/qt4projectmanager/directorywatcher.h index 3f5f5a846fa1a62484a8a5cc99ce53f9d1157c79..b529ec07e7835281c1b0d02c0974bc11d0acf944 100644 --- a/src/plugins/qt4projectmanager/directorywatcher.h +++ b/src/plugins/qt4projectmanager/directorywatcher.h @@ -87,6 +87,31 @@ private: FileModificationTimeMap m_files; }; +class FileWatcher : public QObject +{ + Q_DISABLE_COPY(FileWatcher) + Q_OBJECT +public: + explicit FileWatcher(QObject *parent = 0); + virtual ~FileWatcher(); + + QStringList files(); + void addFile(const QString &file); + void removeFile(const QString &file); +signals: + void fileChanged(const QString &path); + void debugOutout(const QString &path); + +private slots: + void slotFileChanged(const QString&); + +private: + static int m_objectCount; + static QHash<QString, int> m_fileCount; + static QFileSystemWatcher *m_watcher; + QStringList m_files; +}; + } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index 58486fd9a13e5b3d2e2a76c506475918bfee2374..dc004580b2b40ea858288e5fcc8af58b48a75803 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -87,11 +87,20 @@ Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project, Qt4ProFileNode* qt4ProFileNo m_project(project), m_qt4ProFileNode(qt4ProFileNode), m_projectFilePath(QDir::fromNativeSeparators(filePath)), - m_projectDir(QFileInfo(filePath).absolutePath()) + m_projectDir(QFileInfo(filePath).absolutePath()), + m_fileWatcher(new FileWatcher(this)) { QTC_ASSERT(project, return); setFolderName(QFileInfo(filePath).baseName()); setIcon(QIcon(":/qt4projectmanager/images/qt_project.png")); + m_fileWatcher->addFile(filePath); + connect(m_fileWatcher, SIGNAL(fileChanged(QString)), + this, SLOT(scheduleUpdate())); +} + +void Qt4PriFileNode::scheduleUpdate() +{ + m_qt4ProFileNode->scheduleUpdate(); } void Qt4PriFileNode::update(ProFile *includeFile, ProFileReader *reader) @@ -495,12 +504,17 @@ Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project, if (parent) setParent(parent); + m_updateTimer.setInterval(100); + m_updateTimer.setSingleShot(true); + connect(m_dirWatcher, SIGNAL(directoryChanged(const QString&)), - this, SLOT(update())); + this, SLOT(updateGeneratedFiles())); connect(m_dirWatcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(const QString&))); connect(m_project, SIGNAL(activeBuildConfigurationChanged()), this, SLOT(update())); + connect(&m_updateTimer, SIGNAL(timeout()), + this, SLOT(update())); } Qt4ProFileNode::~Qt4ProFileNode() @@ -523,6 +537,11 @@ QStringList Qt4ProFileNode::variableValue(const Qt4Variable var) const return m_varValues.value(var); } +void Qt4ProFileNode::scheduleUpdate() +{ + m_updateTimer.start(); +} + void Qt4ProFileNode::update() { ProFileReader *reader = createProFileReader(); @@ -681,9 +700,11 @@ void Qt4ProFileNode::update() void Qt4ProFileNode::fileChanged(const QString &filePath) { + qDebug()<<"+++++"<<filePath; CppTools::CppModelManagerInterface *modelManager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>(); + // TODO compress modelManager->updateSourceFiles(QStringList() << filePath); } @@ -731,11 +752,16 @@ void Qt4ProFileNode::updateGeneratedFiles() // update generated files + // Already existing FileNodes QList<FileNode*> existingFileNodes; foreach (FileNode *file, fileNodes()) { if (file->isGenerated()) existingFileNodes << file; } + + + // Convert uiFile to uiHeaderFilePath, find all headers that correspond + // and try to find them in uicDirs QStringList newFilePaths; foreach (const QString &uicDir, m_varValues[UiDirVar]) { foreach (FileNode *uiFile, uiFiles) { diff --git a/src/plugins/qt4projectmanager/qt4nodes.h b/src/plugins/qt4projectmanager/qt4nodes.h index 97bc06a08f4f264946d5f209c1a812ba5b6986f3..6b858bc52594ba4855e163c38c4637a540606d0e 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.h +++ b/src/plugins/qt4projectmanager/qt4nodes.h @@ -75,6 +75,7 @@ using ProjectExplorer::FileType; class ProFileReader; class DirectoryWatcher; +class FileWatcher; // Type of projects enum Qt4ProjectType { @@ -142,6 +143,9 @@ protected: QString buildDir() const; ProFileReader *createProFileReader() const; +private slots: + void scheduleUpdate(); + private: void save(ProFile *includeFile); bool priFileWritable(const QString &path); @@ -151,7 +155,10 @@ private: Qt4ProFileNode *m_qt4ProFileNode; QString m_projectFilePath; QString m_projectDir; - QTimer *m_saveTimer; + + // TODO we might be better off using an IFile* and the FileManager for + // watching changes to the .pro and .pri files on disk + FileWatcher *m_fileWatcher; // managed by Qt4ProFileNode friend class Qt4ProFileNode; @@ -174,14 +181,13 @@ public: QStringList variableValue(const Qt4Variable var) const; public slots: + void scheduleUpdate(); void update(); - private slots: void fileChanged(const QString &filePath); - -private: void updateGeneratedFiles(); +private: Qt4ProFileNode *createSubProFileNode(const QString &path); QStringList uiDirPaths(ProFileReader *reader) const; @@ -197,9 +203,9 @@ private: Qt4ProjectType m_projectType; QHash<Qt4Variable, QStringList> m_varValues; bool m_isQBuildProject; + QTimer m_updateTimer; DirectoryWatcher *m_dirWatcher; - friend class Qt4NodeHierarchy; }; diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index edaabdf154eb6b51f415007227f13f4a2cb0326b..c926320193701e29529bfb93d396ad2650eaf6d7 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -265,7 +265,7 @@ Qt4Project::~Qt4Project() void Qt4Project::defaultQtVersionChanged() { if (qtVersionId(activeBuildConfiguration()) == 0) - update(); + m_rootProjectNode->update(); } void Qt4Project::qtVersionsChanged() @@ -274,7 +274,7 @@ void Qt4Project::qtVersionsChanged() if (!qt4ProjectManager()->versionManager()->version(qtVersionId(bc))->isValid()) { setQtVersion(bc, 0); if (bc == activeBuildConfiguration()) - update(); + m_rootProjectNode->update(); } } } @@ -507,9 +507,9 @@ void Qt4Project::updateCodeModel() } -/*! - Updates complete project - */ +///*! +// Updates complete project +// */ void Qt4Project::update() { // TODO Maybe remove this method completely?