Temporarily inlay text in Eclipse CEditor - eclipse

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.

Related

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

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.

Eclipse show number of lines and/or file size

Is there a way for Eclipse to show the total number of lines in the currently open file, and/or the file size in kilobytes, at the bottom of the screen near the current line/column display?
Is there is a plugin that changes e.g. 77 : 70 to something like 77(450) : 70?
I don't know of a plugin that does this but you can create your own which adds a control item to a toolbar.
In the control's class you can extend ControlContribution and then you can create a label with any text you want. Look here for a similar example. You could create a toolbar which shows any information you want about the currently opened file.
You can try this plugin. Along with file details the selected text will automatically copied to the clipboard check this Eclipse: selection autocopy to clipboard.

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.

In an eclipse plugin: How can I programmatically highlight lines of codes in the java editor?

I am trying to develop an eclipse plugin that does some documentation check on java code and highlights some lines of code in the editor.
To achieve my goal, I DON'T want to create a new editor in eclipse, I simply want to extend the default java editor to draw a line under (or highlight) the methods that do not satisfy some set of predetermined requirements.
Do I need to create a PresentationReconciler? If yes, how do I make the JDT or workbench use my reconciler.
I have never done plugin development and this is my first attempt.
Several starting points for you:
Annotations are an UI feature of JFace's text editor that allows you to visually mark some places in an open editor.
Markers are a Workbench feature, more high-level. They are generic "objects that may be associated with Workbench resources", and they can display in several places: in text editors (as annotations) or in the Problems view, for example.
Depending on what you want to do, you would plug in your plug-in into extension points related to either of those.
The Eclipse Java editor is located in the org.eclipse.jdt.internal.ui.javaeditor.JavaEditor package.
The "internal" in the package name means that the Eclipse development team can change how the Java editor works with new revisions.
Try this help page: Juno Help on syntax highlighting
At the end of the page, it describes how to dynamically add a PresentationReconciler, which is used for syntax highlighting. See if that fits the problem that you want to solve.
I assume you already have a plugin project.
In your plugin.xml, open the tab Extensions, click Add..., search for org.eclipse.ui.editors, then you should see a template named Editor, which will produce a simple xml editor to experiment and play with. Also, you will be able to see the needed structure to define a custom editor.
Hope this helps...
I don't know if you still have a need for this, but you are going to want to use Annotations to keep track of what parts of the editor you need to highlight.
For actually doing the graphical effect of highlighting, you could do syntax highlighting via a PresentationReconciler, but I have no experience with that.
We used a technique we borrowed from http://editbox.sourceforge.net/, replacing the background image of the editor Shell. Its open source, so check it out. (Our code might also help -- its at https://github.com/IDE4edu/EclipseEditorOverlay )

MarkerResolution not shown when invoked with quickassist shortcut

I'm working on an eclipse plugin where i've created a custom resource marker together with a markerResolution to added quickfixes to XML files. So far everything is working, except that the quickFix only shows in the Problem view of eclipse. The quickassist popup which is opend using Ctrl+1 in the XML file itself does not show the quickfix.
The marker definition can be found here, the markerResolution is this one.
Is there any additional extension point i need to implement to make the quickFix show up in the shortcut popup?
I think i found the solution. One needs to implement an editorConfiguration for the XML editor with a provisionalConfiguration.
In this class you parse the AnnotationModel and check for your marker. If the marker is found, you return an ICompletionProposal