The Impaler
The Impaler

Reputation: 48850

Open an XML file in Eclipse at a specific line number

I'm writing an eclipse pluging and I need to open an XML file at a specific line number (where the error is).

I have followed the accepted answer on this question and it actually works... with the undesired side effect of generating resourceChanged() events in my FileSystemChangesListener listener.

Is there a way of jumping to the specific line without producing file changes? These events trigger other executions in the plugin.

I tried adding the TRANSIENT parameter as true to no avail as in:

HashMap<String, Object> map = new HashMap<String, Object>();
map.put(IMarker.LINE_NUMBER, lineNumber);
map.put(IMarker.TRANSIENT, true); // doesn't make any difference.
marker.setAttributes(map);
IDE.openEditor(page, marker);

Still generates the resourceChanged() event.

Upvotes: 0

Views: 104

Answers (1)

greg-449
greg-449

Reputation: 111218

The IFile.createMarker call is generating the resource changed event, you can't prevent this.

However you can identify that this is a create marker event in the IResourceData you receive - the getFlags() method will have the IResourceData.MARKERS flag set.

Note that resource deltas can be merged so there may be several flags set - for example if IResourceDelta.CONTENT is set the file's contents have also changed.

Upvotes: 1

Related Questions