Completion and Inspection in the editor
While we're here, a brief plug for a feature of the text editor — 'print' on demand. This happens a lot: you start typing a complex expression something.somethingelse.this.that. and then you think, wait a minute, where am I? Or something + somethingElse provokes the question, just what is the current value of somethingElse ?
Field offers a few of places to find the answer and help you figure out what needs to be typed next — where you are and where you are going. One is auto-completion:
-period. This can be used in lots of places to tell you not just what you might want to "type next" but some things concerning the value of what you have on the left-hand side of the cursor, for example:
-period is related to
-option-period which provides autocomplete that ignores Java's access modifiers (so you can see non-public methods and fields).
You have to be careful that you ask the completion system the right question — it's attempting to work out what you will type next, so it needs to be able to guess what you want based on what you have already typed. Typing PL and asking for completion will offer PLine, the line geometry object (and maybe a few other things, any variables and packages that you have that start with PL). Typing PLine and asking for completion will yield only the constructor for PLine. To see 'inside' PLine, you need to have either PLine. (note the period), PLine() or a variable that is a PLine. Likewise _sel will provoke _self but only _self. will give you the documentation and completion 'inside' _self.
In use
We've spent quite a bit of time both using this autocompletion and refining it's interface. It tries to offer as much information as it can:
Note the parameter names (created by parsing the source code) and the values of simple primitives fields that are always "safe" to evaluate. The grayed out lines are protected & private variables (which Python can access, but are worth indicating in a different weight). These only appear if you are holding down option.
What isn't clear from the screenshot is that you can keep typing while you have this menu up and it will refine itself to include only results that start with what you have written. Backspace, enter (to accept the proposed completion), escape (to forget about the whole thing) and the up and down arrow keys (to choose from the menu without using the mouse) all work as expected. Tapping option shows and hides those 'private' members. Refining your search to the point where only a few options remain will focus the display on the documentation for those things (taken from parsing the JavaDocs? for Java things, or from the documentation comments of Python things) and will, in the case of short Java methods, show you source for the method itself.
Thus together these two things are becoming a way of offering and navigating documentation (see the autocompletion offered for _self. for example).
Printing
A different "series" of keyboard shortcuts starts with
/ . This prints the expression on the left hand side of the cursor. Literally — it's like you cursor-ed back to the start of the line, added a print, executed the line and then deleted everything you wrote and put the cursor back in the old spot.
Further in this vein,
⌃/ 'pretty-prints' the expression. It generally does a better job of formatting lists and showing you what they contain, for example, than Python's built in (and fixed) print. Also, unlike print you can add your own pretty-printers, crafted to whatever objects you are working with, in OutputInserts.addPrintHandler( ...)
Most importantly for our purposes here
⌃/ evaluates and prints generators (up to a certain point, it doesn't try to print a generator that never terminates).
The Object browser (not available in beta 12)
Finally, for completeness,
-option-/ opens an Object browser on an object:
This browser is a lot like the Finder slide scrolling view combined with the kind of information that you'd normally get in a debugger (the names and values of fields and sub-fields). One thing to note about the contextual-menu shown above, firstly, it presents what autocompletion would tell you about the object, secondly, and more useful, it offers up something that you can insert back into the text editor: the code that you need to write in order to access the object that you write clicked on. In the example above, the code is simple, to access the y element of some vector it's just ".y". But for complex hierarchical structures (with maps and lists) this expression can grow very large, and locating just the right combination of [4] and ["something"] and .somethingElse can take a long time. Once again, Field orients itself towards the problem of interacting with large agglomerations of Java code in as nimble a fashion as possible.


