Half-height row margins above-and-below every block-starting statement

Answered

Hi Folks,

I love the condensed Java coding style [ having { at end of the block-starting statement and not on its own separate line ] and yet I find the old C-style easier to read.

Now this is a big ask, because up until now every "line" in the Editor is the same height, but:

Would it be possible to add a configurable feature which will place a half row-height margin of blank space immediately before-and-after (not one or 'tother) any block-starting statement?  

I would apply it also before-and-after any comment.

We could still have blank lines also, and a blank line before a block-starting statement might appear as a 1.5 height blank.

I'm very interested in any Community discussion on this.

Kind regards, Robin.

6 comments
Comment actions Permalink

Request is welcome at https://youtrack.jetbrains.com/issues/IDEA .

It looks like API is already there, so it should be technically possible via the plug-in: https://youtrack.jetbrains.com/issue/IDEA-183815 .

0
Comment actions Permalink

InlayModel looks like it will provide the required capability.

This would be my first attempt at an IntelliJ Plugin. Can you recommend a getting started guide, and perhaps an community plugin to which I could refer, one which is active on an Editor context and illustrated access to the Editor content?

Thanks, Robin.

0
Comment actions Permalink

I've asked the responsible developer to comment here. It would be also better to post API and plug-in development questions in a different forum: https://intellij-support.jetbrains.com/hc/en-us/community/topics/200366979-IntelliJ-IDEA-Open-API-and-Plugin-Development.

0
Comment actions Permalink

Hi Robin,

I'm afraid there are no good guides or example plugins at the moment, as the API to add such elements to editor is relatively new. Platform SDK guide (https://www.jetbrains.org/intellij/sdk/docs/welcome.html) doesn't cover this topic, but is worth reviewing if you're new to IntelliJ plugin development.

Creating an 'InlayHintsProvider' implementation in your plugin seems to be the optimal way to achieve what you need. You can take existing implementations in IDEA CE codebase (MethodChainsInlayProvider, AnnotationInlayProvider) as examples.

 

0
Comment actions Permalink

Thanks, Dmitry, for the link to the SDK Docs.

I think my plugin will apply to existing Editor(s), and will not create a new Editor.  Is that correct?  Is there example source for a plugin which applies to the existing (Java) Editor, even a demo one which just capitalises certain words, for instance?

Also, is there an indentation model or would I have to infer block-start block-end from the text or from the PSI?

I am setting up my IDE for plugin development this morning.

Kind regards, Robin.

 

0
Comment actions Permalink

> I think my plugin will apply to existing Editor(s), and will not create a new Editor. Is that correct?

That's correct.

> Is there example source for a plugin which applies to the existing (Java) Editor, even a demo one which just capitalises certain words, for instance?

Some samples are mentioned in the SDK guide, e.g. this one - https://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support_tutorial.html. It's not exactly your case, as the plugin adds a support for a new language, but some aspects would be the same as extending the functionality for an existing language. E.g. creating a custom folding builder (https://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/folding_builder.html) is conceptually similar to creating an InlayHintsProvider - based on source code and its PSI, you declare where to place certain editor entities, and the platform creates them for you.

> Also, is there an indentation model or would I have to infer block-start block-end from the text or from the PSI?

I think, you'll need to work with text and/or PSI.

0

Please sign in to leave a comment.