How does the the API remember which editor lines have icons in the gutter?

The mechanism through which a debug breakpoint comes to be associated with a particular line of text has what I want - the ability to track a particular statement, no matter how the file it's in is edited, and associate data with it. In this particular case, a breakpoint.

Moreover, the association persists between VMs (that is it endures through the closing
and re-opening of IntelliJ).

This ability is all I have ever dreamed of. How is it achieved and can I break myself off a little bit of the action?

I have tried to use UserData, but I can't persist the info.

I also tried to use the PSI as a type of makeshift URI. However, if two lines are EXACTLY the same text and come one right after the other, then there is no way to differentiate them using the PSI, except the fact that one comes before the other, which is useless.

Most things in the PSI are unique by virtue of the "paths" in the PSI that (can be used to) describe them, somewhat the way URIs are unique. But actually, as in the above example, two different lines can be indistinguishable as far as the PSI is concerned.

I just know this can be done. Breakpoints do it and so do VCS annotations. How do bookmarks work? I search the OpenAPI but found nothing for "bookmark".

In actuality, if anyone is in a position to give me exactly what I want, what I need is more fine-grained than what bookmarks and breakpoints offer, since I want to associate data with individual PSI elements.

2 comments

answering my own question (as I sometimes do)
TextAnnotationGutterProvider seems a likely candidate to me at this time.

But still I am really wanting the functionality provided by numbered bookmarks if anyone knows anything about this.

Message was edited by:
softwarevisualization

0

Hello softwarevisualization,

There is nothing magical in the way breakpoints work. All that is stored
for breakpoints in external configuration files is class name, package name
and line number. Thus, if you modify a source file while IntelliJ IDEA is
not running and then reload IntelliJ IDEA, the breakpoint will remain at
the same line even if it currently contains different code.

While IntelliJ IDEA is running, it watches for document changes and updates
the breakpoint line numbers accordingly. This doesn't use any PSI structures.

Bookmarks work in essentially the same way.

The mechanism through which a debug breakpoint comes to be associated
with a particular line of text has what I want - the ability to track
a particular statement, no matter how the file it's in is edited, and
associate data with it. In this particular case, a breakpoint.

Moreover, the association persists between VMs (that is it endures
through the closing and re-opening of IntelliJ).

This ability is all I have ever dreamed of. How is it achieved and can
I break myself off a little bit of the action?

I have tried to use UserData, but I can't persist the info.

I also tried to use the PSI as a type of makeshift URI. However, if
two lines are EXACTLY the same text and come one right after the
other, then there is no way to differentiate them using the PSI,
except the fact that one comes before the other, which is useless.

Most things in the PSI are unique by virtue of the "paths" in the PSI
that (can be used to) describe them, somewhat the way URIs are unique.
But actually, as in the above example, two different lines can be
indistinguishable as far as the PSI is concerned.

I just know this can be done. Breakpoints do it and so do VCS
annotations. How do bookmarks work? I search the OpenAPI but found
nothing for "bookmark".

In actuality, if anyone is in a position to give me exactly what I
want, what I need is more fine-grained than what bookmarks and
breakpoints offer, since I want to associate data with individual PSI
elements.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.