- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2
 
2.1.2. Auto completion and static features
One of the benefits of the Bear is that it should the smallest possible amount to learn. You learn Bear by using Bear in your IDE which should guide you through the API. If something is unclear in Bear, feel free to create an issue or ask a question at Stackoverflow.com.
In this mini-tutorial we will show you how to easily type this cryptic method definition:
@Method
def ls(){
    run([named("ls task", { _,  task ->
        println _.sys.lsQuick(".")
    } as TaskCallable)])
}- Start typing a method name. To get a list of method suggestions for your project, press 
Ctrl+Spaceand find the methodrun()which should be at the top of a list: 

- A tooltip enlisting 
run()parameters will pop up. In case it does not or it disappears, pressCtrl+Pto bring it back.run()accepts a list ofTaskCallable, so continue typing to declare it with Groovy syntax[element1, element2]. Typenew Nameto create a new instance of a named callable and pressCtrl+Spaceto auto-complete: 

- Press 
Ctrl+Pto display the parameters. First is the name for the callable. Second is a closure containing code to run. In Java 6 closures are normally implemented as anonymous class instances, i.e. instances ofRunnableorCallable, and Groovy has syntax sugar for this which we will use. Now we will create an anonymous inner class with help of IDE and then convert it to a closure. If you are familiar with Groovy closure syntax, you can use it right away. 
Enter the task name and start typing new , hit Ctrl+Shift+Space. Then choose TaskCallable and it will create an anonymous class stub:

- Place cursor at 
TaskCallabledeclaration, hitAlt-Enterand choose 'Change to dynamic': 

My version of Idea has a glitch and does not add as TaskCallable at the end of the closure, so you will need to add it manually.
- Dynamic Groovy does not require specifying a type in a variable declaration and Idea is able to infer the dynamic types so you can types from the declaration:
 

- Use 
_(similar to$in jQuery, Groovy just lacks this symbol) to accesssysobject which is used to run remote commands: 

- Change the constructor to a template method named(...). For the majority of the constructors there are static equivalents - it gives a concise notation and allows to customize object creation when it is required in future.
 
After you do this the too pieces of code should look identical:

Important: The Tables of Content are generated. Any change will be overridden on the next update.
For more information: GitHub Wikifier