ASTVisitor

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ASTVisitor

Ming Cheng
Hi,

ASTVisitor does not provide visit(ICPPASTLinkageSpecification ) and many other CPP specific types callback interface; neither of IASTPreprocessorIncludeStatement. What's the best practice of read these lines?

Thanks.

_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: ASTVisitor

Jonah Graham
Hello,

I believe you want visit(IASTDeclaration) for ICPPASTLinkageSpecification.

IIRC IASTPreprocessorIncludeStatement and the pre-processor in general is not visitable, use IASTTranslationUnit.getAllPreprocessorStatements() and/or getIncludeDirectives

Jonah


~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com
 

On Sat, 22 Feb 2020 at 03:59, Ming Cheng <[hidden email]> wrote:
Hi,

ASTVisitor does not provide visit(ICPPASTLinkageSpecification ) and many other CPP specific types callback interface; neither of IASTPreprocessorIncludeStatement. What's the best practice of read these lines?

Thanks.
_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: ASTVisitor

Ming Cheng

Hi Jonah and All,

 

Thanks for your kind help so I can move further along the a possible long way. Now I encountered another issue.

 

private static int visit(IIndex index, CPPASTFunctionDeclarator cppFunctionDeclarator) {

        display("Visiting CPPASTFunctionDeclarator: " + cppFunctionDeclarator.getRawSignature());

        processFuncName(index, cppFunctionDeclarator.getName().toString());

        return PROCESS_CONTINUE;

    }

 

private static void processFuncName(IIndex index, String funcName) {

        // find bindings for name

       

        try {

            index.acquireReadLock();

            IIndexBinding[] bindings= index.findBindings(funcName.toCharArray(),IndexFilter.ALL_DECLARED, new NullProgressMonitor());

            // find references for each binding

            JOptionPane.showMessageDialog(CurrentGui.getInstance().getGui().getMainFrame(), "IIndexBinding size=" + bindings.length, "INFO", JOptionPane.INFORMATION_MESSAGE);

            for (IIndexBinding b : bindings) {

                if (b instanceof IFunction) {

                    outputReferences(index, b);

                } else {

                    display("non IFunction");

                }

            }

        } catch (CoreException e) {

            log.error(e.getMessage());

        } catch (InterruptedException e) {

            log.error(e.getMessage());

        } finally {

            index.releaseReadLock();

        }

    }

 

When my program ran here:

 

 

The next prompt is “non IFunction”.

 

Index was created like this:

 

IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.UPDATE_ALL |

                                                                                IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT);

 

Thanks.

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: Saturday, February 22, 2020 9:36 PM
To: [hidden email]
Subject: Re: [cdt-dev] ASTVisitor

 

Hello,

 

I believe you want visit(IASTDeclaration) for ICPPASTLinkageSpecification.

 

IIRC IASTPreprocessorIncludeStatement and the pre-processor in general is not visitable, use IASTTranslationUnit.getAllPreprocessorStatements() and/or getIncludeDirectives

 

Jonah

 


~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com

 

 

On Sat, 22 Feb 2020 at 03:59, Ming Cheng <[hidden email]> wrote:

Hi,

 

ASTVisitor does not provide visit(ICPPASTLinkageSpecification ) and many other CPP specific types callback interface; neither of IASTPreprocessorIncludeStatement. What's the best practice of read these lines?

 

Thanks.

_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev

 


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev