Currently visible method(s) tracker

Answered

Is there a simple way for getting the current code a developer is viewing? For example, is there a way to get a list of methods that are currently being displayed?

I'm looking to trigger events when users open and/or scroll past certain code. I only want the event to trigger when the code is visually displayed. My plan was to add file open/closed listeners and editor scroll listeners and keep track of what's currently between the visible start/end line offsets. Is there anything IntelliJ has built-in for this functionality?

3 comments
Comment actions Permalink

See com.intellij.openapi.editor.event.VisibleAreaListener

0
Comment actions Permalink

I should have mentioned I'm already using VisibleAreaListener. When I mentioned "editor scroll listeners", I should have said visible area listeners.

With that being said, is what I've described the most efficient way to achieve what I'm looking for? Is there anything extending VisibleAreaListener that provides more information than just the visible area?

0
Comment actions Permalink

Please see com.intellij.diff.tools.util.SyncScrollSupport.ScrollHelper as reference on how to map these events into Editor coordinates/caret position etc. which can then be used to obtain displayed content/PSI etc

0

Please sign in to leave a comment.