Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDocument cannot be resolved to a type

I'm very new to eclipse plugin devalopment and i want to get content from editor using eclipse plugin so i found this answer.

But problem is: I get the compile error IDocument cannot be resolved to a type. No quick fix imports available. My Eclipse version is 3.8.2.

How can I fix this problem?

The code I used (from the linked answer) is this:

public String getCurrentEditorContent() {
    final IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getActiveEditor();
    if (activeEditor == null)
        return null;
    final IDocument doc = (IDocument) activeEditor.getAdapter(IDocument.class);
    if (doc == null) return null;

    return doc.get();
}

enter image description here

I can't find org.eclipse.jface.text among my dependencies. Here is a snapshot:

enter image description here

like image 502
Madhawa Priyashantha Avatar asked Dec 04 '25 10:12

Madhawa Priyashantha


1 Answers

IDocument is in the org.eclipse.text plugin so you must add this to your plugin's dependencies list.

Note: You can also add the org.eclipse.jface.text plugin to the dependencies list as that will include the org.eclipse.text plugin.

like image 109
greg-449 Avatar answered Dec 06 '25 23:12

greg-449



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!