So, I’m looking to develop a plugin for Eclipse 4.2 that monitors edits that a user makes to their files.
This is my first Eclipse plugin, and to prepare, I walked through the Eclipse plugin development cheat sheet (HelloWorld) and spent many hours on help.eclipse.org looking through the documentation and the API. I think I have some idea of what tools I need, but I’m not sure how to put those tools together to do what I want.
Desired Results: Have a plugin that’s kept apprised of every new letter added to a (Java) editor and any and all deletes. This includes things that Eclipse does (auto-completing variables, curly braces) as well as what the user types.
Tools that might help: I’m thinking that a IResourceChangeListener will assist, as it gives me a IResourceChangeEvent, with an accessible IResourceDelta which represents workspace changes. Also, since editors extend EditorPart, I’m thinking that adding a IPropertyChangeListener to the relevant editor may be useful as well.
I think I’ve got the right tools, but I’ve got no idea how to go about assembling them to do as I wish.
Questions:
Are the tools listed above the proper ones for the job?
How can I get a list of all editors opened or that will be opened and add listeners to them?
Any additional tips for resources on learning how to program Eclipse plugins?
Krumelur’s tip gave me a good starting point. The
DocumentEvents returned byIDocumentListenerare granular enough to give me a character by character analysis of what happened.As far as what I should extend, I extended
org.eclipse.ui.startupand added a series of listeners until I got to the code that looks like what I’ve got above.I hope this helps anybody else who is looking for what I was.