Need help with duchain infrastructure: function arguments do not appear in quickopen

Alexander Dymo alexander.dymo at gmail.com
Sat Feb 27 11:37:55 UTC 2010


Niko, David, a question for you :)

In my new Ruby plugin
http://websvn.kde.org/trunk/playground/devtools/kdevelop4-extra-plugins/ruby/
after parsing the file/project, quickopen doesn't show arguments for methods.

I have the usual infrastructure:
ContextBuilder => TypeBuilder => DeclarationBuilder

Relevant parts are:
void ContextBuilder::visitFunction(FunctionAST* ast) {
    openContext(ast, editorFindRange(ast, ast), KDevelop::DUContext::Function, 
ast->name);
    Visitor::visitFunction(ast);
    closeContext();
}

void TypeBuilder::visitFunction(FunctionAST* ast) {
    KDevelop::FunctionType::Ptr functionType = KDevelop::FunctionType::Ptr(new 
KDevelop::FunctionType());
    openType(functionType);
    updateCurrentType();
    TypeBuilderBase::visitFunction(ast);
    closeType();
}

void TypeBuilder::visitFunctionArgument(FunctionArgumentAST* ast) {
    KDevelop::AbstractType::Ptr type(new 
KDevelop::IntegralType(KDevelop::IntegralType::TypeMixed));
    openAbstractType(type);
    TypeBuilderBase::visitFunctionArgument(ast);
    closeType();
    KDevelop::DUChainWriteLocker lock(KDevelop::DUChain::lock());
    currentType<KDevelop::FunctionType>()->addArgument(type);
    // POINT 1
}

void DeclarationBuilder::visitFunction(FunctionAST* ast)
{
    {
        KDevelop::SimpleRange range = editor()->findRange(ast->name);
        KDevelop::QualifiedIdentifier 
id(KDevelop::Identifier(KDevelop::IndexedString(ast->name->name)));
        KDevelop::DUChainWriteLocker lock(KDevelop::DUChain::lock());
            KDevelop::ClassFunctionDeclaration *decl = 
openDefinition<KDevelop::ClassFunctionDeclaration>(id, range);
            decl->setAccessPolicy(ast->access);
            decl->setDeclarationIsDefinition(true);
            decl->setKind(KDevelop::Declaration::Type);
    }
    DeclarationBuilderBase::visitFunction(ast);
    // POINT 2
    closeDeclaration();
}


When I come to POINT 1 in the code, the function has its arguments. But after 
going out of this function and returning to POINT 2, I have no longer 
arguments in the function. 

updateCurrentType() function correctly sets the abstract type for a function 
declaration:
currentDeclaration()->setAbstractType(currentAbstractType());
So, quickopen does know about the function type. But when it prints it out, 
the arguments aren't there.

I'm definitely missing something, but what?




More information about the KDevelop-devel mailing list