LeGEC
LeGEC

Reputation: 51780

Custom command for Eclipse on current buffer

My question is related to this one : Custom command for Eclipse on current file

but the answer there does not exactly fit what I am looking for.

I would like to run an external command (e.g : an external code formatter) on the current buffer (e.g : pipe the buffer's content to the command's standard input) and load the result back in the current buffer, with the possibility to undo (Ctrl+Z) the action.

I want to act on the buffer content, not the content of the file stored on disk.

Is there a way to do that without writing a custom Eclipse plugin ?

Upvotes: 0

Views: 38

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328556

External commands can't access the Document instance which the text editors use to store the data. External commands can only access files, so you need to save the editor content, first.

That means you either need to write a plugin which allows external commands to look at editors (maybe a JSON/REST-based query service) or you need to write a new plugin which does everything.

Have a look at Eclipse Monkey, it should be pretty simple to create a script which does what you want without starting PDE. Note that Monkey is discontinued but it still works since it depends only on a few core APIs.

Upvotes: 1

Related Questions