Hyperclose eclipse console - pending entries causing BadLocationException?

I am writing an eclipse plugin with console hyperlink, but I see BadLocationExceptions when creating hyperlinks.

To create a hyperlink, I followed the instructions on the relevant question How to write a hyperlink to the eclipse console from the plugin .

Prerequisites: The problem is that the base document is updated asynchronously for requests that are written to the console (for example, via MessageOutputStream), so trying to create a hyperlink immediately after recording, t, because the offset and length indices specified in the request are invalid.

To fix this, I created a DocumentListener in the base document, so I could detect when the console was updated and create HyperLink at that moment. But the listener is provided with events that correspond to mass console updates, so I cannot easily determine if the console is updated. The only choice seems to be to look for a console document for the line I want to use for the hyperlink, which seems pretty inefficient.

So the question is : when do you need to create HyperLink correctly after writing to the console? Are there any proven mechanisms to ensure that the base document is updated when I request a hyperlink? Sample code that writes to the console, then creates HyperLink, would be great.

Not sure about the exact version of eclipse (I write this from home before I get started), but I know that I'm using MessageConsole.addHyperlink () for the request.

+3
source share
1 answer

I am in the same situation and came to the same conclusion: I add a hyperlink to the document receiver, and then delete the document listener. Please note that you have no choice but to search for a string, because the console can be cleared by the user! In my case, this is not a serious decrease in performance, so I am pleased with this solution.

0
source

Source: https://habr.com/ru/post/1726036/


All Articles