~ubuntu-branches/ubuntu/karmic/kdevelop/karmic

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-06-28 20:48:13 UTC
  • mfrom: (1.1.12 upstream) (2.3.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20090628204813-m6qlb9e92ig9h04m
Tags: 4:3.9.94-1ubuntu1
* Merge from Debian experimental, remaining changes:
  - Conflict/replace -kde4 packages
  - Remove gdb from recommends, version >= 6.8.50 is not yet in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
using namespace KDevelop;
38
38
using namespace Cpp;
39
39
 
40
 
NameASTVisitor::NameASTVisitor(ParseSession* session, Cpp::ExpressionVisitor* visitor, const KDevelop::DUContext* context, const KDevelop::TopDUContext* source, const SimpleCursor& position, KDevelop::DUContext::SearchFlags localSearchFlags, bool debug )
41
 
: m_session(session), m_visitor(visitor), m_context(context), m_source(source), m_find(m_context, m_source, localSearchFlags, SimpleCursor(position) ), m_debug(debug), m_finalName(0)
 
40
NameASTVisitor::NameASTVisitor(ParseSession* session, Cpp::ExpressionVisitor* visitor, const KDevelop::DUContext* context, const KDevelop::TopDUContext* source, const KDevelop::DUContext* localVisibilityContext, const SimpleCursor& position, KDevelop::DUContext::SearchFlags localSearchFlags, bool debug )
 
41
: m_session(session), m_visitor(visitor), m_context(context), m_source(source), m_localContext(localVisibilityContext), m_find(m_context, m_source, localSearchFlags, SimpleCursor(position) ), m_debug(debug), m_finalName(0)
42
42
{
43
43
  m_flags = localSearchFlags;
44
44
  m_stopSearch = false;
128
128
  } else {
129
129
    if(node == m_finalName) {
130
130
      if(m_visitor) { //Create a zero use, which will be highlighted as an error
131
 
        m_visitor->newUse(node, node->id, node->id+1, DeclarationPointer());
132
 
        ///@todo Eventually report a problem, but then we don't need the zero use
 
131
        bool createUse = false;
 
132
        {
 
133
          LOCKDUCHAIN;
 
134
          createUse = !m_foundSomething || !Cpp::isTemplateDependent(m_foundSomething.data());
 
135
        }
 
136
        if(createUse)
 
137
          m_visitor->newUse(node, node->id, node->id+1, DeclarationPointer());
133
138
      }
134
139
      
135
140
      if( m_debug )
138
143
  }
139
144
 
140
145
  _M_name.push(m_currentIdentifier);
 
146
  
 
147
  if(!m_find.lastDeclarations().isEmpty()) {
 
148
    m_foundSomething = m_find.lastDeclarations().first();
 
149
  }
141
150
}
142
151
 
143
152
TypeSpecifierAST* NameASTVisitor::lastTypeSpecifier() const {
165
174
    if(!m_visitor) {
166
175
      m_visitor = new ExpressionVisitor(m_session, m_source);
167
176
      ownVisitor = true;
168
 
      node->expression->ducontext = const_cast<DUContext*>(m_context);
 
177
      node->expression->ducontext = const_cast<DUContext*>(m_localContext);
169
178
    }
170
179
    
171
180
    m_visitor->visit( node->expression );
196
205
    
197
206
  } else if( node->type_id )
198
207
  {
199
 
    TypeASTVisitor v( m_session, m_visitor, m_context, m_source, m_debug );
200
 
    v.setSearchFlags(m_flags);
 
208
    TypeASTVisitor v( m_session, m_visitor, m_localContext, m_source, m_localContext, m_debug );
201
209
    v.run( node->type_id );
202
210
 
203
211
    if(v.stoppedSearch()) {
296
304
  LOCKDUCHAIN;
297
305
  m_find.closeQualifiedIdentifier();
298
306
}
 
307
 
 
308
 
 
309
DeclarationPointer NameASTVisitor::foundSomething() const
 
310
{
 
311
  return m_foundSomething;
 
312
}