~ubuntu-branches/ubuntu/utopic/kdevelop-php/utopic

« back to all changes in this revision

Viewing changes to duchain/expressionevaluationresult.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2010-01-17 17:10:22 UTC
  • Revision ID: james.westby@ubuntu.com-20100117171022-q2xlgd9ekewo2ijx
Tags: upstream-1.0.0~beta2
ImportĀ upstreamĀ versionĀ 1.0.0~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of KDevelop
 
2
    Copyright 2008 David Nolden <david.nolden.kdevelop@art-master.de>
 
3
    Copyright 2008 Niko Sams <niko.sams@gmail.com>
 
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
#include "expressionevaluationresult.h"
 
21
#include <language/duchain/identifier.h>
 
22
#include <QString>
 
23
#include <language/duchain/duchainlock.h>
 
24
#include <language/duchain/repositories/itemrepository.h>
 
25
#include <language/duchain/duchain.h>
 
26
#include <language/duchain/types/identifiedtype.h>
 
27
#include <language/duchain/declaration.h>
 
28
 
 
29
#define ifDebug(x)
 
30
 
 
31
using namespace KDevelop;
 
32
namespace Php
 
33
{
 
34
 
 
35
ExpressionEvaluationResult::~ExpressionEvaluationResult()
 
36
{
 
37
}
 
38
 
 
39
ExpressionEvaluationResult::ExpressionEvaluationResult()/* : isInstance(false)*/
 
40
{
 
41
}
 
42
 
 
43
void ExpressionEvaluationResult::setDeclaration(Declaration* declaration)
 
44
{
 
45
    QList<Declaration*> decs;
 
46
    if (declaration) {
 
47
        decs << declaration;
 
48
    }
 
49
    setDeclarations(decs);
 
50
}
 
51
 
 
52
void ExpressionEvaluationResult::setDeclarations(QList<Declaration*> declarations)
 
53
{
 
54
    ifDebug(kDebug() << "setting declarations" << declarations.size();)
 
55
 
 
56
    m_allDeclarations = declarations;
 
57
    if (!m_allDeclarations.isEmpty()) {
 
58
        setType(m_allDeclarations.last()->abstractType());
 
59
    } else {
 
60
        setType(AbstractType::Ptr());
 
61
    }
 
62
    m_allDeclarationIds.clear();
 
63
    DUChainReadLocker lock(DUChain::lock());
 
64
    foreach(Declaration* dec, m_allDeclarations) {
 
65
        m_allDeclarationIds << dec->id();
 
66
        ifDebug(kDebug() << dec->toString();)
 
67
    }
 
68
}
 
69
 
 
70
AbstractType::Ptr ExpressionEvaluationResult::type() const
 
71
{
 
72
    return m_type;
 
73
}
 
74
 
 
75
QList<Declaration*> ExpressionEvaluationResult::allDeclarations() const
 
76
{
 
77
    return m_allDeclarations;
 
78
}
 
79
 
 
80
QList<DeclarationId> ExpressionEvaluationResult::allDeclarationIds() const
 
81
{
 
82
    return m_allDeclarationIds;
 
83
}
 
84
 
 
85
void ExpressionEvaluationResult::setType(AbstractType::Ptr type)
 
86
{
 
87
    ifDebug(kDebug() << "setting type" << (type ? type->toString() : QString("no type"));)
 
88
 
 
89
    m_type = type;
 
90
}
 
91
 
 
92
}