adapt to kdevplatform changes, use DeclarationPointer when the duchain might get...
[kdevelop:php.git] / duchain / helper.h
1 /***************************************************************************
2  *   This file is part of KDevelop                                         *
3  *   Copyright 2008 Niko Sams <niko.sams@gmail.com>                        *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU Library General Public License as       *
7  *   published by the Free Software Foundation; either version 2 of the    *
8  *   License, or (at your option) any later version.                       *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU Library General Public     *
16  *   License along with this program; if not, write to the                 *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20 #ifndef PHPDUCHAINHELPER_H
21 #define PHPDUCHAINHELPER_H
22
23 #include "phpduchainexport.h"
24
25 #include <language/duchain/identifier.h>
26 #include <language/duchain/ducontext.h>
27 #include <language/duchain/indexedstring.h>
28
29 namespace KDevelop
30 {
31 class Declaration;
32 class DUContext;
33 }
34 namespace Php
35 {
36 class UnaryExpressionAst;
37 class AstNode;
38 class CommonScalarAst;
39 class EditorIntegrator;
40 class NamespacedIdentifierAst;
41
42 enum DeclarationType {
43     ClassDeclarationType,
44     FunctionDeclarationType,
45     ConstantDeclarationType,
46     GlobalVariableDeclarationType,
47     NamespaceDeclarationType
48 };
49
50 KDEVPHPDUCHAIN_EXPORT bool isMatch(KDevelop::Declaration* declaration, DeclarationType declarationType);
51
52 KDEVPHPDUCHAIN_EXPORT KDevelop::DeclarationPointer findDeclarationImportHelper(KDevelop::DUContext* currentContext,
53         KDevelop::QualifiedIdentifier id,
54         DeclarationType declarationType,
55         AstNode* node,
56         EditorIntegrator* editor);
57
58 KDEVPHPDUCHAIN_EXPORT QByteArray formatComment(AstNode* node, EditorIntegrator* editor);
59
60 KDEVPHPDUCHAIN_EXPORT CommonScalarAst* findCommonScalar(AstNode* node);
61
62 KDEVPHPDUCHAIN_EXPORT KDevelop::IndexedString findIncludeFileUrl(const QString &includeFile, const KUrl &currentUrl);
63
64 KDEVPHPDUCHAIN_EXPORT KUrl getUrlForBase(const QString &includeFile, const KUrl &baseUrl);
65
66 KDEVPHPDUCHAIN_EXPORT KDevelop::IndexedString getIncludeFileForNode(UnaryExpressionAst* node, EditorIntegrator* editor);
67
68 KDEVPHPDUCHAIN_EXPORT QString prettyName(KDevelop::Declaration* dec);
69
70 KDEVPHPDUCHAIN_EXPORT const KDevelop::IndexedString& internalFunctionFile();
71
72 /**
73  * Get proper QualifiedIdentifier for a NamespacedIdentifierAst.
74  *
75  * Identifier will be all lowercase except for the last identifier if @p lastIsConstIdentifier is set to true.
76  */
77 KDEVPHPDUCHAIN_EXPORT KDevelop::QualifiedIdentifier identifierForNamespace(NamespacedIdentifierAst* node, EditorIntegrator* editor,
78                                                                            bool lastIsConstIdentifier = false);
79 }
80 #endif