~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/cpp/cppduchain/name_visitor.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of KDevelop
 
2
    Copyright 2002-2005 Roberto Raggi <roberto@kdevelop.org>
 
3
    Copyright 2007 David Nolden <david.nolden.kdevelop@art-master.de>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Library General Public
 
7
   License version 2 as published by the Free Software Foundation.
 
8
 
 
9
   This library is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this library; see the file COPYING.LIB.  If not, write to
 
16
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
   Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#ifndef NAME_VISITOR_H
 
21
#define NAME_VISITOR_H
 
22
 
 
23
#include "default_visitor.h"
 
24
#include <language/duchain/identifier.h>
 
25
#include <cppduchainexport.h>
 
26
#include "cppducontext.h"
 
27
#include <language/duchain/ducontext.h>
 
28
 
 
29
class ParseSession;
 
30
class OperatorAST;
 
31
 
 
32
namespace KDevelop {
 
33
  class SimpleCursor;
 
34
}
 
35
 
 
36
namespace Cpp {
 
37
  class ExpressionVisitor;
 
38
}
 
39
 
 
40
///This searches for the name while walking its AST.
 
41
class KDEVCPPDUCHAIN_EXPORT NameASTVisitor: protected DefaultVisitor
 
42
{
 
43
public:
 
44
  ///@param context Context in which to look up the name
 
45
  ///@param source The source top-context from where the parsing was triggerd
 
46
  ///@param localVisibilityContext Local context from where to look up template parameters
 
47
  NameASTVisitor(ParseSession* session, Cpp::ExpressionVisitor* visitor, const KDevelop::DUContext* context, const KDevelop::TopDUContext* source, const KDevelop::DUContext* localVisibilityContext, const KDevelop::SimpleCursor& position, KDevelop::DUContext::SearchFlags localSearchFlags = KDevelop::DUContext::NoSearchFlags, bool debug = false);
 
48
 
 
49
  void run(NameAST *node, bool skipLastNamePart = false);
 
50
  ///@param skipThisName if this is true, only the template-parameters of the given node are processed
 
51
  void run(UnqualifiedNameAST *node, bool skipThisName = false);
 
52
 
 
53
  QString name() const { if(m_stopSearch) return QString(); return _M_name.toString(); }
 
54
  QStringList qualifiedName() const { if(m_stopSearch) return QStringList(); return _M_name.toStringList(); }
 
55
 
 
56
  const KDevelop::QualifiedIdentifier& identifier() const;
 
57
 
 
58
  /**
 
59
   * When the name contains one type-specifier, this should contain that specifier after the run.
 
60
   * Especially this is the type-specifier of a conversion-operator like "operator int()"
 
61
   * */
 
62
  TypeSpecifierAST* lastTypeSpecifier() const;
 
63
 
 
64
  ///Retrieve the declarations found for the name
 
65
  QList<KDevelop::DeclarationPointer> declarations() const;
 
66
 
 
67
  bool stoppedSearch() const {
 
68
    return m_stopSearch;
 
69
  }
 
70
  
 
71
  ///Whether at least one part of the scope could be resolved
 
72
  DeclarationPointer foundSomething() const;
 
73
  
 
74
  ///This can be used from outside to only process the type of a template-argument.
 
75
  ///This NameASTVisitor will be in an invalid state after this is called, so don't continue using it!
 
76
  Cpp::ExpressionEvaluationResult processTemplateArgument(TemplateArgumentAST *node);
 
77
protected:
 
78
  virtual void visitUnqualifiedName(UnqualifiedNameAST *node);
 
79
  void visitTemplateArgument(TemplateArgumentAST *node);
 
80
  
 
81
private:
 
82
  ParseSession* m_session;
 
83
  Cpp::ExpressionVisitor* m_visitor;
 
84
  const KDevelop::DUContext* m_context;
 
85
  const KDevelop::TopDUContext* m_source;
 
86
  const KDevelop::DUContext* m_localContext;
 
87
  TypeSpecifierAST* m_typeSpecifier;
 
88
  KDevelop::Identifier m_currentIdentifier;
 
89
  KDevelop::QualifiedIdentifier _M_name;
 
90
  Cpp::FindDeclaration m_find;
 
91
  bool m_debug;
 
92
  UnqualifiedNameAST* m_finalName;
 
93
  KDevelop::DUContext::SearchFlags m_flags;
 
94
  bool m_stopSearch;
 
95
  DeclarationPointer m_foundSomething;
 
96
};
 
97
 
 
98
QString decode(ParseSession* session, AST* ast, bool without_spaces = false);
 
99
 
 
100
#endif // NAME_VISITOR_H
 
101