Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Identifying Classes and Functions within .cpp and .h files
Identifying Classes and Functions within .cpp and .h files [message #221556] Fri, 08 August 2008 18:51 Go to next message
Eclipse UserFriend
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 #221564 is a reply to message #221556] Sat, 09 August 2008 08:14 Go to previous messageGo to next message
Michael Schulte is currently offline Michael SchulteFriend
Messages: 38
Registered: July 2009
Member
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!!!
>
Re: Identifying Classes and Functions within .cpp and .h files [message #221572 is a reply to message #221564] Sat, 09 August 2008 11:20 Go to previous messageGo to next message
M. Reza Motallebi is currently offline M. Reza MotallebiFriend
Messages: 2
Registered: July 2009
Junior Member
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!!!
>>
Re: Identifying Classes and Functions within .cpp and .h files [message #221864 is a reply to message #221556] Tue, 12 August 2008 18:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kevin.oberg.baesystems.com

So, I was looking through CDT 5.0's changelog, and sure enough, there
appears to have been added something like what we are looking for.

I haven't tried it out yet, but according to this page:

http://wiki.eclipse.org/CDT/User/NewIn50

"Doxygen editor support (plus framework)

Auto-generation of tags and a pluggable framework for other documentation
tools is now available."

Maybe that will fulfill all our wildest dreams!
Re: Identifying Classes and Functions within .cpp and .h files [message #221876 is a reply to message #221864] Tue, 12 August 2008 19:06 Go to previous message
Michael Schulte is currently offline Michael SchulteFriend
Messages: 38
Registered: July 2009
Member
that's why I wondered, what feature you intended to write...

But the only thing that is provided AFAIK is the auto generation of
comment tags, such as @param and @return, but not more!
The comments are neither checked nor is there an integrated new builder
for doxygen.
Previous Topic:Trying to create a new project type in the C++ new project wizard
Next Topic:Linux kernel on CDT
Goto Forum:
  


Current Time: Wed Jul 17 23:33:23 GMT 2024

Powered by FUDForum. Page generated in 0.03721 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top