The first definition that belongs to a context that surrounds the current cursor
| 177 | |
| 178 | ///The first definition that belongs to a context that surrounds the current cursor |
| 179 | Declaration* cursorContextDeclaration() |
| 180 | { |
| 181 | KTextEditor::View* view = ICore::self()->documentController()->activeTextDocumentView(); |
| 182 | if (!view) { |
| 183 | return nullptr; |
| 184 | } |
| 185 | |
| 186 | KDevelop::DUChainReadLocker lock(DUChain::lock()); |
| 187 | |
| 188 | TopDUContext* ctx = DUChainUtils::standardContextForUrl(view->document()->url()); |
| 189 | if (!ctx) { |
| 190 | return nullptr; |
| 191 | } |
| 192 | |
| 193 | KTextEditor::Cursor cursor(view->cursorPosition()); |
| 194 | |
| 195 | DUContext* subCtx = ctx->findContext(ctx->transformToLocalRevision(cursor)); |
| 196 | |
| 197 | while (subCtx && !subCtx->owner()) |
| 198 | subCtx = subCtx->parentContext(); |
| 199 | |
| 200 | Declaration* definition = nullptr; |
| 201 | |
| 202 | if (!subCtx || !subCtx->owner()) { |
| 203 | definition = DUChainUtils::declarationInLine(cursor, ctx); |
| 204 | } else { |
| 205 | definition = subCtx->owner(); |
| 206 | } |
| 207 | |
| 208 | if (!definition) { |
| 209 | return nullptr; |
| 210 | } |
| 211 | |
| 212 | return definition; |
| 213 | } |
| 214 | |
| 215 | //Returns only the name, no template-parameters or scope |
| 216 | QString cursorItemText() |
no test coverage detected