Identifying Classes and Functions within .cpp and .h files [message #221556] |
Fri, 08 August 2008 14:51  |
Eclipse User |
|
|
|
Originally posted by: kevin.oberg.baesystems.com
I have the active editor IEditorPart, its input IFileEditorInput, and its
file IFile. I am trying to write a plug-in that will check the file open
in the active editor for proper Doxygen commenting above each function and
class, and add it if it is not present.
Is there any part of the file that will identify to me where (via line
number or position from start of file) the classes or functions are
declared or defined for .cpp and .h files? There must be something that
identifies these because their syntax coloring is properly working.
Apparently CDT has some sort of DOM, but I don't know how to access it.
Any help or suggestions are greatly appreciated!!!
|
|
|
|
Re: Identifying Classes and Functions within .cpp and .h files [message #221572 is a reply to message #221564] |
Sat, 09 August 2008 07:20   |
Eclipse User |
|
|
|
Hi,
I'm working with CDT 5.0 and this is how I get the AST contatining all the
parser information:
IFile foundFile = project.getFile(file.getPath());
IASTTranslationUnit tu =
CDOM.getInstance().getTranslationUnit(foundFile);
Then with tu you can access various elements, or let them accept an
ASTVisitor subclass.
Cheers
"Michael Schulte" <mischu72@gmx.de> wrote in message
news:g7jjlt$uo0$1@build.eclipse.org...
> Hi Kevin,
>
>
> If your input is of type IFile, maybe this could help. Given the file, I
> accessed the IIndex to determine the "included by" of a given source file:
>
> void retrieveInfoFromFile (IFile file) {
>
> ICProject project =
> CCorePlugin.getDefault().getCoreModel().create(file.getProje ct());
>
> if (project != null)
> {
> IIndex index = CCorePlugin.getIndexManager().getIndex(project);
>
> index.acquireReadLock(); // this is necessary to access the index
> information
>
> // do something with the index here...
> index.releaseReadLock();
> }
> }
>
> However the class IIndex is marked as "EXPERIMENTAL" since version 4.
> So - if you find a better way to retrieve the information about the
> classes, I would like to know :)
>
> By the way - I'm trying something similar at the moment - writing a
> plug-in with doxygen to check the comments (and show appropriate markers).
> The doxygen part still has to be enhanced... (the markers are still not
> right there where they should be)
>
> see:
> http://www.jaylib.org/cppchecker
>
>
> Michael
>
>> I have the active editor IEditorPart, its input IFileEditorInput, and its
>> file IFile. I am trying to write a plug-in that will check the file open
>> in the active editor for proper Doxygen commenting above each function
>> and class, and add it if it is not present.
>>
>> Is there any part of the file that will identify to me where (via line
>> number or position from start of file) the classes or functions are
>> declared or defined for .cpp and .h files? There must be something that
>> identifies these because their syntax coloring is properly working.
>> Apparently CDT has some sort of DOM, but I don't know how to access it.
>>
>> Any help or suggestions are greatly appreciated!!!
>>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04175 seconds