I am using dynamic MenuContribution
and get a warning that two of my referenced identifiers "cannot be found". Even though the contribution works. These warnings bug me.
I have a CompoundContributionItem
implementation defined in one of my plugins. Basically it looks like this:
public class ViewerHistoryMenuItems extends CompoundContributionItem
implements IExecutableExtension {
private static final String PARAM_TYPE = "type";
private static final String PARAM_COMMAND = "command";
// some fields
public void setInitializationData(final IConfigurationElement config,
final String propertyName, final Object data) {
/* set fields */
}
protected final IContributionItem[] getContributionItems() {
/* create Items */
}
}
In other plugins I use this ContributionItem
implementation by declaring the following:
<menuContribution locationURI="menu:mylocationUri">
<dynamic id="myId">
<class class="ViewerHistoryMenuItems">
<parameter
name="type"
value="someValue">
</parameter>
<parameter
name="command"
value="someCommandId">
</parameter>
</class>
</dynamic>
<command
commandId="someCommandId"
icon="anIcon.png">
</command>
</menuContribution>
When looking at the Problems-View I get two entries there (for each plug-in, which uses this contribution):
**Referenced identifier 'type' in attribute 'name' cannot be found**
**Referenced identifier 'command' in attribute 'name' cannot be found**
What am I missing here? Any ideas, why I get this warning?
PS: It doesn't help, to make the two fields PARAM_TYPE
& PARAM_COMMAND
public
I do not think this is related to the presence of internal fields within a class.
If you look at a similar error (not the same since it includes
annotationType
), the correction involved the definition of said Referenced identifier:Fixed with:
Considering the extension point
org.eclipse.ui.menus
help page:You need to reference in the name attribute an id present somewhere else in your
plugin.xml
.Sure thing, VonC. Here we go:
Within the dynamic declaration (see above) there are two parameter references
These two parameter are meant to be passed to the command itself. The command declaration is within the same plugin.xml but wasn't declaring these two commandParameters.
What I did was adding these missing commandParameters, resolving the missing reference, which was clearly stated by the warning.
So, you were absolutely right by saying "the correction involved the definition of said reference identifier". The question just was where and what I had to define. I think, I wasn't thinking about the most obvious in this case.