I'm developing a JSP tag that have an attribute that works with a set of possible values.
I don't need to enforce this values, but I would like my IDE (Eclipse) do some code hinting or auto-completion.Suppose a tag like this <mytag:sometag someattribute="value" />
.
The attribute someattribute
can have any value (remember, I don't need to enforce), but I would like it to suggest you the following list of values: ValueA
, ValueB
and ValueC
Nitin Dahyabhai at the Eclipse Community Forums suggested writing a plugin based on org.eclipse.wst.xml.core.modelQueryExtensions
or create templates with the values.
The problem with tem开发者_如何转开发plates is that I have hundreds of possible values and I have multiple tags.
The problem with writing a plugin is that I haven't time or knowledge to do it.Is there another way to do it?
In case you end up with writing Eclipse extension for modelQueryExtensions, that should be as simple as:
Create new plug-in: com.my.taglib
, and add to its plugin.xml
:
<extension point="org.eclipse.wst.xml.core.modelQueryExtensions">
<modelQueryExtension
class="com.my.taglib.MyTaglibModelQueryExtension"
contentType="org.eclipse.wst.html.core.htmlsource">
</modelQueryExtension>
</extension>
Then implement com.my.taglib.MyTaglibModelQueryExtension
class:
public class MyTaglibModelQueryExtension extends ModelQueryExtension {
public String[] getAttributeValues(Element e, String namespace, String name) {
// See XSDModelQueryExtension for an example implementation of this...
}
}
精彩评论