[Qt-creator] FunctionDefinitionAST* to Declaration*

Lorenz Haas lykurg at gmail.com
Wed Apr 3 21:56:03 CEST 2013


I have a FunctionDefinitionAST pointer to e.g.

    void setA(int a) {
        m_a = a;

at a _header_ file and the file name of the corresponding cpp file. (And
a CppQuickFixInterface pointing to the header file, if that is
important. It's inside a CppQuickFixFactory::match function.)

Now I want to know where to put a definition of that function in the cpp
file (and if there is already a definition (which would be a exit
condition)). The code I would like to use for that is

    CppRefactoringChanges refactoring(interface->snapshot());
    InsertionPointLocator locator(refactoring);
    foreach (const InsertionLocation &loc, locator.methodDefinition(
                                        /* Declaration pointer */)) {
        // do stuff here

But I can't figure out, how to get a Declaration pointer to that
function (setA) which is declared and defined in the header file.
Meaning: get Declaration* out of FunctionDefinitionAST*/Function*.

Thanks for any hints,

P.s.: During looping through interface->path() nodes I get two results
for node->asDeclaration() but I also fail to convert DeclarationAST* to
Declaration* to be accepted by
InsertionPointLocator::methodDefinition(). And I also get a
SimpleDeclarationAST* but the symbol list is empty.

More information about the Qt-creator mailing list