Scoggle
Since moving to Sublime Text from Intellij for Scala development, I have been trying to find plugins to replace most of what I found useful in Intellij. Being able to easily switch between production and test code was one of those useful features.
I came across the ScalaTest plugin which supported switching between production and test code. It also allowed the execution of tests via JUnit. Junit is an undesirable option because Scala has at least two very popular testing frameworks supported out of the box through SBT: ScalaTest and Specs2. It also interacted with the Scala compiler for which I had no possible use.
All I wanted was a way to switch between production and test code. So I decided to write my own plugin which did that one very specific thing.
Starting out my goals were:
- Toggling from a production file will bring up a list of matching test files based on configured suffixes. Eg. Spec, Test, Suite, IntSpec etc.
- Toggling from a test file will bring the matching source files. I was not sure whether to show a list of possibly matching source files.
- Provide a way to match on package-path on either production or test source directories.
- Provide a way to match on file name irrespective of package-path.
- Maybe a have a nice way to create production or test sources if they don’t exist. Maybe run a file template.
- Have a way to override configuration of source and test source directories on a per project basis.
I am happy to say that I have completed most of the above list. The most notable exception being #5. I also figured out that I didn’t need #3 as my matchers handled all variations quite quickly. If needed I could write a matcher that did #3 quite easily.
Overriding configuration on a per project basis (#6), proved to be very useful. Many projects still follow non-standard setups and this feature allows the plugin to support them. A simple example is any Play project.
Some of the other neat features provided by Scoggle are:
- Easily configurable production and test source directories as well as test suffixes.
- Three built-in matchers that match increasingly fuzzier searches.
- Error notifications can be turned down if they become too noisy. Currently supported techniques are through a dialog (default), through the status bar or not displayed at all.
- Debug logging can be enabled which allows the user to easily follow how a match is done against a source file and the files that were consider but rejected when coming to a final result.
- Support for the Context Menus and the Command Palette (CMD + SHIFT + P).
- Installation through Package Control.
- An easy framework to write your matchers which abstracts away the complexities and requires only two boolean functions.
I found it very interesting writing this plugin. There is something cool about writing your own tools. Give it a whirl and let me know what you think.