-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Therapi Discovery in ImageJ Ops2 #49
Conversation
d963982
to
80d0e2c
Compare
80d0e2c
to
367d716
Compare
367d716
to
d9909fd
Compare
Using perl commands: To get basic (type, name) plugins with some javadoc before perl -0777 -i -pe 's/ \*\/\s*\@plugin\(\s*type\s*=\s*([^\.]*)[^n]*name\s*=\s*"\s*([^"]*)"\s*\)/ * \@implNote \L\1\E names="\2"\n *\//igs' **/*.java To get basic (type, name, priority) plugins with some javadoc before perl -0777 -i -pe 's/ \*\/\s*\@plugin\(\s*type\s*=\s*([^\.]*)[^n]*name\s*=\s*"\s*([^"]*)",\s*priority\s*=\s*([^,\s]*)\s*\)/ * \@implNote \L\1\E names="\2", priority="\3"\n *\//igs' **/*.java To get basic (type, name, label, priority) plugins with some javadoc before perl -0777 -i -pe 's/ \*\/\s*\@plugin\(\s*type\s*=\s*([^\.]*)[^n]*name\s*=\s*"\s*([^"]*)",\s*label\s*=\s*"([^"]*)"\s*,\s*priority\s*=\s*([^,\s]*)\s*\)/ * \@implNote \L\1\E names="\2", label="\3", priority="\4"\n *\//igs' **/*.java To get basic (type, name, label) plugins with some javadoc before perl -0777 -i -pe 's/ \*\/\s*\@plugin\(\s*type\s*=\s*([^\.]*)[^n]*name\s*=\s*"\s*([^"]*)",\s*label\s*=\s*"([^"]*)"\s*\)/ * \@implNote \L\1\E names="\2", label="\3"\n *\//igs' **/*.java To get basic (type, name) plugins with no javadoc before perl -0777 -i -pe 's/\@plugin\(\s*type\s*=\s*([^\.]*)[^n]*name\s*=\s*"\s*([^"]*)"\s*\)/\/**\n * \@implNote \L\1\E names="\2"\n *\//igs' **/*.java To get basic (type, name, priority) plugins with no javadoc before perl -0777 -i -pe 's/\@plugin\(\s*type\s*=\s*([^\.]*)[^n]*name\s*=\s*"\s*([^"]*)",\s*priority\s*=\s*([^,\s]*)\s*\)/\/**\n * \@implNote \L\1\E names="\2", priority="\3"\n *\//igs' **/*.java After using these commands, remaining Ops were converted manually We then need to convert the double quotes in the created implNotes into single quotes. We do this with the following commands: perl -0777 -i -pe "s/ \@implnote op names=\"([^\"]*)\"/\@implNote op names='\1'/igs" **/*.java perl -0777 -i -pe "s/\*(\s*)\@implNote op(.*'.*'), priority=\"([^\"]*)\"/\* \@implNote op\2, priority='\3'/igs" **/*.java perl -0777 -i -pe "s/\*(\s*)\@implNote op(.*'.*'), label=\"([^\"]*)\"/\* \@implNote op\2, label='\3'/igs" **/*.java perl -0777 -i -pe "s/\*(\s*)\@implNote op(.*'.*'), priority=\"([^\"]*)\"/\* \@implNote op\2, priority='\3'/igs" **/*.java Again, after running these command, remaining implNotes were fixed Then, we convert the SciJava Priority enums to numbers (as SciJava Discovery Therapi doesn't support Priority (yet)): sed -i -e "s/'Priority.VERY_HIGH'/'10000.'/g" **/*.java sed -i -e "s/'Priority.HIGH'/'100.'/g" **/*.java sed -i -e "s/'Priority.LOW'/'100.'/g" **/*.java
First, the parameters were converted to custom taglets (manually, sob). Then the following perl commands were used to convert OpField annotations into implNotes: perl -0777 -i -pe "s/(\s*)\*\/(\s*)\@OpField\(\s*names\s*=\s*\"([^\"]*)\"\s*,\s*params\s*=\s*\"[^\"]*\"\s*,\s*priority\s*=\s*([^\)]*)\)/\1* \@implNote op names='\3', priority='\4'\1*\/\2\@FlopField/igs" **/*.java perl -0777 -i -pe "s/(\s*)\*\/(\s*)\@OpField\(\s*names\s*=\s*\"([^\"]*)\"\s*,\s*params\s*=\s*\"[^\"]*\"[^\)]*\)/\1* \@implNote op names='\3'\1*\/\2\@FlopField/igs" **/*.java Then I realized I had left my @FlopField indicator string in, yielding the usage of the sed command: sed -i -e '/@FlopField/d' **/*.java Now I continue: perl -0777 -i -pe "s/(\s*)\*\/(\s*)\@OpField\(\s*names\s*=\s*\"([^\"]*)\"[^\)]*\)/\1* \@implNote op names='\3'\1*\//igs" **/*.java Of course, there are some with @SuppressWarnings annotations *sigh* perl -0777 -i -pe "s/(\s*)\*\/(\s*)\@OpField\(\s*names\s*=\s*\"([^\"]*)\"[^\)]*\)/\1* \@implNote op names='\3'\1*\//igs" **/*.java Continuing on: perl -0777 -i -pe "s/([\t ]*)\@OpField\(\s*names\s*=\s*\"([^\"]*)\"\s*,\s*priority\s*=\s*([^\)]*)\s*\)/\1\/**\n\1 * \@implNote op names='\2', priority='\3'\n\1 *\//igs" **/*.java perl -0777 -i -pe "s/([\t ]*)\@OpField\(\s*names\s*=\s*\"([^\"]*)\"[^\)]*\)/\1\/**\n\1 * \@implNote op names='\2'\n\1 *\//igs" **/*.java Finally, we rename the priorities to their decimal value. See last commmit for method
d9909fd
to
a910289
Compare
And fix a couple of warnings. Co-authored-by: Curtis Rueden <[email protected]>
a910289
to
8a62ad7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you for documenting the perl commands used. That could conceivably come in handy later (or at least educate someone on how to do this sort of work).
I squashed your import cleaning commits, and did my own import cleaning pass, since there were still many unused ones left.
I will note that I got some nondeterministic test failures on my system, where ops or their dependencies sometimes could not be matched. I am inclined to blame Eclipse, even though I tried to have the projects closed in Eclipse any time I ran tests from the command line. Anyway, the last couple of rounds of testing built successfully for me, so I'm going to move ahead with this.
This PR follows #48 as the second PR designed to purge SciJava Common 2 from the Incubator projects. It:
@Plugin
definitions as@implNotes
, consistent with the methodology described in Therapi-based Discovery #44.@Plugin
andPriority
import
s from the ImageJ Ops2 module.