File indexing completed on 2024-05-05 16:42:27
0001 /* 0002 SPDX-FileCopyrightText: 2007 Piyush verma <piyush.verma@gmail.com> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #include "dumpchain.h" 0008 #include "pythoneditorintegrator.h" 0009 0010 #include <language/duchain/types/identifiedtype.h> 0011 #include <language/duchain/ducontext.h> 0012 #include <language/duchain/topducontext.h> 0013 #include <language/duchain/declaration.h> 0014 #include <language/duchain/duchainpointer.h> 0015 #include <language/duchain/use.h> 0016 0017 #include <QDebug> 0018 #include "duchaindebug.h" 0019 0020 using namespace KDevelop; 0021 0022 namespace Python { 0023 0024 0025 DumpChain::DumpChain() 0026 : indent(0) 0027 { 0028 } 0029 0030 void DumpChain::dump( DUContext * context, bool imported ) 0031 { 0032 if( !context ) 0033 return; 0034 qCDebug(KDEV_PYTHON_DUCHAIN) << QString( indent*2, ' ' ) << (imported ? "==import==> Context " : "New Context ") << context->scopeIdentifier(true) << context->transformFromLocalRevision(context->range()) << " " << context << " " << (dynamic_cast<TopDUContext*>(context) ? "top-context" : ""); 0035 if (!imported) 0036 { 0037 foreach (Declaration* dec, context->localDeclarations()) 0038 { 0039 const auto uses = dec->uses(); 0040 qCDebug(KDEV_PYTHON_DUCHAIN) << QString( (indent+1)*2, ' ' ) << "Declaration: " << dec->toString() << " [" << dec->qualifiedIdentifier() << "] "<< dec << "(internal ctx" << dec->internalContext() << ")" << context->transformFromLocalRevision(dec->range()) << ", "<< ( dec->isDefinition() ? "definition, " : "declaration, " ) << uses.count() << "use(s)"; 0041 for (auto it = uses.constBegin(); it != uses.constEnd(); ++it) 0042 { 0043 qCDebug(KDEV_PYTHON_DUCHAIN) << QString((indent+1)*2, ' ') << "File:" << it.key().str(); 0044 foreach(const RangeInRevision& r, it.value()) 0045 { 0046 qCDebug(KDEV_PYTHON_DUCHAIN) << QString((indent+2)*2, ' ') << "Use:" << context->transformFromLocalRevision(r); 0047 } 0048 } 0049 } 0050 } 0051 ++indent; 0052 if (!imported) 0053 { 0054 foreach (const DUContext::Import& parent, context->importedParentContexts()) 0055 { 0056 dump(parent.context(dynamic_cast<TopDUContext*>(context)), true); 0057 } 0058 foreach (DUContext* child, context->childContexts()) 0059 { 0060 dump(child); 0061 } 0062 } 0063 --indent; 0064 } 0065 0066 DumpChain::~ DumpChain( ) 0067 { 0068 } 0069 0070 }