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>
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.
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.
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.
20
#include "expressionevaluationresult.h"
21
#include <language/duchain/identifier.h>
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>
31
using namespace KDevelop;
35
ExpressionEvaluationResult::~ExpressionEvaluationResult()
39
ExpressionEvaluationResult::ExpressionEvaluationResult()/* : isInstance(false)*/
43
void ExpressionEvaluationResult::setDeclaration(Declaration* declaration)
45
QList<Declaration*> decs;
49
setDeclarations(decs);
52
void ExpressionEvaluationResult::setDeclarations(QList<Declaration*> declarations)
54
ifDebug(kDebug() << "setting declarations" << declarations.size();)
56
m_allDeclarations = declarations;
57
if (!m_allDeclarations.isEmpty()) {
58
setType(m_allDeclarations.last()->abstractType());
60
setType(AbstractType::Ptr());
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();)
70
AbstractType::Ptr ExpressionEvaluationResult::type() const
75
QList<Declaration*> ExpressionEvaluationResult::allDeclarations() const
77
return m_allDeclarations;
80
QList<DeclarationId> ExpressionEvaluationResult::allDeclarationIds() const
82
return m_allDeclarationIds;
85
void ExpressionEvaluationResult::setType(AbstractType::Ptr type)
87
ifDebug(kDebug() << "setting type" << (type ? type->toString() : QString("no type"));)