2009-08-07 13:02:36 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2009-08-07 13:02:36 +02:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-08-07 13:02:36 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-08-07 13:02:36 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2009-08-07 13:02:36 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef CPPFINDREFERENCES_H
|
|
|
|
|
#define CPPFINDREFERENCES_H
|
|
|
|
|
|
2011-09-07 20:28:04 +02:00
|
|
|
#include <utils/filesearch.h>
|
|
|
|
|
#include <cplusplus/CppDocument.h>
|
|
|
|
|
#include <cplusplus/DependencyTable.h>
|
|
|
|
|
#include <cplusplus/FindUsages.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QMutex>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QFuture>
|
|
|
|
|
#include <QFutureWatcher>
|
|
|
|
|
#include <QMetaType>
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2010-03-17 14:18:32 +01:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QTimer)
|
|
|
|
|
|
2009-08-07 13:02:36 +02:00
|
|
|
namespace Find {
|
2009-10-05 16:01:50 +02:00
|
|
|
struct SearchResultItem;
|
2011-09-02 11:51:31 +02:00
|
|
|
class SearchResult;
|
2011-02-04 09:52:39 +01:00
|
|
|
} // namespace Find
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
namespace CPlusPlus {
|
2009-10-12 10:38:00 +02:00
|
|
|
class CppModelManagerInterface;
|
2010-12-03 13:49:35 +01:00
|
|
|
}
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
namespace CppTools {
|
2009-10-12 10:38:00 +02:00
|
|
|
namespace Internal {
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2011-12-20 18:45:29 +01:00
|
|
|
class CppFindReferencesParameters
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CPlusPlus::LookupContext context;
|
|
|
|
|
CPlusPlus::Symbol *symbol;
|
|
|
|
|
};
|
|
|
|
|
|
2009-08-07 13:02:36 +02:00
|
|
|
class CppFindReferences: public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2010-12-03 13:49:35 +01:00
|
|
|
CppFindReferences(CPlusPlus::CppModelManagerInterface *modelManager);
|
2009-08-07 13:02:36 +02:00
|
|
|
virtual ~CppFindReferences();
|
|
|
|
|
|
2010-05-31 12:09:28 +02:00
|
|
|
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) const;
|
2009-09-30 13:25:40 +02:00
|
|
|
|
2009-08-07 13:02:36 +02:00
|
|
|
public:
|
2010-05-31 12:09:28 +02:00
|
|
|
void findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
2010-07-20 11:02:37 +02:00
|
|
|
void renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context,
|
|
|
|
|
const QString &replacement = QString());
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2009-12-21 14:54:10 +01:00
|
|
|
void findMacroUses(const CPlusPlus::Macro ¯o);
|
|
|
|
|
|
2010-09-10 14:16:06 +02:00
|
|
|
CPlusPlus::DependencyTable updateDependencyTable(CPlusPlus::Snapshot snapshot);
|
|
|
|
|
|
2009-08-07 13:02:36 +02:00
|
|
|
private Q_SLOTS:
|
2009-12-01 17:07:35 +01:00
|
|
|
void displayResults(int first, int last);
|
2009-08-07 13:02:36 +02:00
|
|
|
void searchFinished();
|
2011-09-09 08:46:51 +02:00
|
|
|
void cancel();
|
2012-05-25 16:45:18 +02:00
|
|
|
void setPaused(bool paused);
|
2009-10-05 16:01:50 +02:00
|
|
|
void openEditor(const Find::SearchResultItem &item);
|
2009-10-05 18:02:46 +02:00
|
|
|
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
|
2011-12-20 18:45:29 +01:00
|
|
|
void searchAgain();
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2009-10-05 15:17:25 +02:00
|
|
|
private:
|
2011-12-20 18:45:29 +01:00
|
|
|
void findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context,
|
|
|
|
|
const QString &replacement, bool replace);
|
|
|
|
|
void findAll_helper(Find::SearchResult *search);
|
2010-09-10 14:16:06 +02:00
|
|
|
CPlusPlus::DependencyTable dependencyTable() const;
|
|
|
|
|
void setDependencyTable(const CPlusPlus::DependencyTable &newTable);
|
2011-12-20 10:44:13 +01:00
|
|
|
void createWatcher(const QFuture<CPlusPlus::Usage> &future, Find::SearchResult *search);
|
2011-12-20 18:45:29 +01:00
|
|
|
bool findSymbol(CppFindReferencesParameters *parameters,
|
|
|
|
|
const CPlusPlus::Snapshot &snapshot);
|
2009-10-05 15:17:25 +02:00
|
|
|
|
2009-08-07 13:02:36 +02:00
|
|
|
private:
|
2010-12-03 13:49:35 +01:00
|
|
|
QPointer<CPlusPlus::CppModelManagerInterface> _modelManager;
|
2011-12-20 10:44:13 +01:00
|
|
|
QMap<QFutureWatcher<CPlusPlus::Usage> *, QPointer<Find::SearchResult> > m_watchers;
|
2010-09-10 14:16:06 +02:00
|
|
|
|
|
|
|
|
mutable QMutex m_depsLock;
|
2010-03-17 12:34:29 +01:00
|
|
|
CPlusPlus::DependencyTable m_deps;
|
2009-08-07 13:02:36 +02:00
|
|
|
};
|
|
|
|
|
|
2011-02-04 09:52:39 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CppTools
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2011-12-20 18:45:29 +01:00
|
|
|
Q_DECLARE_METATYPE(CppTools::Internal::CppFindReferencesParameters)
|
|
|
|
|
|
2009-08-07 13:02:36 +02:00
|
|
|
#endif // CPPFINDREFERENCES_H
|