2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-08-13 16:38:45 +02:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-08-13 16:38:45 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-08-13 16:38:45 +02: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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2010-08-13 16:38:45 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, 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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-08-13 16:38:45 +02:00
|
|
|
|
2013-03-12 12:06:41 +01:00
|
|
|
#ifndef CPPELEMENTEVALUATOR_H
|
|
|
|
|
#define CPPELEMENTEVALUATOR_H
|
2010-08-13 16:38:45 +02:00
|
|
|
|
|
|
|
|
#include "cppeditor.h"
|
2010-08-27 12:11:55 +02:00
|
|
|
|
|
|
|
|
#include <texteditor/helpitem.h>
|
2012-01-24 11:07:26 +01:00
|
|
|
#include <cpptools/symbolfinder.h>
|
2010-08-13 16:38:45 +02:00
|
|
|
#include <cplusplus/CppDocument.h>
|
|
|
|
|
#include <cplusplus/Overview.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
#include <QSharedPointer>
|
|
|
|
|
#include <QTextCursor>
|
|
|
|
|
#include <QIcon>
|
2010-08-13 16:38:45 +02:00
|
|
|
|
|
|
|
|
namespace CPlusPlus {
|
|
|
|
|
class LookupItem;
|
|
|
|
|
class LookupContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace CppTools {
|
|
|
|
|
class CppModelManagerInterface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace CppEditor {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2011-02-21 16:02:26 +01:00
|
|
|
class CPPEditorWidget;
|
2010-08-13 16:38:45 +02:00
|
|
|
class CppElement;
|
|
|
|
|
|
|
|
|
|
class CppElementEvaluator
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit CppElementEvaluator(CPPEditorWidget *editor);
|
2010-08-13 16:38:45 +02:00
|
|
|
|
|
|
|
|
void setTextCursor(const QTextCursor &tc);
|
|
|
|
|
void setLookupBaseClasses(const bool lookup);
|
2011-07-08 09:56:02 +02:00
|
|
|
void setLookupDerivedClasses(const bool lookup);
|
2010-08-13 16:38:45 +02:00
|
|
|
|
2011-01-17 16:29:57 +01:00
|
|
|
void execute();
|
|
|
|
|
bool identifiedCppElement() const;
|
|
|
|
|
const QSharedPointer<CppElement> &cppElement() const;
|
|
|
|
|
bool hasDiagnosis() const;
|
|
|
|
|
const QString &diagnosis() const;
|
2010-08-13 16:38:45 +02:00
|
|
|
|
|
|
|
|
private:
|
2011-01-17 16:29:57 +01:00
|
|
|
void clear();
|
2011-08-24 12:01:50 +02:00
|
|
|
void checkDiagnosticMessage(int pos);
|
2010-08-13 16:38:45 +02:00
|
|
|
bool matchIncludeFile(const CPlusPlus::Document::Ptr &document, unsigned line);
|
|
|
|
|
bool matchMacroInUse(const CPlusPlus::Document::Ptr &document, unsigned pos);
|
|
|
|
|
void handleLookupItemMatch(const CPlusPlus::Snapshot &snapshot,
|
|
|
|
|
const CPlusPlus::LookupItem &lookupItem,
|
|
|
|
|
const CPlusPlus::LookupContext &lookupContext);
|
|
|
|
|
|
2011-02-21 16:02:26 +01:00
|
|
|
CPPEditorWidget *m_editor;
|
2010-12-03 13:49:35 +01:00
|
|
|
CPlusPlus::CppModelManagerInterface *m_modelManager;
|
2010-08-13 16:38:45 +02:00
|
|
|
QTextCursor m_tc;
|
|
|
|
|
bool m_lookupBaseClasses;
|
2011-07-08 09:56:02 +02:00
|
|
|
bool m_lookupDerivedClasses;
|
2010-08-13 16:38:45 +02:00
|
|
|
QSharedPointer<CppElement> m_element;
|
2011-01-17 16:29:57 +01:00
|
|
|
QString m_diagnosis;
|
2012-01-24 11:07:26 +01:00
|
|
|
CppTools::SymbolFinder m_symbolFinder;
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppElement
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
CppElement();
|
|
|
|
|
|
2012-10-10 22:32:31 +02:00
|
|
|
public:
|
|
|
|
|
virtual ~CppElement();
|
2010-08-13 16:38:45 +02:00
|
|
|
|
2012-10-10 22:32:31 +02:00
|
|
|
TextEditor::HelpItem::Category helpCategory;
|
|
|
|
|
QStringList helpIdCandidates;
|
|
|
|
|
QString helpMark;
|
|
|
|
|
CPPEditorWidget::Link link;
|
|
|
|
|
QString tooltip;
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Unknown : public CppElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit Unknown(const QString &type);
|
2010-08-13 16:38:45 +02:00
|
|
|
|
2012-10-10 22:32:31 +02:00
|
|
|
public:
|
|
|
|
|
QString type;
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppInclude : public CppElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit CppInclude(const CPlusPlus::Document::Include &includeFile);
|
2010-08-13 16:38:45 +02:00
|
|
|
|
2012-10-10 22:32:31 +02:00
|
|
|
public:
|
|
|
|
|
QString path;
|
|
|
|
|
QString fileName;
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppMacro : public CppElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit CppMacro(const CPlusPlus::Macro ¯o);
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppDeclarableElement : public CppElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit CppDeclarableElement(CPlusPlus::Symbol *declaration);
|
2010-08-13 16:38:45 +02:00
|
|
|
|
2012-10-10 22:32:31 +02:00
|
|
|
public:
|
|
|
|
|
QString name;
|
|
|
|
|
QString qualifiedName;
|
|
|
|
|
QString type;
|
|
|
|
|
QIcon icon;
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppNamespace : public CppDeclarableElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit CppNamespace(CPlusPlus::Symbol *declaration);
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppClass : public CppDeclarableElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-07-08 09:56:02 +02:00
|
|
|
CppClass();
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit CppClass(CPlusPlus::Symbol *declaration);
|
2010-08-13 16:38:45 +02:00
|
|
|
|
|
|
|
|
void lookupBases(CPlusPlus::Symbol *declaration, const CPlusPlus::LookupContext &context);
|
2011-07-08 09:56:02 +02:00
|
|
|
void lookupDerived(CPlusPlus::Symbol *declaration, const CPlusPlus::Snapshot &snapshot);
|
2010-08-13 16:38:45 +02:00
|
|
|
|
2012-10-10 22:32:31 +02:00
|
|
|
public:
|
|
|
|
|
QList<CppClass> bases;
|
|
|
|
|
QList<CppClass> derived;
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppFunction : public CppDeclarableElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit CppFunction(CPlusPlus::Symbol *declaration);
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppEnum : public CppDeclarableElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit CppEnum(CPlusPlus::Enum *declaration);
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppTypedef : public CppDeclarableElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 09:30:32 +02:00
|
|
|
explicit CppTypedef(CPlusPlus::Symbol *declaration);
|
2010-08-13 16:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppVariable : public CppDeclarableElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CppVariable(CPlusPlus::Symbol *declaration,
|
|
|
|
|
const CPlusPlus::LookupContext &context,
|
|
|
|
|
CPlusPlus::Scope *scope);
|
|
|
|
|
};
|
|
|
|
|
|
2011-06-09 09:30:32 +02:00
|
|
|
class CppEnumerator : public CppDeclarableElement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit CppEnumerator(CPlusPlus::EnumeratorDeclaration *declaration);
|
|
|
|
|
};
|
|
|
|
|
|
2010-08-13 16:38:45 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CppEditor
|
|
|
|
|
|
2013-03-12 12:06:41 +01:00
|
|
|
#endif // CPPELEMENTEVALUATOR_H
|