2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-11-28 15:36:54 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-11-28 15:36:54 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-11-28 15:36:54 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-11-28 15:36:54 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-11-28 15:36:54 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-11-28 15:36:54 +01:00
|
|
|
|
2011-11-25 12:05:58 +01:00
|
|
|
#include "cpptools_global.h"
|
2012-11-23 11:47:39 +01:00
|
|
|
#include "cppindexingsupport.h"
|
2014-04-14 16:52:01 +02:00
|
|
|
#include "indexitem.h"
|
2012-11-23 11:47:39 +01:00
|
|
|
|
2008-11-28 15:36:54 +01:00
|
|
|
#include <cplusplus/CppDocument.h>
|
|
|
|
|
#include <cplusplus/Overview.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QSet>
|
|
|
|
|
#include <QHash>
|
2008-11-28 15:36:54 +01:00
|
|
|
|
|
|
|
|
namespace CppTools {
|
|
|
|
|
|
2014-03-13 16:53:17 +01:00
|
|
|
class SearchSymbols: protected CPlusPlus::SymbolVisitor
|
2008-11-28 15:36:54 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2019-02-07 10:09:21 +01:00
|
|
|
using SymbolTypes = SymbolSearcher::SymbolTypes;
|
2008-11-28 15:36:54 +01:00
|
|
|
|
2010-07-19 14:46:53 +02:00
|
|
|
static SymbolTypes AllTypes;
|
|
|
|
|
|
2018-02-07 13:18:48 +01:00
|
|
|
SearchSymbols();
|
2008-11-28 15:36:54 +01:00
|
|
|
|
2014-05-19 18:32:38 +03:00
|
|
|
void setSymbolsToSearchFor(const SymbolTypes &types);
|
2008-11-28 15:36:54 +01:00
|
|
|
|
2014-04-14 16:52:01 +02:00
|
|
|
IndexItem::Ptr operator()(CPlusPlus::Document::Ptr doc)
|
|
|
|
|
{ return operator()(doc, QString()); }
|
2008-11-28 15:36:54 +01:00
|
|
|
|
2014-04-14 16:52:01 +02:00
|
|
|
IndexItem::Ptr operator()(CPlusPlus::Document::Ptr doc, const QString &scope);
|
2008-11-28 15:36:54 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
using SymbolVisitor::visit;
|
|
|
|
|
|
|
|
|
|
void accept(CPlusPlus::Symbol *symbol)
|
|
|
|
|
{ CPlusPlus::Symbol::visitSymbol(symbol, this); }
|
|
|
|
|
|
2018-05-07 15:06:32 +02:00
|
|
|
bool visit(CPlusPlus::UsingNamespaceDirective *) override;
|
|
|
|
|
bool visit(CPlusPlus::UsingDeclaration *) override;
|
|
|
|
|
bool visit(CPlusPlus::NamespaceAlias *) override;
|
|
|
|
|
bool visit(CPlusPlus::Declaration *) override;
|
|
|
|
|
bool visit(CPlusPlus::Argument *) override;
|
|
|
|
|
bool visit(CPlusPlus::TypenameArgument *) override;
|
|
|
|
|
bool visit(CPlusPlus::BaseClass *) override;
|
|
|
|
|
bool visit(CPlusPlus::Enum *) override;
|
|
|
|
|
bool visit(CPlusPlus::Function *) override;
|
|
|
|
|
bool visit(CPlusPlus::Namespace *) override;
|
|
|
|
|
bool visit(CPlusPlus::Template *) override;
|
|
|
|
|
bool visit(CPlusPlus::Class *) override;
|
|
|
|
|
bool visit(CPlusPlus::Block *) override;
|
|
|
|
|
bool visit(CPlusPlus::ForwardClassDeclaration *) override;
|
2010-09-08 14:21:19 +02:00
|
|
|
|
|
|
|
|
// Objective-C
|
2018-05-07 15:06:32 +02:00
|
|
|
bool visit(CPlusPlus::ObjCBaseClass *) override;
|
|
|
|
|
bool visit(CPlusPlus::ObjCBaseProtocol *) override;
|
|
|
|
|
bool visit(CPlusPlus::ObjCClass *symbol) override;
|
|
|
|
|
bool visit(CPlusPlus::ObjCForwardClassDeclaration *) override;
|
|
|
|
|
bool visit(CPlusPlus::ObjCProtocol *symbol) override;
|
|
|
|
|
bool visit(CPlusPlus::ObjCForwardProtocolDeclaration *) override;
|
|
|
|
|
bool visit(CPlusPlus::ObjCMethod *symbol) override;
|
|
|
|
|
bool visit(CPlusPlus::ObjCPropertyDeclaration *symbol) override;
|
2008-12-05 12:21:18 +01:00
|
|
|
|
2014-02-25 16:57:18 +01:00
|
|
|
QString scopedSymbolName(const QString &symbolName, const CPlusPlus::Symbol *symbol) const;
|
2008-12-05 12:21:18 +01:00
|
|
|
QString scopedSymbolName(const CPlusPlus::Symbol *symbol) const;
|
2014-02-25 16:57:18 +01:00
|
|
|
QString scopeName(const QString &name, const CPlusPlus::Symbol *symbol) const;
|
2014-04-14 16:52:01 +02:00
|
|
|
IndexItem::Ptr addChildItem(const QString &symbolName, const QString &symbolType,
|
|
|
|
|
const QString &symbolScope, IndexItem::ItemType type,
|
|
|
|
|
CPlusPlus::Symbol *symbol);
|
2008-11-28 15:36:54 +01:00
|
|
|
|
2014-07-16 16:35:03 +02:00
|
|
|
private:
|
|
|
|
|
template<class T> void processClass(T *clazz);
|
|
|
|
|
template<class T> void processFunction(T *func);
|
|
|
|
|
|
2008-11-28 15:36:54 +01:00
|
|
|
private:
|
2014-04-14 16:52:01 +02:00
|
|
|
IndexItem::Ptr _parent;
|
2008-11-28 15:36:54 +01:00
|
|
|
QString _scope;
|
|
|
|
|
CPlusPlus::Overview overview;
|
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-11-28 15:36:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace CppTools
|
|
|
|
|
|
2011-11-25 12:05:58 +01:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(CppTools::SearchSymbols::SymbolTypes)
|