Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Re: Cross-language navigation (Nicolas Musset)

Hi Nicolas,

From: Nicolas Musset <musset@xxxxxxxxxxx>
> I started working on a cross-language navigation between C and Ada. 

I encountered a similar issue when trying to enable navigation between C/C++ source code and some assembly code (cf  https://bugs.eclipse.org/bugs/show_bug.cgi?id=160447).

> On one hand Ada to C navigation works fine because my Ada project knows 
> about CDT (a CDT project is associated with the Ada project), and I can 
> use PDOMManager and IIndex to find the corresponding binding with its name.

The assembly files generated by our compiler contain source locations, so it's also easy to open a CDT editor at the proper line from an assembly file. Forward navigation from CDT to our assembly editor is the real issue.

> On the other hand, CDT does not know about my Ada Project. So if I 
> Ctrl-click on a function defined as "extern", nothing happens. I don't 
> know how to tell Eclipse to go to the corresponding Ada source file.

If your Ada plug-in also has an index and if you limit the navigation to high level elements like functions, it should be possible to write a menu contribution to the CDT editor. This contribution then needs to retrieve the selection and performs a look-up in the Ada index. Not very pretty but could help.

From: "Schorn, Markus" <Markus.Schorn@xxxxxxxxxxxxx>
> The necessary extension-point + interfaces/classes should probably be
> defined in CDT. 

Markus, I'm not sure about that. How do you handle e.g. Java/Ada navigation if everything is in CDT ? I think we need a generic framework in the platform and then each language specific plug-in should provide its own bridge.

The most accurate way to provide cross language navigation is to introduce some kind of a type system in which the most common constructs of all programming languages could be expressed (function/method ?). With something like that it should be possible to have a generic type-based search view from which you could for example search for all methods named 'foo' having signature 'int * string -> float' in heterogeneous source files (currently each language has its own tab in the search view).

Navigation from/to C could be implemented in a cheaper/easier way as type parameters are not used for name resolution, but as soon as you want to handle C++ constructs you may need such a type system. In our context (C/C++ <-> assembly) we even need mangling/demangling support to find the proper mangled symbol in an assembly file when starting from a C++ signature (so cross-indexing is not only language specific, but in the CDT context could also require tool-chain specific support).

Back to the top