How do I adjust the position attributes of custom Eclipse markers when a file is edited by typing? - eclipse

Does Eclipse adjust the position attributes of custom markers when a file is edited?
I have many Eclipse plugins in which I successfully create and delete markers, create quick fixes, and apply edits to the active editor programmatically. When text is inserted or deleted from the buffer all the text in the editor shifts, of course, and Eclipse's markers and my custom markers stay in synch with the text.
The problem is that when the file is edited, whether by regular typing or programmatically by changing the IBuffer, the attributes (e.g. CHAR_START) are not modified - they report the values when the marker was created and first made visible. So when one goes to do a QuickFix on the marker, for example, the reported position is incorrect. (This is an info marker, in CDT, if that matters.)
How are these marker positions supposed to be updated when edits happen?
Is there an Eclipse way to do this, but I need to implement some setting or notification or listener?
One possibility is to implement a ResourceChangeReporter - but it is not triggered for me when text edits happen, just when, for example, a save is invoked. And, if it were, I don't see information about how the file is actually altered.
I suppose I could require that a dirty file be saved before the quick fix is applied, but I still don't see where to obtain information about the file's edits. If I apply the edit programmatically, I know this information, but it does not help when the edit happens by typing.

Marker positions can be updated during editing using an updater declared using the org.eclipse.ui.editors.markerUpdaters extension point and implementing the IMarkerUpdater interface.
However there is a default updater org.eclipse.ui.texteditor.BasicMarkerUpdater which is already active for all markers which should be doing basic position updating for you.

Related

Highlighting a point (or an offset) in a file instead of a region

I am developing an Eclipse plug-in, and I want to highlight some points (between two consecutive characters in a file) instead of a region of text.
As an example, suppose that I want to highlight the position where foo has been deleted in a source file.
I know about the Markers(link), and I can set an annotation to a point in file, which can be shown in the side ruler areas.
Would there be any way to make it visible directly within the editor area itself?
It's obvious to highlight an area of text using something like boxes, underlines, but I couldn't find anything for a single point.
It would be nice if I could draw something like a caret, or a text cursor mark to some of the points I want to highlight.
I'm afraid annotations is the only civilized way to do it. You can apply them without markers as markers only simplify annotations management and provide persistence mechanism. All depends on how you get the information on what to highlight. Any more details on that?
If you're looking only for a way to customize annotation painting there's no way to do it via API. See in AnnotationPainter.getDecoration(), this is where the stuff happens. Looks like you can customize it only if you provide your own editor. More here - http://www.eclipse.org/forums/index.php/t/102865/.

Get Eclipse columns to stay as they've been set

I've customized the perspectives I use often in Eclipse pretty thoroughly. Sometimes, however, I accidentally close a window and I need to reopen it. However, when I do, all the selected columns reset to the defaults.
The easiest way to reproduce this, is in Java mode (or any mode, I suppose):
Choose upside-down triangle in the Tasks view
Click configure columns
Remove a column, such as "Completion".
Window -> Save Perspective as... It will say "do you wish to overwrite Java"?
Choose yes, because the changes don't actually save anyway
Window -> New Window
And you will see, in the new Window, the removed column has returned!
Is there a way to make this change permanent? I tried looking through the files in /.metadata/.plugins/.org.eclipse.core.runtime/.settings but as I didn't know what I was looking for, I didn't know what to change. I also tried File->Export->General->Preferences, but the Tasks settings file created there had no mention of columns. I also tried the advice in this thread but none of it was helpful really. Does this feature exist?
Edit: After getting little response here and on their forums, I have created an Eclipse bug

Temporarily inlay text in Eclipse CEditor

I am creating an Eclipse plugin. It creates custom Problem markers. What I would like to do is inlay text at the marker location in the CEditor to give the user information. Basically add a comment, but I do not want these comments saved when the user saves the file. Is there a way to do this in Eclipse or is there a plugin that I can use to do this? Thank you in advance.
I have solved this. It can be done by treating the editor as a styledText area. With this other controls can be added to the styledText area. I just added a label with my text. Since the label is not part of the actual file it does not get saved with the file. Upon close of the file in the editor the label is disposed and the underlying file is left unmodified by the addition of the label.

Eclipse - Change problems view action

I am currently working on eclipse plugin development. I am working with the builders and markers and I have implemented a rename participant where it checks for a valid file name (does not contain any special characters, lets assume a valid file name to be a alpha numeric regular expression). Its working fine when the user is working within the workbench. Say, when a user directly goes into the file system and changes the file name. I have implemented the markers for this case too. It will show problem marker for the respective file in the project stating, "Invalid file entered - {filename}"
Is there any possibility to change the action on clicking the respective problem marker in the problems view. Say, if such a rename problem marker comes I want to open the rename resource dialog instead of opening the respective file on clicking the problem in the view. Any help upon that.
Although this does not change the double-click behaviour of the marker, you could provide a Quick Fix for the user as described in the Eclipse marker resolution help, and display the rename resource dialog from within the IMarkerResolutionGenerator you provide.

Multiple cursor markers in Eclipse text editor

I am developing a plug-in for Eclipse. I have to develop a Java text editor which allows several users to write the code at the same time, the same way as in Google Docs. But I came across the following problem: the text editor has to show the cursor position of the other users who are coding in same Java document. In other words, I want to place a marker in the text editor content (see this image that shows what I'm trying to implement).
I've already looked IMarker, but IMarker is placed on the text editor's vertical ruler, which is not what I want. Can I use this class? If not, what other class should I use?
The other idea of mine was to insert a JTable in the text editor, but I couldn't find the way how to do that. Is this a right approach, or I'm wrong?
Stack Overflow Gods, please help me...
Eclipse has two different concepts for managing extra information related to files: markers and annotations. Annotations are related to a single editor instance, and their appearance can be customized with a corresponding extension point; markers are used to store extra information permanently (and additionally an annotation can be set up for that reason).
I think, you need to use annotations, as markers are too heavyweight for a real-time collaboration. For future reference, see the Annotations in the Eclipse Help; and some time ago I have written a blog post that describes an automatic translation (and customization) of markers to annotations.