Add AbstractDeclarationNavigationContext, and move the html-method from
[kdevelopdvcssupport.git] / language / duchain / duchainutils.h
blobebfe43bcefcd1aafa1b642dc710e2598e9b73e8e
1 /*
2 * DUChain Utilities
4 * Copyright 2007 Hamish Rodda <rodda@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef DUCHAINUTILS_H
23 #define DUCHAINUTILS_H
25 #include <KIcon>
27 #include <ktexteditor/codecompletionmodel.h>
29 #include "../languageexport.h"
31 class KUrl;
33 namespace KDevelop {
35 class Declaration;
36 class DUChainBase;
37 class DUContext;
38 class SimpleCursor;
39 class HashedString;
40 class TopDUContext;
42 /**
43 * A namespace which contains convenience utilities for navigating definition-use chains.
45 namespace DUChainUtils {
46 KDEVPLATFORMLANGUAGE_EXPORT KTextEditor::CodeCompletionModel::CompletionProperties completionProperties(Declaration* dec);
47 KDEVPLATFORMLANGUAGE_EXPORT QIcon iconForProperties(KTextEditor::CodeCompletionModel::CompletionProperties p);
48 KDEVPLATFORMLANGUAGE_EXPORT QIcon iconForDeclaration(Declaration* dec);
49 /** Asks the language-plugins for standard-contexts for the given url, and returns one if available.
50 * If there is no language-plugin registered for the given url, it will just try to get any top-context for the file from the du-chain. */
51 KDEVPLATFORMLANGUAGE_EXPORT KDevelop::TopDUContext* standardContextForUrl(const KUrl& url);
52 /** Returns the Declaration/Definition under the cursor, or zero. DUChain does not need to be locked.
53 * If the item under the cursor is a use, the declaration is returned. */
54 KDEVPLATFORMLANGUAGE_EXPORT Declaration* itemUnderCursor(const KUrl& url, const SimpleCursor& cursor);
55 /**If the given declaration is a definition, and has a real declaration
56 *attached, returns that declarations. Else returns the given argument. */
57 KDEVPLATFORMLANGUAGE_EXPORT Declaration* declarationForDefinition(Declaration* definition, TopDUContext* topContext = 0);
58 ///Returns the first declaration in the given line. Searches the given context and all sub-contexts.
59 KDEVPLATFORMLANGUAGE_EXPORT Declaration* declarationInLine(const KDevelop::SimpleCursor& cursor, KDevelop::DUContext* ctx);
61 class KDEVPLATFORMLANGUAGE_EXPORT DUChainItemFilter {
62 public:
63 virtual bool accept(Declaration* decl) = 0;
64 //Should return whether processing should be deepened into the given context
65 virtual bool accept(DUContext* ctx) = 0;
66 virtual ~DUChainItemFilter();
68 ///walks a context, all its sub-contexts, and all its declarations in exactly the order they appear in in the file.
69 ///Re-implement DUChainItemFilter to do something with the items.
70 KDEVPLATFORMLANGUAGE_EXPORT void collectItems( DUContext* context, DUChainItemFilter& filter );
72 KDEVPLATFORMLANGUAGE_EXPORT DUContext* getArgumentContext(Declaration* decl);
77 #endif // DUCHAINUTILS_H