Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Changelog C/C++ parser

Hi all,

I'm working on a changelog utility for C/C++/Java/(insert language
here). I'm currently rewriting the function guess routines (they were
previously just a generic parser that parsed IDocuments gained from
IEditorPart); but now, I've moved to an extension point approach, which
allows us to use the object model of a particular language contributed
to Eclipse. Anyway, in Java I can get the current function under the
cursor via CompilationUnit. I'm looking for an approach on how to write
the C/C++ function guess routines. In very rough form for Java,
something like:


if (editor instanceof CompilationUnitEditor) {

CompilationUnitEditor java_editor = (CompilationUnitEditor) editor;     

ITextSelection selection = (ITextSelection)
java_editor.getSelectionProvider().getSelection();

IEditorInput input = java_editor.getEditorInput();
IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
manager.connect(input);
ICompilationUnit workingCopy = manager.getWorkingCopy(input);
IJavaElement method = workingCopy.getElementAt(selection
                                        .getOffset());

In this instance JavaElement method would be the function within
whatever the current location of the  cursor in the editor is. I want to
make a contribution based on the C/C++ editors, and was polling for the
best way to get the current function under the "cursor".

Thanks,

Phil Muldoon



Back to the top