2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-11-28 15:36:54 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2008-11-28 15:36:54 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-11-28 15:36:54 +01:00
|
|
|
**
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-11-28 15:36:54 +01:00
|
|
|
**
|
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.
|
2008-11-28 15:36:54 +01: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.
|
2008-11-28 15:36:54 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-11-28 15:36:54 +01:00
|
|
|
|
|
|
|
|
#ifndef SEARCHSYMBOLS_H
|
|
|
|
|
#define SEARCHSYMBOLS_H
|
|
|
|
|
|
|
|
|
|
#include <cplusplus/CppDocument.h>
|
|
|
|
|
#include <cplusplus/Icons.h>
|
|
|
|
|
#include <cplusplus/Overview.h>
|
|
|
|
|
#include <Symbols.h>
|
|
|
|
|
#include <SymbolVisitor.h>
|
|
|
|
|
|
2010-09-16 14:59:05 +02:00
|
|
|
#include <QtGui/QIcon>
|
|
|
|
|
#include <QtCore/QMetaType>
|
|
|
|
|
#include <QtCore/QString>
|
|
|
|
|
#include <QtCore/QSet>
|
|
|
|
|
#include <QtCore/QHash>
|
2008-11-28 15:36:54 +01:00
|
|
|
|
2008-12-05 16:39:33 +01:00
|
|
|
#include <functional>
|
|
|
|
|
|
2008-11-28 15:36:54 +01:00
|
|
|
namespace CppTools {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
struct ModelItemInfo
|
|
|
|
|
{
|
2009-05-14 21:08:08 +02:00
|
|
|
enum ItemType { Enum, Class, Method, Declaration };
|
2008-11-28 15:36:54 +01:00
|
|
|
|
|
|
|
|
ModelItemInfo()
|
2009-10-21 16:47:28 +02:00
|
|
|
: type(Declaration),
|
2010-07-19 14:46:53 +02:00
|
|
|
line(0),
|
|
|
|
|
column(0)
|
2008-11-28 15:36:54 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
ModelItemInfo(const QString &symbolName,
|
|
|
|
|
const QString &symbolType,
|
|
|
|
|
ItemType type,
|
2010-07-19 14:46:53 +02:00
|
|
|
QStringList fullyQualifiedName,
|
2008-11-28 15:36:54 +01:00
|
|
|
const QString &fileName,
|
|
|
|
|
int line,
|
2010-07-20 12:21:27 +02:00
|
|
|
int column,
|
2008-11-28 15:36:54 +01:00
|
|
|
const QIcon &icon)
|
|
|
|
|
: symbolName(symbolName),
|
|
|
|
|
symbolType(symbolType),
|
2010-07-19 14:46:53 +02:00
|
|
|
fullyQualifiedName(fullyQualifiedName),
|
2008-11-28 15:36:54 +01:00
|
|
|
fileName(fileName),
|
2010-09-06 16:46:23 +02:00
|
|
|
icon(icon),
|
|
|
|
|
type(type),
|
2008-11-28 15:36:54 +01:00
|
|
|
line(line),
|
2010-09-06 16:46:23 +02:00
|
|
|
column(column)
|
2008-11-28 15:36:54 +01:00
|
|
|
{ }
|
|
|
|
|
|
2010-07-19 14:46:53 +02:00
|
|
|
ModelItemInfo(const ModelItemInfo &otherInfo)
|
|
|
|
|
: symbolName(otherInfo.symbolName),
|
|
|
|
|
symbolType(otherInfo.symbolType),
|
|
|
|
|
fullyQualifiedName(otherInfo.fullyQualifiedName),
|
|
|
|
|
fileName(otherInfo.fileName),
|
2010-09-06 16:46:23 +02:00
|
|
|
icon(otherInfo.icon),
|
|
|
|
|
type(otherInfo.type),
|
2010-07-19 14:46:53 +02:00
|
|
|
line(otherInfo.line),
|
2010-09-06 16:46:23 +02:00
|
|
|
column(otherInfo.column)
|
2010-07-19 14:46:53 +02:00
|
|
|
{ }
|
|
|
|
|
|
2008-11-28 15:36:54 +01:00
|
|
|
QString symbolName;
|
|
|
|
|
QString symbolType;
|
2010-07-19 14:46:53 +02:00
|
|
|
QStringList fullyQualifiedName;
|
2008-11-28 15:36:54 +01:00
|
|
|
QString fileName;
|
2010-09-06 16:46:23 +02:00
|
|
|
QIcon icon;
|
|
|
|
|
ItemType type;
|
2008-11-28 15:36:54 +01:00
|
|
|
int line;
|
2010-07-20 12:21:27 +02:00
|
|
|
int column;
|
2008-11-28 15:36:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SearchSymbols: public std::unary_function<CPlusPlus::Document::Ptr, QList<ModelItemInfo> >,
|
|
|
|
|
protected CPlusPlus::SymbolVisitor
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum SymbolType {
|
2009-05-14 21:08:08 +02:00
|
|
|
Classes = 0x1,
|
|
|
|
|
Functions = 0x2,
|
|
|
|
|
Enums = 0x4,
|
|
|
|
|
Declarations = 0x8
|
2008-11-28 15:36:54 +01:00
|
|
|
};
|
2010-07-19 14:46:53 +02:00
|
|
|
|
2008-12-05 09:02:08 +01:00
|
|
|
Q_DECLARE_FLAGS(SymbolTypes, SymbolType)
|
2008-11-28 15:36:54 +01:00
|
|
|
|
2010-07-19 14:46:53 +02:00
|
|
|
static SymbolTypes AllTypes;
|
|
|
|
|
|
2008-11-28 15:36:54 +01:00
|
|
|
SearchSymbols();
|
|
|
|
|
|
2008-12-05 09:02:08 +01:00
|
|
|
void setSymbolsToSearchFor(SymbolTypes types);
|
2008-12-05 12:21:18 +01:00
|
|
|
void setSeparateScope(bool separateScope);
|
2008-11-28 15:36:54 +01:00
|
|
|
|
|
|
|
|
QList<ModelItemInfo> operator()(CPlusPlus::Document::Ptr doc)
|
|
|
|
|
{ return operator()(doc, QString()); }
|
|
|
|
|
|
|
|
|
|
QList<ModelItemInfo> operator()(CPlusPlus::Document::Ptr doc, const QString &scope);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
using SymbolVisitor::visit;
|
|
|
|
|
|
|
|
|
|
void accept(CPlusPlus::Symbol *symbol)
|
|
|
|
|
{ CPlusPlus::Symbol::visitSymbol(symbol, this); }
|
|
|
|
|
|
|
|
|
|
QString switchScope(const QString &scope);
|
2010-09-08 14:21:19 +02:00
|
|
|
|
|
|
|
|
virtual bool visit(CPlusPlus::UsingNamespaceDirective *);
|
|
|
|
|
virtual bool visit(CPlusPlus::UsingDeclaration *);
|
|
|
|
|
virtual bool visit(CPlusPlus::NamespaceAlias *);
|
|
|
|
|
virtual bool visit(CPlusPlus::Declaration *);
|
|
|
|
|
virtual bool visit(CPlusPlus::Argument *);
|
|
|
|
|
virtual bool visit(CPlusPlus::TypenameArgument *);
|
|
|
|
|
virtual bool visit(CPlusPlus::BaseClass *);
|
|
|
|
|
virtual bool visit(CPlusPlus::Enum *);
|
|
|
|
|
virtual bool visit(CPlusPlus::Function *);
|
|
|
|
|
virtual bool visit(CPlusPlus::Namespace *);
|
|
|
|
|
virtual bool visit(CPlusPlus::Template *);
|
|
|
|
|
virtual bool visit(CPlusPlus::Class *);
|
|
|
|
|
virtual bool visit(CPlusPlus::Block *);
|
|
|
|
|
virtual bool visit(CPlusPlus::ForwardClassDeclaration *);
|
|
|
|
|
|
|
|
|
|
// Objective-C
|
|
|
|
|
virtual bool visit(CPlusPlus::ObjCBaseClass *);
|
|
|
|
|
virtual bool visit(CPlusPlus::ObjCBaseProtocol *);
|
|
|
|
|
virtual bool visit(CPlusPlus::ObjCClass *);
|
|
|
|
|
virtual bool visit(CPlusPlus::ObjCForwardClassDeclaration *);
|
|
|
|
|
virtual bool visit(CPlusPlus::ObjCProtocol *);
|
|
|
|
|
virtual bool visit(CPlusPlus::ObjCForwardProtocolDeclaration *);
|
|
|
|
|
virtual bool visit(CPlusPlus::ObjCMethod *);
|
|
|
|
|
virtual bool visit(CPlusPlus::ObjCPropertyDeclaration *);
|
2008-12-05 12:21:18 +01:00
|
|
|
|
|
|
|
|
QString scopedSymbolName(const QString &symbolName) const;
|
|
|
|
|
QString scopedSymbolName(const CPlusPlus::Symbol *symbol) const;
|
2008-11-28 15:36:54 +01:00
|
|
|
QString symbolName(const CPlusPlus::Symbol *symbol) const;
|
2008-12-05 12:21:18 +01:00
|
|
|
void appendItem(const QString &name,
|
|
|
|
|
const QString &info,
|
|
|
|
|
ModelItemInfo::ItemType type,
|
2010-07-19 14:46:53 +02:00
|
|
|
CPlusPlus::Symbol *symbol);
|
2008-11-28 15:36:54 +01:00
|
|
|
|
|
|
|
|
private:
|
2008-12-05 12:21:18 +01:00
|
|
|
QString findOrInsert(const QString &s)
|
|
|
|
|
{ return *strings.insert(s); }
|
|
|
|
|
|
|
|
|
|
QSet<QString> strings; // Used to avoid QString duplication
|
|
|
|
|
|
2008-11-28 15:36:54 +01:00
|
|
|
QString _scope;
|
|
|
|
|
CPlusPlus::Overview overview;
|
|
|
|
|
CPlusPlus::Icons icons;
|
|
|
|
|
QList<ModelItemInfo> items;
|
2008-12-05 09:02:08 +01:00
|
|
|
SymbolTypes symbolsToSearchFor;
|
2010-09-06 16:46:23 +02:00
|
|
|
QHash<const CPlusPlus::StringLiteral *, QString> m_paths;
|
2008-12-05 12:21:18 +01:00
|
|
|
bool separateScope;
|
2008-11-28 15:36:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CppTools
|
|
|
|
|
|
2010-01-07 13:53:48 +01:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(CppTools::Internal::SearchSymbols::SymbolTypes)
|
2008-11-28 15:36:54 +01:00
|
|
|
Q_DECLARE_METATYPE(CppTools::Internal::ModelItemInfo)
|
|
|
|
|
|
|
|
|
|
#endif // SEARCHSYMBOLS_H
|