File indexing completed on 2024-05-12 04:37:47
0001 /* 0002 SPDX-FileCopyrightText: 2008 Ramón Zarazúa <killerfox512+kde@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #include "duchainchangeset.h" 0008 #include <debug.h> 0009 #include <serialization/indexedstring.h> 0010 0011 namespace KDevelop { 0012 //DUChainRef::DUChainRef(DUChainChangeSet* set, DUChainBase* object, bool newObject) : 0013 // m_changeSet(set), m_object(object), m_objectRef(0), m_newObject(newObject) 0014 //{ 0015 //} 0016 0017 DUChainChangeSet::DUChainChangeSet(const ReferencedTopDUContext& topContext) : 0018 m_topContext(topContext) 0019 { 0020 } 0021 0022 DUChainChangeSet::~DUChainChangeSet() 0023 { 0024 qDeleteAll(m_objectRefs); 0025 } 0026 0027 DUChainChangeSet& DUChainChangeSet::operator<<(DUChainChangeSet& rhs) 0028 { 0029 //Avoid merging into self 0030 if (this == &rhs) 0031 return *this; 0032 0033 Q_ASSERT(m_topContext == rhs.m_topContext); 0034 qCDebug(LANGUAGE) << "Merging ChangeSets for context:" << m_topContext.data()->url().str(); 0035 0036 m_objectRefs << rhs.m_objectRefs; 0037 rhs.m_objectRefs.clear(); 0038 0039 #ifndef NDEBUG 0040 //check for possible duplicates 0041 std::sort(m_objectRefs.begin(), m_objectRefs.end()); 0042 0043 for (QList<DUChainRef*>::iterator i = m_objectRefs.begin(); i < m_objectRefs.end() - 1; ++i) 0044 Q_ASSERT(*i != *(i + 1)); 0045 0046 #endif 0047 return *this; 0048 } 0049 0050 QList<DUChainRef*> DUChainChangeSet::objectRefs() const 0051 { 0052 return m_objectRefs; 0053 } 0054 0055 const ReferencedTopDUContext& DUChainChangeSet::topDuContext() const 0056 { 0057 return m_topContext; 0058 } 0059 }