| 202 | |
| 203 | |
| 204 | KDevelop::QuickOpenDataPointer ProjectItemDataProvider::data(uint pos) const |
| 205 | { |
| 206 | //Check whether this position falls into an appended item-list, else apply the offset |
| 207 | uint filteredItemOffset = 0; |
| 208 | for (AddedItems::const_iterator it = m_addedItems.constBegin(); it != m_addedItems.constEnd(); ++it) { |
| 209 | int offsetInAppended = pos - (it.key() + 1); |
| 210 | if (offsetInAppended >= 0 && offsetInAppended < it.value().count()) { |
| 211 | return it.value()[offsetInAppended]; |
| 212 | } |
| 213 | if (it.key() >= pos) { |
| 214 | break; |
| 215 | } |
| 216 | filteredItemOffset += it.value().count(); |
| 217 | } |
| 218 | |
| 219 | const uint a = pos - filteredItemOffset; |
| 220 | if (a > ( uint )m_filteredItems.size()) { |
| 221 | return KDevelop::QuickOpenDataPointer(); |
| 222 | } |
| 223 | |
| 224 | const auto& filteredItem = m_filteredItems[a]; |
| 225 | |
| 226 | QList<KDevelop::QuickOpenDataPointer> ret; |
| 227 | KDevelop::DUChainReadLocker lock(DUChain::lock()); |
| 228 | TopDUContext* ctx = DUChainUtils::standardContextForUrl(filteredItem.m_file.toUrl()); |
| 229 | if (ctx) { |
| 230 | QList<Declaration*> decls = ctx->findDeclarations(filteredItem.m_id, CursorInRevision::invalid(), AbstractType::Ptr(), nullptr, DUContext::DirectQualifiedLookup); |
| 231 | |
| 232 | //Filter out forward-declarations or duplicate imported declarations |
| 233 | const auto unfilteredDecls = decls; |
| 234 | for (Declaration* decl : unfilteredDecls) { |
| 235 | bool filter = false; |
| 236 | if (decls.size() > 1 && decl->isForwardDeclaration()) { |
| 237 | filter = true; |
| 238 | } else if (decl->url() != filteredItem.m_file && m_files.contains(decl->url())) { |
| 239 | filter = true; |
| 240 | } |
| 241 | if (filter) { |
| 242 | decls.removeOne(decl); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | ret.reserve(ret.size() + decls.size()); |
| 247 | for (Declaration* decl : std::as_const(decls)) { |
| 248 | DUChainItem item; |
| 249 | item.m_item = decl; |
| 250 | item.m_text = decl->qualifiedIdentifier().toString(); |
| 251 | item.m_projectPath = findProjectForForPath(filteredItem.m_file); |
| 252 | ret << QuickOpenDataPointer(new DUChainItemData(item)); |
| 253 | } |
| 254 | |
| 255 | if (decls.isEmpty()) { |
| 256 | DUChainItem item; |
| 257 | item.m_text = filteredItem.m_id.toString(); |
| 258 | item.m_projectPath = findProjectForForPath(filteredItem.m_file); |
| 259 | ret << QuickOpenDataPointer(new DUChainItemData(item)); |
| 260 | } |
| 261 | } else { |
nothing calls this directly
no test coverage detected