Problem with markers [message #49845] |
Tue, 27 May 2003 14:43 |
Eclipse User |
|
|
|
Originally posted by: gg.decisionsoft.com
I've defined a Marker in my plugin.xml as follows:
<extension
id="XMLValueMarker"
name="XML Value"
point="org.eclipse.core.resources.markers">
<persistent
value="true">
</persistent>
<super
type="org.eclipse.core.resources.bookmark">
</super>
<super
type="org.eclipse.core.resources.textmarker">
</super>
<attribute
name="type">
</attribute>
<attribute
name="start_line">
</attribute>
<attribute
name="end_line">
</attribute>
<attribute
name="xpath">
</attribute>
</extension>
In one class I create a map of attributes and create the marker as follows:
attributes.put("end_line", new Integer(_loc.getLineNumber()));
attributes.put(IMarker.CHAR_END, new Integer(_loc.getColumnNumber()));
MarkerUtilities.createMarker(_resource, attributes, "XMLValueMarker");
In another I try to get the markers I've created:
IMarker[] tmp = file.findMarkers("XMLValueMarker", true, 5);
for(int i = 0; i < tmp.length; ++i) {
System.err.println("Marker found: " + tmp[i].getAttribute("xpath",
"n/a"));
}
The problem is that the call to findMarkers is returning an empty array.
Where have I gone wrong?
Geoff.
|
|
|
|
Re: Problem with markers [message #51001 is a reply to message #49845] |
Wed, 28 May 2003 07:10 |
Eclipse User |
|
|
|
Originally posted by: gg.decisionsoft.com
> Something that you sholud have mind is that the depth argument must
be one
> of the following constants:
>
> IResource.DEPTH_INFINITE
> IResource.DEPTH_ONE
> IResource.DEPTH_ZERO
>
> There is no support for arbitrary depths. Also, for file resources, it
> only makes sense to specify DEPTH_ZERO (since files cannot have
children).
> By the way, is your variable "file" really a file?
>
> Rafael
I changed the code to use IResource.DEPTH_ZERO as below, but I'm still
not getting any markers.
And yes, file is really a file. It is the same object that the markers
were added to.
IMarker[] tmp = file.findMarkers("XMLValueMarker", true,
IResource.DEPTH_ZERO);
for(int i = 0; i < tmp.length; ++i) {
System.err.println("Marker found: " + tmp[i].getAttribute("xpath",
"n/a"));
}
|
|
|
Re: Problem with markers [message #51571 is a reply to message #49845] |
Wed, 28 May 2003 10:48 |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.gmx.net
Geoff,
first of all the ID of your marker is <pluginID>+".XMLValueMarker"
(unless you fully qualify the ID the plug-in ID will be added).
Does the creation of the marker work i.e. no exception?
Is the file/resource really the same?
Try the following code to see whether the marker has been created
somewhere in your workspace:
ResourcesPlugin.getWorkspace().getRoot().findMarkers(<markerID >, true,
IResource.DEPTH_INFINITE);
HTH
Dani
|
|
|
Re: Problem with markers [message #53400 is a reply to message #51571] |
Thu, 29 May 2003 08:05 |
Eclipse User |
|
|
|
Originally posted by: gg.decisionsoft.com
> first of all the ID of your marker is <pluginID>+".XMLValueMarker"
> (unless you fully qualify the ID the plug-in ID will be added).
I've tried with both fully qualified and short and neither seemed to work.
>
> Does the creation of the marker work i.e. no exception?
No exceptions. Not that I can see anyway.
> Is the file/resource really the same?
Yes.
>
> Try the following code to see whether the marker has been created
> somewhere in your workspace:
> ResourcesPlugin.getWorkspace().getRoot().findMarkers(<markerID >, true,
> IResource.DEPTH_INFINITE);
Still no markers.
Geoff.
|
|
|
Re: Problem with markers [message #53427 is a reply to message #53400] |
Thu, 29 May 2003 08:57 |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.gmx.net
Geoff Gibbs wrote:
>> first of all the ID of your marker is <pluginID>+".XMLValueMarker"
>> (unless you fully qualify the ID the plug-in ID will be added).
>
>
> I've tried with both fully qualified and short and neither seemed to
> work.
>
>>
>> Does the creation of the marker work i.e. no exception?
>
>
> No exceptions. Not that I can see anyway.
>
>> Is the file/resource really the same?
>
>
> Yes.
>
>>
>> Try the following code to see whether the marker has been created
>> somewhere in your workspace:
>> ResourcesPlugin.getWorkspace().getRoot().findMarkers(<markerID >,
>> true, IResource.DEPTH_INFINITE);
>
>
> Still no markers.
Put a breakpoint in createMarker and start in debug mode to verify that
the marker is created. Then put a breakpoint in findMarkers to see why
your breakpoint is not found.
HTH
Dani
|
|
|
Re: Problem with markers [message #53451 is a reply to message #53427] |
Thu, 29 May 2003 09:05 |
Eclipse User |
|
|
|
Originally posted by: gg.decisionsoft.com
> Put a breakpoint in createMarker and start in debug mode to verify that
> the marker is created. Then put a breakpoint in findMarkers to see why
> your breakpoint is not found.
How can I tell if the markers have been created?
What object, if any, do they get added to?
If they don't get added to an object how can I view them in the debugger?
Geoff.
|
|
|
Re: Problem with markers [message #53530 is a reply to message #53427] |
Thu, 29 May 2003 10:16 |
Eclipse User |
|
|
|
Originally posted by: gg.decisionsoft.com
>
> Put a breakpoint in createMarker and start in debug mode to verify that
> the marker is created. Then put a breakpoint in findMarkers to see why
> your breakpoint is not found.
OK. The markers are being created.
When using:
findMarkers("com.decisionsoft.xmeta.ui.infoeditor.XMLValueMarker ", true,
IResource.DEPTH_INFINITE);
it goes as deep as the
basicFindMatching in org.eclipse.core.internal.resources.MarkerManager
Within this method it contains the code:
if (includeSubtypes) {
if (cache.isSubtype(marker.getType(), type))
result.add(marker);
} else {
if (marker.getType().equals(type))
result.add(marker);
}
Because I specified to find subtypes, it checks the marker to see if it
is a subtype and fails.
Should this not check the types are equal as well as checking if its a
subtype?
If I use:
findMarkers("com.decisionsoft.xmeta.ui.infoeditor.XMLValueMarker ",
false, IResource.DEPTH_INFINITE);
Then the markers are found.
Geoff.
|
|
|
Re: Problem with markers [message #53585 is a reply to message #53530] |
Thu, 29 May 2003 10:51 |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.gmx.net
Geoff Gibbs wrote:
>
> if (includeSubtypes) {
> if (cache.isSubtype(marker.getType(), type))
> result.add(marker);
> } else {
> if (marker.getType().equals(type))
> result.add(marker);
> }
>
> Because I specified to find subtypes, it checks the marker to see if
> it is a subtype and fails.
> Should this not check the types are equal as well as checking if its a
> subtype?
It does (see IMarker.isSubtypes()). I guess the test fails because of a
typo (the ID in the code does not match to the one in the XML). Step
again into above code and inspect the cache to see which markers it
contains. I assume you will find one similar spelled to yours.
Dani
|
|
|
Re: Problem with markers [message #53968 is a reply to message #53585] |
Thu, 29 May 2003 14:55 |
Eclipse User |
|
|
|
Originally posted by: gg.decisionsoft.com
While debugging I have found that if the plugin manifest lists
<extension
id="com.decisionsoft.xmeta.ui.infoeditor.XMLValueMarker"
name="XML Value"
point="org.eclipse.core.resources.markers">
then the MarkerManager stores a definition of
" com.decisionsoft.xmeta.ui.infoeditor.com.decisionsoft.xmeta. ui.infoeditor.XMLValueMarker "
But if I use id="XMLValueMarker" no definition at all is stored.
The ID is the only thing I change.
Any thoughts?
Geoff.
|
|
|
Re: Problem with markers [message #54071 is a reply to message #53968] |
Thu, 29 May 2003 15:39 |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.gmx.net
Geoff Gibbs wrote:
> While debugging I have found that if the plugin manifest lists
> <extension
> id="com.decisionsoft.xmeta.ui.infoeditor.XMLValueMarker"
> name="XML Value"
> point="org.eclipse.core.resources.markers">
>
> then the MarkerManager stores a definition of
> " com.decisionsoft.xmeta.ui.infoeditor.com.decisionsoft.xmeta. ui.infoeditor.XMLValueMarker "
>
> But if I use id="XMLValueMarker" no definition at all is stored.
> The ID is the only thing I change.
>
> Any thoughts?
Not without seeing your whole plugin.xml. Using unqualified names should
be OK (see other plugin.xmls).
Dani
|
|
|
Powered by
FUDForum. Page generated in 0.04599 seconds