Search code examples
javaeclipse-plugineclipse-cdt

Cannot extend CDT CEditor: "The hierarchy of the type '' is inconsistent"


When trying to write a class that extends I get the error message:

The hierarchy of the type 'MYEditor' is inconsistent.

import org.eclipse.cdt.internal.ui.editor.CEditor;

public class MYEditor extends CEditor {

}

This answer says:

These errors happened because some interface/class in the hierarchy cannot be resolved.

This indicates that eclipse cannot find a class in the hierarchy. But when I use the class in my plugin.xml, it works. I am using it like this:

<editor
    class="org.eclipse.cdt.internal.ui.editor.CEditor"
    contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
    default="true"
    filenames="*.grasp, *.c"
    icon="icons/small.png"
    id="de.blub.ide.myeditor"
    name="My Editor">
</editor>

This works, but lacks a few features that I need for my plugin. That's why I want to use a class that inherits from CEditor.

This answer didn't work, to (remove and add JRE System Library).

I've also read that the jar file needs to be put in the Classpath section of the plugin.xml. But the "Add" and "New" Buttons don't provide a way to chose an external jar file. I can manually copy that jar file from "~/.p2/pool/plugins" into my projects lib folder, but that didn't help.


Solution

  • Plug-ins reference code in other plug-ins by including the other plug-in in their dependencies list. This is the Require-Bundle entry in the plug-in's MANIFEST.MF.

    In the MANIFEST.MF/plugin.xml/build.properties editor you can set the dependencies in the 'Required Plug-ins' section on the 'Dependencies' page.

    Do not copy plugin jars, do not put plugin jars in the Java Build Path.

    But note that extending internal classes is against the Eclipse API Rules of Engagement. Internal classes may change without warning and may be different in older releases.

    The CDT Plug-in Programmer's Guide covers the official APIs for Eclipse CDT.