|
Re: Question about markers [message #1069407 is a reply to message #1067846] |
Mon, 15 July 2013 20:41 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Kevin Regan![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=kregan77%40hotmail.com) 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.:
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 20:46] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03290 seconds