39
36
#include "indexedstring.h"
40
37
#include "duchainregister.h"
41
38
#include "persistentsymboltable.h"
42
#include "repositories/stringrepository.h"
43
39
#include "types/identifiedtype.h"
44
40
#include "types/structuretype.h"
45
41
#include "functiondefinition.h"
48
44
#include "types/typeutils.h"
49
45
#include "types/typealiastype.h"
50
46
#include "classdeclaration.h"
52
using namespace KTextEditor;
47
#include "repositories/stringrepository.h"
57
///@todo Use reference counting
58
static Repositories::StringRepository& commentRepository() {
59
static Repositories::StringRepository commentRepositoryObject("Comment Repository");
60
return commentRepositoryObject;
63
52
REGISTER_DUCHAIN_ITEM(Declaration);
65
54
DeclarationData::DeclarationData()
76
///@todo Use reference counting
77
static Repositories::StringRepository& commentRepository() {
78
static Repositories::StringRepository commentRepositoryObject("Comment Repository");
79
return commentRepositoryObject;
82
void initDeclarationRepositories() {
87
86
Declaration::Kind Declaration::kind() const {
88
87
DUCHAIN_D(Declaration);
105
104
return top && top->inDUChain();
108
Declaration::Declaration( const SimpleRange& range, DUContext* context )
107
Declaration::Declaration( const RangeInRevision& range, DUContext* context )
109
108
: DUChainBase(*new DeclarationData, range)
111
110
d_func_dynamic()->setClassId(this);
722
720
return m_context->equalScopeIdentifier(m_context);
725
QList<KTextEditor::SmartRange*> Declaration::smartUses() const
723
QMap<IndexedString, QList<RangeInRevision> > Declaration::uses() const
727
Q_ASSERT(topContext());
729
QSet<KTextEditor::SmartRange*> tempUses;
726
QMap<IndexedString, QMap<RangeInRevision, bool> > tempUses;
730
728
//First, search for uses within the own context
732
foreach(KTextEditor::SmartRange* range, allSmartUses(topContext(), const_cast<Declaration*>(this)))
733
tempUses.insert(range);
730
QMap<RangeInRevision, bool>& ranges(tempUses[topContext()->url()]);
731
foreach(const RangeInRevision& range, allUses(topContext(), const_cast<Declaration*>(this)))
732
ranges[range] = true;
736
735
KDevVarLengthArray<IndexedTopDUContext> useContexts = DUChain::uses()->uses(id());
738
737
FOREACH_ARRAY(const IndexedTopDUContext& indexedContext, useContexts) {
739
if(!indexedContext.isLoaded())
741
738
TopDUContext* context = indexedContext.data();
743
foreach(KTextEditor::SmartRange* range, allSmartUses(context, const_cast<Declaration*>(this)))
744
tempUses.insert(range);
748
return tempUses.toList();
740
QMap<RangeInRevision, bool>& ranges(tempUses[context->url()]);
741
foreach(const RangeInRevision& range, allUses(context, const_cast<Declaration*>(this)))
742
ranges[range] = true;
746
QMap<IndexedString, QList<RangeInRevision> > ret;
748
for(QMap<IndexedString, QMap<RangeInRevision, bool> >::const_iterator it = tempUses.constBegin(); it != tempUses.constEnd(); ++it) {
749
if(!(*it).isEmpty()) {
750
QList<RangeInRevision>& list(ret[it.key()]);
751
for(QMap<RangeInRevision, bool>::const_iterator it2 = (*it).constBegin(); it2 != (*it).constEnd(); ++it2)
751
QMap<IndexedString, QList<SimpleRange> > Declaration::uses() const
758
QMap<IndexedString, QList<SimpleRange> > Declaration::usesCurrentRevision() const
754
761
QMap<IndexedString, QMap<SimpleRange, bool> > tempUses;
756
763
//First, search for uses within the own context
758
765
QMap<SimpleRange, bool>& ranges(tempUses[topContext()->url()]);
759
foreach(const SimpleRange& range, allUses(topContext(), const_cast<Declaration*>(this)))
760
ranges[range] = true;
766
foreach(const RangeInRevision& range, allUses(topContext(), const_cast<Declaration*>(this)))
768
ranges[topContext()->transformFromLocalRevision(range)] = true;
763
772
KDevVarLengthArray<IndexedTopDUContext> useContexts = DUChain::uses()->uses(id());
766
775
TopDUContext* context = indexedContext.data();
768
777
QMap<SimpleRange, bool>& ranges(tempUses[context->url()]);
769
foreach(const SimpleRange& range, allUses(context, const_cast<Declaration*>(this)))
770
ranges[range] = true;
778
foreach(const RangeInRevision& range, allUses(context, const_cast<Declaration*>(this)))
779
ranges[context->transformFromLocalRevision(range)] = true;
774
QMap<IndexedString, QList<SimpleRange> > ret;
783
QMap<IndexedString, QList<SimpleRange> > ret;
776
785
for(QMap<IndexedString, QMap<SimpleRange, bool> >::const_iterator it = tempUses.constBegin(); it != tempUses.constEnd(); ++it) {
777
786
if(!(*it).isEmpty()) {