File indexing completed on 2024-04-14 14:47:47
0001 /* 0002 SPDX-FileCopyrightText: 2008 Niko Sams <niko.sams@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef PHPDUCHAINHELPER_H 0008 #define PHPDUCHAINHELPER_H 0009 0010 #include "phpduchainexport.h" 0011 0012 #include <language/duchain/identifier.h> 0013 #include <language/duchain/ducontext.h> 0014 #include <language/duchain/types/abstracttype.h> 0015 #include <serialization/indexedstring.h> 0016 #include "phpast.h" 0017 0018 namespace KDevelop 0019 { 0020 class Declaration; 0021 class DUContext; 0022 } 0023 namespace Php 0024 { 0025 class EditorIntegrator; 0026 0027 enum DeclarationType { 0028 ClassDeclarationType, 0029 FunctionDeclarationType, 0030 ConstantDeclarationType, 0031 GlobalVariableDeclarationType, 0032 NamespaceDeclarationType 0033 }; 0034 0035 enum DeclarationScope { 0036 GlobalScope, 0037 LocalScope 0038 }; 0039 0040 KDEVPHPDUCHAIN_EXPORT bool isMatch(KDevelop::Declaration* declaration, DeclarationType declarationType); 0041 0042 KDEVPHPDUCHAIN_EXPORT bool isGenericClassTypehint(NamespacedIdentifierAst* genericType, EditorIntegrator *editor); 0043 0044 KDEVPHPDUCHAIN_EXPORT bool hasClassTypehint(UnionParameterTypeAst* unionType, EditorIntegrator *editor); 0045 0046 KDEVPHPDUCHAIN_EXPORT bool hasClassTypehint(UnionPropertyTypeAst* unionType, EditorIntegrator *editor); 0047 0048 KDEVPHPDUCHAIN_EXPORT bool hasClassTypehint(UnionReturnTypeAst* unionType, EditorIntegrator *editor); 0049 0050 KDEVPHPDUCHAIN_EXPORT KDevelop::DeclarationPointer findDeclarationImportHelper(KDevelop::DUContext* currentContext, 0051 const KDevelop::QualifiedIdentifier& id, 0052 DeclarationType declarationType); 0053 0054 KDEVPHPDUCHAIN_EXPORT KDevelop::DeclarationPointer findDeclarationInPST(KDevelop::DUContext* currentContext, 0055 KDevelop::QualifiedIdentifier id, 0056 DeclarationType declarationType); 0057 0058 KDEVPHPDUCHAIN_EXPORT QByteArray formatComment(AstNode* node, EditorIntegrator* editor); 0059 0060 KDEVPHPDUCHAIN_EXPORT CommonScalarAst* findCommonScalar(AstNode* node); 0061 0062 KDEVPHPDUCHAIN_EXPORT KDevelop::IndexedString getIncludeFileForNode(UnaryExpressionAst* node, EditorIntegrator* editor); 0063 0064 KDEVPHPDUCHAIN_EXPORT QString prettyName(KDevelop::Declaration* dec); 0065 0066 KDEVPHPDUCHAIN_EXPORT const KDevelop::IndexedString& internalFunctionFile(); 0067 0068 KDEVPHPDUCHAIN_EXPORT const KDevelop::IndexedString& internalTestFile(); 0069 0070 /// Indexed string for 'Php', identifies environment files from this language plugin 0071 KDEVPHPDUCHAIN_EXPORT const KDevelop::IndexedString& phpLanguageString(); 0072 0073 /** 0074 * Get proper QualifiedIdentifier for a NamespacedIdentifierAst. 0075 * 0076 * Identifier will be all lowercase except for the last identifier if @p lastIsConstIdentifier is set to true. 0077 */ 0078 KDEVPHPDUCHAIN_EXPORT KDevelop::QualifiedIdentifier identifierForNamespace(NamespacedIdentifierAst* node, EditorIntegrator* editor, 0079 bool lastIsConstIdentifier = false); 0080 KDEVPHPDUCHAIN_EXPORT KDevelop::QualifiedIdentifier identifierForNamespace( 0081 NamespacedIdentifierBeforeGroupedNamespaceAst* node, 0082 EditorIntegrator* editor, 0083 bool lastIsConstIdentifier); 0084 KDEVPHPDUCHAIN_EXPORT KDevelop::QualifiedIdentifier identifierForNamespace( 0085 NamespacedIdentifierBeforeGroupedNamespaceAst* prefixNode, 0086 InnerUseNamespaceAst* node, 0087 EditorIntegrator* editor, 0088 bool lastIsConstIdentifier); 0089 0090 /** 0091 * Get proper QualifiedIdentifier for a basic identifier. 0092 */ 0093 KDEVPHPDUCHAIN_EXPORT KDevelop::QualifiedIdentifier identifierWithNamespace(const KDevelop::QualifiedIdentifier& base, KDevelop::DUContext* context); 0094 0095 KDEVPHPDUCHAIN_EXPORT KDevelop::AbstractType::Ptr parameterType(const ParameterAst* node, KDevelop::AbstractType::Ptr phpDocTypehint, EditorIntegrator* editor, KDevelop::DUContext *currentContext); 0096 KDEVPHPDUCHAIN_EXPORT KDevelop::AbstractType::Ptr propertyType(const ClassStatementAst* node, KDevelop::AbstractType::Ptr phpDocTypehint, EditorIntegrator* editor, KDevelop::DUContext *currentContext); 0097 KDEVPHPDUCHAIN_EXPORT KDevelop::AbstractType::Ptr returnType(const ReturnTypeAst* node, KDevelop::AbstractType::Ptr phpDocTypehint, EditorIntegrator* editor, KDevelop::DUContext *currentContext); 0098 0099 KDEVPHPDUCHAIN_EXPORT KDevelop::AbstractType::Ptr determineGenericTypeHint(const GenericTypeHintAst* genericType, EditorIntegrator *editor, KDevelop::DUContext* currentContext); 0100 0101 } 0102 #endif