Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Question about markers
Question about markers [message #1067846] Wed, 10 July 2013 16:22 Go to next message
Kevin Regan is currently offline Kevin Regan
Messages: 33
Registered: May 2013
Member
Hi, I am creating some custom markers within the Java Editor that involve highlighting certain things. I have noticed that if I go into the editor and modify the highlighted text (i.e. click in the middle of the text and type some stuff) the highlighting moves/extends as if it is automatically updating - it does not work if you add characters before or after the highlighted text.

However, if I look at the marker object (I'm doing this in compilation participant reconcile function) I see that the start and end attributes are still set to the original values. I can use a markerUpdater extension to correct the start end properties but these updaters appear to only get fired when you save the resource.

Is there a way I can adjust my markers during reconcile similar to how it would be done via the markerUpdater extension?
Re: Question about markers [message #1069407 is a reply to message #1067846] Mon, 15 July 2013 16:41 Go to previous message
Kevin Regan is currently offline Kevin Regan
Messages: 33
Registered: May 2013
Member
Basically, what I am trying to do is load some Java code from an external tool during a startup plugin. I programmatically create a Java project and put the code into the project. During this phase, I replace variables in the code e.g.:

public class {{^className^}} {


with their values e.g.:

public class MyClass {


During this replacement I also define a marker on that location (MyClass) - when you hover over it you can see the parameter name (className). I also have a custom view that stores the parameters and their values. I wanted to be able to update the view value and then, during reconcile, replace the value in the Java code with the value entered.

The problems are:
1) If someone modifies the source code (whether modifying the marked location or not) the reconcile phase does not have updated start/end positions for the marker despite the marker appearing to "move with the edits" visually in the editor
2) I can update the marker position using the markerUpdaters extension point but this only gets triggered on save of the file.
3) Assuming it's ok to defer the updates to the save event, the marker updaters extension fires before the compilation participant so I can then rely on the marker posistions in the build functions in the compilation participant (as opposed to the reconcile function) - however, when I try to replace the values in the source code with the values in the view (if they changed) using TextEdit's against the compilation unit, which moves the code around potentially, the marker positions become invalid again. For example:

public class MyClass { 
   public MyClass() { 
      // construct
   }
}


Assuming both "MyClass" (including constructor fucntion name) were markers and I changed the value of the "className" variable in my view to e.g. X I could identify my first Marker and appropriately replace it with a DeleteEdit (to delete MyClass) and an InsertEdit (to put X in there) - at this point, the second marker location (the constructor function name) will be inaccurate because the text moved around but the Marker start/end positions did not update. At that point I cannot reliably update the second marker value to X.


Basically, it seems that I cannot rely on the Marker objects to locate the section of code that represents these parameters so that I can replace the values as they are updated in the view. In general, this concept doesn't seem to work well considering the users can go modify code at the marker location anyways and the reconciler fixing them would be very strange.

I don't think what I'm trying to do can work - at least not without writing my own custom Java Editor which seems to be a very large undertaking.

[Updated on: Mon, 15 July 2013 16:46]

Report message to a moderator

Previous Topic:WindowDestroyer cannot be resolved to a type
Next Topic:Kepler problem with "unicode" text
Goto Forum:
  


Current Time: Thu Apr 17 03:39:21 EDT 2014

Powered by FUDForum. Page generated in 0.01692 seconds