void DeclarationBuilder::visitFuncDeclaration(IFunctionDeclaration *node) { TypeBuilder::visitFuncDeclaration(node); DUChainWriteLocker lock; if(inClassScope) { ClassFunctionDeclaration *newMethod = openDefinition<ClassFunctionDeclaration>(node->getName(), node); if(node->getComment()) newMethod->setComment(QString::fromUtf8(node->getComment())); newMethod->setKind(KDevelop::Declaration::Type); lock.unlock(); ContextBuilder::visitFuncDeclaration(node); lock.lock(); closeDeclaration(); newMethod->setInternalContext(lastContext()); newMethod->setType(currentFunctionType); } else { FunctionDeclaration *newMethod = openDefinition<FunctionDeclaration>(node->getName(), node); if(node->getComment()) newMethod->setComment(QString::fromUtf8(node->getComment())); newMethod->setKind(KDevelop::Declaration::Type); lock.unlock(); ContextBuilder::visitFuncDeclaration(node); lock.lock(); closeDeclaration(); newMethod->setInternalContext(lastContext()); newMethod->setType(currentFunctionType); } }
FunctionDeclaration *UserTypeDeclaration::getMethod(std::string name, ASTFunctionType *opt_ty) { for(int i = 0; i < methods.size(); i++) { if(name == methods[i]->getName()) { FunctionDeclaration *fdecl = methods[i]; while(fdecl) { //XXX using 'coercesTo' so that first parameter 'this' may convert to proper type if(!opt_ty || fdecl->getType()->coercesTo(opt_ty)) { return fdecl; } fdecl = fdecl->getNextOverload(); } } } return NULL; }
void DeclarationBuilder::visitFunctionOrRuleClause(erlang::FunctionOrRuleClauseAst* node) { if (node->function_name) { FunctionDeclaration* func = openDeclaration<FunctionDeclaration>(node->function_name, node->body); func->setDeclarationIsDefinition(true); func->setKind(KDevelop::Declaration::Type); DeclarationBuilderBase::visitFunctionOrRuleClause(node); closeDeclaration(); } else { DeclarationBuilderBase::visitFunctionOrRuleClause(node); } }
bool ItemReaderASTVisitor::visit(AST::FunctionDeclaration *ast) { FunctionDeclaration f; if (Q_UNLIKELY(ast->name.isNull())) throw ErrorInfo(Tr::tr("function decl without name")); f.setName(ast->name.toString()); // remove the name QString funcNoName = textOf(m_file->content(), ast); funcNoName.replace(QRegExp(QLatin1String("^(\\s*function\\s*)\\w*")), QLatin1String("(\\1")); funcNoName.append(QLatin1Char(')')); f.setSourceCode(funcNoName); f.setLocation(toCodeLocation(ast->firstSourceLocation())); m_item->m_functions += f; return false; }
Var(const std::string& name, FunctionDeclaration& funcDecl, const AddressSpace& q = DEFAULT) : _identifier(name), _qualifier(q), _inlineValue(false), _value(0) { funcDecl.argument(*this); }
Var(const std::string& name, const AddressSpace& q, FunctionDeclaration& funcDecl, const bool isArg) : _identifier(name), _qualifier(q), _inlineValue(false), _value(0) { if (isArg) funcDecl.argument(*this); }
Var(const std::string& name, FunctionDeclaration& funcDecl, const bool inlineValue, const int value, const AddressSpace& q = DEFAULT) : _identifier(name), _qualifier(q), _inlineValue(inlineValue), _value(value) { if (! inlineValue) funcDecl.argument(*this); }
FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration& rhs) : KDevelop::FunctionDeclaration(*new FunctionDeclarationData(*rhs.d_func())) { }
ASTType *getType() { if(overload) return overload->getType(); if(fpointer) return fpointer->getType(); return NULL; }
FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration& other) : FunctionTypeSpecifier(other.GetParameterTypeList(), other.GetReturnTypeSpecifier(), other.GetLocation()), m_parameter_list( other.m_parameter_list) { }