Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Doubts regarding indexer and parsing of source file

The CDOM is way out of date and very very deprecated at this point. In short, don't use it.

===========================
Chris Recoskie
Team Lead, IBM CDT and RDT
IBM Toronto
Inactive hide details for Nayna Jain <naynjain@xxxxxxxxxx>Nayna Jain <naynjain@xxxxxxxxxx>


          Nayna Jain <naynjain@xxxxxxxxxx>
          Sent by: cdt-dev-bounces@xxxxxxxxxxx

          04/07/2009 04:51 AM

          Please respond to
          "CDT General developers list." <cdt-dev@xxxxxxxxxxx>

To

cdt-dev@xxxxxxxxxxx

cc


Subject

[cdt-dev] Doubts regarding indexer and parsing of source file

Hi all,

I have the following questions :-

#1. Given a class ICPPClassType how to get the header file where it is
defined ?
#2. Given a function IFunction, how to get which header file it is defined
or declared ?
#3. Given a FunctionDeclarator, how to find whether it is only a
declaration or definition or both ?
#4. How to index the specific file or set of files programmatically ?

To give more details on how I actually tried, following is the scenario
given :-

I need to parse C++ SourceFiles or Header files.

I started with getting dom using

CDOM dom = CDOM.getInstance() .

Then,  IASTTranslationUnit tu = dom.getTranslationUnit(new
FileStorage(fileName) , project).

And then using visitor pattern I started parsing this translation unit .
i.e. making shouldVisitDeclarations and shouldVisitDeclSpecifiers = true
and then giving tu.accept().

Till this it was OK.

But then for class methods defined in .C file I wanted to get its header
file. And I also wanted header for SuperClasses of this class.

>From IFunction, ICPPMethod and ICPPClassType I couldn't get anything.

So, I thought that AST doesn't contain any information for binding
locations.

And so I moved to Indexer.

However if the source file is copied into workspace from some other place
then that file is not indexed and so IIndex.findNames() or
findDefinitions() or findDeclarations() also didn't return anything.

So, I realized that the file is not indexed so it won't have information.

So, I tried

IIndexManager.reindex() method or IIndexManager.update(cProject,
IIndexManager.UPDATE_ALL) as I wanted to index all  the files whether they
are modified or not.

But that didn't seem to work for me. i am still not knowing why it didn't
work.

Finally I thought of doing indexing via WritablePDOM. And so used

WritablePDOM.acquireWriteLock()
WritablePDOM.addBinding(binding);
WritablePDOM.releaseWriteLock().

But then sometimes it works and sometimes it doesn't and gives all sort of
surprising exceptions which I couldn't understand. Moreover they are
internal APIs which actually I don't want to use for my project.

Your answers will be of great help.

Thanks & Regards,
     - Nayna Jain

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev

GIF image

GIF image

GIF image


Back to the top