user3408654
user3408654

Reputation: 301

How to insert visual elements inside the Java text editor of Eclipse?

I'd like to add extra visual elements inside the Java text editor of Eclipse, more specifically on top of classes and methods declarations. Things like indicators and links.

The best example is what Microsoft has done in Visual Studio with what they call CodeLens:

Visual Studio CodeLens

The closest solution I can think of is using Annotations (displayed in the rulers) but it's far from the user experience I want to have.

Are there any Eclipse plugins that have done this before?

Any pointers to give me somewhere to start?

Upvotes: 2

Views: 495

Answers (2)

Angelo
Angelo

Reputation: 2125

Disclaimer, I'm the author of CodeLens Eclipse.

Eclipse doesn't provide Codelens feature, but it exists CodeLens Eclipse.

This project provides a CodeLens extension point to implement your own CodeLens. Today TypeScript, Java JDT CodeLens and lsp4e CodeLens are available. Here a little demo with Java JDT Editor:

JDT CodeLens Demo

Upvotes: 2

nitind
nitind

Reputation: 20003

Annotations are typically shown in the vertical and overview rulers (left and right), but they're not limited to them. Take a closer look at the documentation you linked to, particularly the mentions of AnnotationPainter, and then how it uses drawing strategies. I expect you'd need a rather complicated one, and I haven't even thought through how you'd generate the information in the first place, never mind adding it directly to the Annotation Model if you're not just going to stash it in a Marker on disk.

Of course, some of this looks like information you can already find through Team->Show Annotations (although that does use the ruler to let you find them by line).

Upvotes: 2

Related Questions