In the new Metadata Tags Settings you can specific which Tags should be available and how strict they should be handled:
For example the Event Metadata Tag has the two required parameters name and type. You can also add your own Metadata Tags.
The Event Metadata Tag appears as auto completion option with its parameters:
For example you could add the following metadata tag:
[ErrorMessage(name=””, severity=””)]
It should mark a class that it could send error messages to a receiver. The parameter name should be limited to a name containing only letters and digits and the severity should only have values like Info,Warning, and Error.
You could achieve this by the following steps:
Add a new Tag (Add Tag).
Click on the name of new appeared tag and enter the name ErrorMessage.
After pressing return the tag list is alphabetically reorder so that the tag ErrorMessage appears below Embed.
Selected the ErrorMessage tag and use Add Parameter to create a new parameter.
Rename the new parameter to name.
The new parameter name should be of type String and its mode should be Required.
Now click on the cell of column Special for parameter name.
Here you can enter a java regular expression describing what kind of names are allowed. For more details about java regular expressions see:
http://www.vogella.com/tutorials/JavaRegularExpressions/article.html
http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
For identifiers without underscore the pattern [A-Za-z0-9]+ should be adequate so we use it for the name parameter.
The second parameter severity can be added the same way.
The type of parameter severity is String, too.
The pattern for value of parameter severity should be: Info|Warning|Error
We can assume that the severity parameter is by default Error so we can leave the parameter optional.
Since the ErrorMessage tag should not contain any other parameter and requires at least the name we switch it to Strict.
In the lower area examples of how to use the metadata tag are shown and which checks are applied.
Confirm your changes with Apply
Metadata Tags Settings can be set for each project inside project properties, too:
These settings are stored inside the project settings folder as com.powerflasher.fdt.core.metaDataTags.prefs
Using Self-Defined Metadata Tags
Here is an example how you could use the auto completion for the new example metadata tag ErrorMessage as created above:
The default value for the parameters is the first possibility of the top most or-pattern if it is a simple constant.
The auto completion for the severity value offers all three values since they are simple constants appearing in the top most or-pattern of regular expression for parameter severity:
The severity-parameter contains a not matching value and so an error is shown:
Comments