Differential D8512 Diff 21414 kdevplatform/language/duchain/navigation/abstractincludenavigationcontext.cpp
Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/language/duchain/navigation/abstractincludenavigationcontext.cpp
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 69 | if(!duchain && !duchains.isEmpty() && forcePick) | |||
---|---|---|---|---|---|
70 | duchain = duchains.first(); | 70 | duchain = duchains.first(); | ||
71 | 71 | | |||
72 | return duchain; | 72 | return duchain; | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | QString AbstractIncludeNavigationContext::html(bool shorten) | 75 | QString AbstractIncludeNavigationContext::html(bool shorten) | ||
76 | { | 76 | { | ||
77 | clear(); | 77 | clear(); | ||
78 | modifyHtml() += "<html><body><p>" + fontSizePrefix(shorten); | 78 | modifyHtml() += QLatin1String("<html><body><p>") + fontSizePrefix(shorten); | ||
79 | addExternalHtml(prefix()); | 79 | addExternalHtml(prefix()); | ||
80 | 80 | | |||
81 | QUrl u = m_item.url(); | 81 | QUrl u = m_item.url(); | ||
82 | NavigationAction action(u, KTextEditor::Cursor(0,0)); | 82 | NavigationAction action(u, KTextEditor::Cursor(0,0)); | ||
83 | makeLink(u.toDisplayString(QUrl::PreferLocalFile), u.toString(), action); | 83 | makeLink(u.toDisplayString(QUrl::PreferLocalFile), u.toString(), action); | ||
84 | modifyHtml() += QStringLiteral("<br />"); | 84 | modifyHtml() += QStringLiteral("<br />"); | ||
85 | 85 | | |||
86 | QList<TopDUContext*> duchains = DUChain::self()->chainsForDocument(u); | 86 | QList<TopDUContext*> duchains = DUChain::self()->chainsForDocument(u); | ||
87 | //Pick the one duchain for this document that has the most child-contexts/declarations. | 87 | //Pick the one duchain for this document that has the most child-contexts/declarations. | ||
88 | //This prevents picking a context that is empty due to header-guards. | 88 | //This prevents picking a context that is empty due to header-guards. | ||
89 | TopDUContext* duchain = pickContextWithData(duchains, 2, m_type); | 89 | TopDUContext* duchain = pickContextWithData(duchains, 2, m_type); | ||
90 | 90 | | |||
91 | if(duchain) { | 91 | if(duchain) { | ||
92 | getFileInfo(duchain); | 92 | getFileInfo(duchain); | ||
93 | if(!shorten) { | 93 | if(!shorten) { | ||
94 | modifyHtml() += labelHighlight(i18n("Declarations:")) + "<br />"; | 94 | modifyHtml() += labelHighlight(i18n("Declarations:")) + QLatin1String("<br />"); | ||
95 | bool first = true; | 95 | bool first = true; | ||
96 | QList<IdentifierPair> decs; | 96 | QList<IdentifierPair> decs; | ||
97 | addDeclarationsFromContext(duchain, first, decs); | 97 | addDeclarationsFromContext(duchain, first, decs); | ||
98 | } | 98 | } | ||
99 | }else if(duchains.isEmpty()) { | 99 | }else if(duchains.isEmpty()) { | ||
100 | modifyHtml() += i18n("not parsed yet"); | 100 | modifyHtml() += i18n("not parsed yet"); | ||
101 | } | 101 | } | ||
102 | 102 | | |||
103 | addExternalHtml(suffix()); | 103 | addExternalHtml(suffix()); | ||
104 | 104 | | |||
105 | modifyHtml() += fontSizeSuffix(shorten) + "</p></body></html>"; | 105 | modifyHtml() += fontSizeSuffix(shorten) + QLatin1String("</p></body></html>"); | ||
106 | return currentHtml(); | 106 | return currentHtml(); | ||
107 | } | 107 | } | ||
108 | 108 | | |||
109 | void AbstractIncludeNavigationContext::getFileInfo(TopDUContext* duchain) | 109 | void AbstractIncludeNavigationContext::getFileInfo(TopDUContext* duchain) | ||
110 | { | 110 | { | ||
111 | modifyHtml() += QStringLiteral("%1: %2 %3: %4").arg(labelHighlight(i18nc("Files included into this file", "Includes"))).arg(duchain->importedParentContexts().count()).arg(labelHighlight(i18nc("Count of files this file was included into", "Included by"))).arg(duchain->importers().count()); | 111 | modifyHtml() += QStringLiteral("%1: %2 %3: %4").arg(labelHighlight(i18nc("Files included into this file", "Includes"))).arg(duchain->importedParentContexts().count()).arg(labelHighlight(i18nc("Count of files this file was included into", "Included by"))).arg(duchain->importers().count()); | ||
112 | modifyHtml() += QStringLiteral("<br />"); | 112 | modifyHtml() += QStringLiteral("<br />"); | ||
113 | } | 113 | } | ||
Show All 36 Lines | 149 | IdentifierPair id = qMakePair(static_cast<int>((*declarationIterator)->kind()), | |||
150 | (*declarationIterator)->qualifiedIdentifier().index()); | 150 | (*declarationIterator)->qualifiedIdentifier().index()); | ||
151 | if(!addedDeclarations.contains(id) && filterDeclaration(*declarationIterator) ) { | 151 | if(!addedDeclarations.contains(id) && filterDeclaration(*declarationIterator) ) { | ||
152 | //Show the declaration | 152 | //Show the declaration | ||
153 | if(!first) | 153 | if(!first) | ||
154 | modifyHtml() += QStringLiteral(", "); | 154 | modifyHtml() += QStringLiteral(", "); | ||
155 | else | 155 | else | ||
156 | first = false; | 156 | first = false; | ||
157 | 157 | | |||
158 | modifyHtml() += QString(indent + declarationKind(DeclarationPointer(*declarationIterator)) + " ").toHtmlEscaped(); | 158 | modifyHtml() += QString(indent + declarationKind(DeclarationPointer(*declarationIterator)) + QLatin1Char(' ')).toHtmlEscaped(); | ||
159 | makeLink((*declarationIterator)->qualifiedIdentifier().toString(), DeclarationPointer(*declarationIterator), NavigationAction::NavigateDeclaration); | 159 | makeLink((*declarationIterator)->qualifiedIdentifier().toString(), DeclarationPointer(*declarationIterator), NavigationAction::NavigateDeclaration); | ||
160 | 160 | | |||
161 | addedDeclarations << id; | 161 | addedDeclarations << id; | ||
162 | } | 162 | } | ||
163 | ++declarationIterator; | 163 | ++declarationIterator; | ||
164 | } else { | 164 | } else { | ||
165 | //Eventually Recurse into the context | 165 | //Eventually Recurse into the context | ||
166 | if((*childIterator)->type() == DUContext::Global || (*childIterator)->type() == DUContext::Namespace /*|| (*childIterator)->type() == DUContext::Class*/) | 166 | if((*childIterator)->type() == DUContext::Global || (*childIterator)->type() == DUContext::Namespace /*|| (*childIterator)->type() == DUContext::Class*/) | ||
167 | addDeclarationsFromContext(*childIterator, first, addedDeclarations, indent + ' '); | 167 | addDeclarationsFromContext(*childIterator, first, addedDeclarations, indent + QLatin1Char(' ')); | ||
168 | ++childIterator; | 168 | ++childIterator; | ||
169 | } | 169 | } | ||
170 | } | 170 | } | ||
171 | //modifyHtml() += "}<br />"; | 171 | //modifyHtml() += "}<br />"; | ||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | } | 174 | } |