Commit c677ea1
committed
ScriptInfo: try harder when converting types
If we cannot convert directly from source to target type,
try converting through String before giving up.
With this change, the following now works as desired:
// @string(visibility=MESSAGE) text
The reason this change fixes the above is that the expression
"visibility=MESSAGE" evaluates to the map:
visibility -> new org.scijava.sjep.eval.Unresolved("MESSAGE")
That is, the variable "visibility" contains an object of type
org.scijava.sjep.eval.Unresolved, with a token value of "MESSAGE".
We cannot convert from an org.scijava.sjep.eval.Unresolved to an
org.scijava.ItemVisibility, but we _can_ convert from Unresolved to
String (the toString() method is called, resulting in "MESSAGE"),
followed by String to ItemVisibility (the string value is
considered to be naming one of the enumeration's values).
This heuristic avoids an explicit assumption in the scripting
framework of the ParseService being backed by SJEP (it might not
be -- someone might be using their own higher priority ParseService).1 parent b700de6 commit c677ea1
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
454 | 460 | | |
455 | 461 | | |
456 | 462 | | |
| |||
0 commit comments