Overview
Scrappy is for executing quick scraps of code. Just type in your code (the kind of code you might
type in a message body), and choose one of the execution options. Your code will be
instantly compiled and executed. If you only want to execute a few lines from the scrap, select them
and then choose one of the execution options. The selected lines will be executed.
Features
- Do It - Do It is for executing blocks of code that
end in a statement. Loosely speaking, statements are instructions to the machine (e.g.,
if
statement, while
statements, assignment statements, and method invocation statements. Do It will not result in any output and is useful for firing
off code where printed output is not produced (e.g., opening frames, starting threads.)
- Print It - Print It is for executing blocks of code that
end in an expression. Loosely speaking, expressions represent values. E.g., literal expressions
like "foo", arithmetic expressions, etc. Method invocations that return values are also expressions. Print It will produce output in the scrap tab. The output is
the result of evaluating the last expression and is either a string value of a primitive or the result
of a toString() invocation.
- Inspect It - Inspect It is for executing blocks of code that
end in an expression. Inspect It will open the expression result in an "inspector" window.
An inspector lets you walk an object graph to see field values. Inspectors can
be open on primitives, arrays, or objects, but are most useful for arrays and objects.
- Tabs - Create multiple tabs to manage independent scraps of code. In IDEA,
these tabs and the text they contain will be persisted with your project.
- Imports - Type your semi-colon delimited imports list in the imports text field.
You can optionally omit the "imports" keyword. Examples: "com.foo.*;com.bar.*" or
"import com.foo.*; import com.bar.*;".
Tips
- The semicolon for the last line in a scrap is optional.
- All features are accessible through hotkeys. See the popup menu for hotkey
assignments.
- Keyboard selection hotkeys are faster than mouse selection. E.g.,
Ctrl+A will instantly select all text on a tab.
Ctrl+Shift+[Left/Right Arrow] will select a word left or right, etc.
- You do not have to select all lines in a tab to execute the scrap - just select
the lines you need.
- Output from scrap execution (e.g., compiler messages, Print It output, and exception
stack traces are already selected. Cut it with Ctrl+X before deselection if
you do not want to keep it around.
- Scrappy is not a unit test tool - use JUnit for that. Scrappy is a code prototyping and
exploration environment. It should be used to experiment with code scraps to quickly
see if they are suitable for your needs, for learning how third-party toolkits behave, etc.
Ideas
- Intellij folks - add an API for the debugger, add an API for Intellisense, add an
API for chromacoding. :)
- Should output be dumped to a separate output area in each tab? That way multiple
scraps could be executed and the results kept around for posterity.
- Should scraps be executable even if there is no selection? The entire tab
could be executed if the selection is empty.
- Any other ideas? Email me at rhett@bytecrafters.com
Change History
- 1.0.1 to 1.1
- Added import capability.
- Added ability to execute an entire tab if no code is selected.
- 1.0 to 1.0.1
- Fixed problem with classpaths on non-Windows platforms.