Changeset View
Changeset View
Standalone View
Standalone View
duchain/dumpchain.cpp
Show All 15 Lines | 1 | /* This file is part of KDevelop | |||
---|---|---|---|---|---|
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "dumpchain.h" | 20 | #include "dumpchain.h" | ||
21 | 21 | | |||
22 | #include <QtCore/QString> | 22 | #include <QtCore/QString> | ||
23 | #include <QTextStream> | 23 | #include <QTextStream> | ||
24 | #include <QDebug> | ||||
24 | 25 | | |||
25 | #include <kdebug.h> | | |||
26 | #include <ktexteditor/range.h> | 26 | #include <ktexteditor/range.h> | ||
27 | 27 | | |||
28 | #include <language/duchain/types/identifiedtype.h> | 28 | #include <language/duchain/types/identifiedtype.h> | ||
29 | #include "editorintegrator.h" | 29 | #include "editorintegrator.h" | ||
30 | #include <language/duchain/ducontext.h> | 30 | #include <language/duchain/ducontext.h> | ||
31 | #include <language/duchain/topducontext.h> | 31 | #include <language/duchain/topducontext.h> | ||
32 | #include <language/duchain/declaration.h> | 32 | #include <language/duchain/declaration.h> | ||
33 | #include <language/duchain/duchainpointer.h> | 33 | #include <language/duchain/duchainpointer.h> | ||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Line(s) | 198 | if (m_editor) { | |||
200 | for( qint64 a = node->startToken; a <= node->endToken; a++ ) { | 200 | for( qint64 a = node->startToken; a <= node->endToken; a++ ) { | ||
201 | if( !nodeText.isEmpty() ) | 201 | if( !nodeText.isEmpty() ) | ||
202 | nodeText += ' '; | 202 | nodeText += ' '; | ||
203 | nodeText += m_session->symbol(a); | 203 | nodeText += m_session->symbol(a); | ||
204 | } | 204 | } | ||
205 | if( !nodeText.isEmpty() ) nodeText = "\"" + nodeText + "\""; | 205 | if( !nodeText.isEmpty() ) nodeText = "\"" + nodeText + "\""; | ||
206 | 206 | | |||
207 | 207 | | |||
208 | kDebug() << indentation << "\\" << names[node->kind - 1000] | 208 | qDebug() << indentation << "\\" << names[node->kind - 1000] | ||
209 | << "[" << node->startToken << m_editor->findPosition(node->startToken, EditorIntegrator::FrontEdge) << ", " | 209 | << "[" << node->startToken << m_editor->findPosition(node->startToken, EditorIntegrator::FrontEdge) << ", " | ||
210 | << node->endToken << m_editor->findPosition(node->endToken, EditorIntegrator::BackEdge) << "]" << nodeText << endl; | 210 | << node->endToken << m_editor->findPosition(node->endToken, EditorIntegrator::BackEdge) << "]" << nodeText << endl; | ||
211 | } else { | 211 | } else { | ||
212 | kDebug() << indentation << "\\" << names[node->kind - 1000] | 212 | qDebug() << indentation << "\\" << names[node->kind - 1000] | ||
213 | << "[" << node->startToken << "," << node->endToken << "]" << endl; | 213 | << "[" << node->startToken << "," << node->endToken << "]" << endl; | ||
214 | } | 214 | } | ||
215 | } | 215 | } | ||
216 | 216 | | |||
217 | ++indent; | 217 | ++indent; | ||
218 | DefaultVisitor::visitNode(node); | 218 | DefaultVisitor::visitNode(node); | ||
219 | --indent; | 219 | --indent; | ||
220 | 220 | | |||
221 | if (node) { | 221 | if (node) { | ||
222 | if (m_editor) { | 222 | if (m_editor) { | ||
223 | kDebug() << indentation << "/" << names[node->kind - 1000] | 223 | qDebug() << indentation << "/" << names[node->kind - 1000] | ||
224 | << "[(" << node->endToken << ") "/*<< m_editor->findPosition(node->startToken, EditorIntegrator::FrontEdge) << ", "*/ | 224 | << "[(" << node->endToken << ") "/*<< m_editor->findPosition(node->startToken, EditorIntegrator::FrontEdge) << ", "*/ | ||
225 | << m_editor->findPosition(node->endToken, EditorIntegrator::FrontEdge) << "]" << endl; | 225 | << m_editor->findPosition(node->endToken, EditorIntegrator::FrontEdge) << "]" << endl; | ||
226 | } else { | 226 | } else { | ||
227 | kDebug() << indentation << "/" << names[node->kind - 1000] | 227 | qDebug() << indentation << "/" << names[node->kind - 1000] | ||
228 | << "[" << node->startToken << "," << node->endToken << ']' << endl; | 228 | << "[" << node->startToken << "," << node->endToken << ']' << endl; | ||
229 | } | 229 | } | ||
230 | } | 230 | } | ||
231 | } | 231 | } | ||
232 | 232 | | |||
233 | DumpChain::~ DumpChain( ) | 233 | DumpChain::~ DumpChain( ) | ||
234 | { | 234 | { | ||
235 | delete m_editor; | 235 | delete m_editor; | ||
236 | } | 236 | } | ||
237 | 237 | | |||
238 | void DumpChain::dump( DUContext * context, bool imported ) | 238 | void DumpChain::dump( DUContext * context, bool imported ) | ||
239 | { | 239 | { | ||
240 | kDebug() << QString(indent * 2, ' ') << (imported ? "==import==> Context " : "New Context ") << context << "\"" << context->localScopeIdentifier() << "\" [" << context->scopeIdentifier() << "]" << context->range() << " " << (dynamic_cast<TopDUContext*>(context) ? "top-context" : ""); | 240 | qDebug() << QString(indent * 2, ' ') << (imported ? "==import==> Context " : "New Context ") << context << "\"" << context->localScopeIdentifier() << "\" [" << context->scopeIdentifier() << "]" << context->range() << " " << (dynamic_cast<TopDUContext*>(context) ? "top-context" : ""); | ||
241 | if( !context ) | 241 | if( !context ) | ||
242 | return; | 242 | return; | ||
243 | if (!imported) { | 243 | if (!imported) { | ||
244 | foreach (Declaration* dec, context->localDeclarations()) { | 244 | foreach (Declaration* dec, context->localDeclarations()) { | ||
245 | 245 | | |||
246 | kDebug() << QString((indent+1) * 2, ' ') << "Declaration: " << dec->toString() << /*(idType ? (" (type-identity: " + idType->identifier().toString() + ")") : QString()) <<*/ " [" << dec->qualifiedIdentifier() << "]" << dec << "(internal ctx" << dec->internalContext() << ")" << dec->range() << "," << (dec->isDefinition() ? "definition, " : "declaration, ") << dec->uses().count() << "use(s)," << (dec->inSymbolTable() ? " in symbol table" : " not in symbol table"); | 246 | qDebug() << QString((indent+1) * 2, ' ') << "Declaration: " << dec->toString() << /*(idType ? (" (type-identity: " + idType->identifier().toString() + ")") : QString()) <<*/ " [" << dec->qualifiedIdentifier() << "]" << dec << "(internal ctx" << dec->internalContext() << ")" << dec->range() << "," << (dec->isDefinition() ? "definition, " : "declaration, ") << dec->uses().count() << "use(s)," << (dec->inSymbolTable() ? " in symbol table" : " not in symbol table"); | ||
247 | QMap<IndexedString, QList<RangeInRevision> > uses = dec->uses(); | 247 | QMap<IndexedString, QVector<RangeInRevision> > uses = dec->uses(); | ||
248 | for(QMap<IndexedString, QList<RangeInRevision> >::const_iterator it = uses.begin(); it != uses.end(); ++it) { | 248 | for(QMap<IndexedString, QVector<RangeInRevision> >::const_iterator it = uses.begin(); it != uses.end(); ++it) { | ||
249 | kDebug() << QString((indent+2) * 2, ' ') << "File:" << it.key().str(); | 249 | qDebug() << QString((indent+2) * 2, ' ') << "File:" << it.key().str(); | ||
250 | foreach (const RangeInRevision& range, *it) | 250 | foreach (const RangeInRevision& range, *it) | ||
251 | kDebug() << QString((indent+2) * 2+1, ' ') << "Use:" << range; | 251 | qDebug() << QString((indent+2) * 2+1, ' ') << "Use:" << range; | ||
252 | } | 252 | } | ||
253 | } | 253 | } | ||
254 | } | 254 | } | ||
255 | 255 | | |||
256 | ++indent; | 256 | ++indent; | ||
257 | if (!imported) { | 257 | if (!imported) { | ||
258 | ///@todo Think whether this is used for top-contexts, and if it is, prevent endless recursion due to loops | 258 | ///@todo Think whether this is used for top-contexts, and if it is, prevent endless recursion due to loops | ||
259 | foreach (const DUContext::Import& parent, context->importedParentContexts()) { | 259 | foreach (const DUContext::Import& parent, context->importedParentContexts()) { | ||
Show All 10 Lines |