Search code examples
eclipseeclipse-plugineclipse-cdt

Supporting toggle between new file-types in eclipse or eclipse CDT


I would like to extend the source/header toggle functionality of eclipse CDT for custom file types. I work with *.cppml and *.hppml file extensions (C++ with some functional language syntax-extension), and I would like eclipse to understand that there is a source/header relationship between these two file types and toggle between them upon request.


Solution

  • The current CDT does not support this exactly, but it is pretty close, it needs an update to SourceHeaderPartnerFinder.

    That class has a method, getPartnerFileFromFilename, which calculates the partner when you do a Header/Source toggle (Ctrl+Tab by default, or available from Navigate -> Toggle Source/Header)

    That method strips off the extension of the file you started in, and then tries the partner type extensions (as derived from getPartnerContentTypes).

    What needs to be done is update getPartnerFileFromFilename to create new header/source partnerships. Perhaps you could even edit the File Types property pages to allow users to explicitly define such associations.

    If this feature is of value to you, raising it in CDT's Bugzilla would be a good start.