QuBiT / cucumber-netbeans-plugin

Plugin / Module which allow Syntax Highlighting and many more in NetBeans with .feature Files
MIT License
50 stars 19 forks source link

feature request: Code Templates for gherkin #21

Closed jorahood closed 14 years ago

jorahood commented 14 years ago

My fingers are tired of typing "Then show me the page", do you know if and how to add gherkin as an available language for code templates?

QuBiT commented 14 years ago

Hi, as this is too "user specific" I think that I can't help you here. you may know that there is code completion (but only for the keywords, try press ctrl+space in a "blank" line)

I've also such a step "And I see the page" (where I check the response code) but they do not give you very much "value" in my opinion (see a page, show a page, ... what is on the page? is it the login page, is it a redirected page, is it the same page again (validation failed) or was the task successful and did I got redirected to the right page. ...) I integrate those "low level, low value, but helpful steps" into more valueable steps: example:

Then /^I should see that something really trick was going on$/ do
And I see the page
And I should see "tricky stuff completed"
And I should have x objects with tricky enabled
end

If this is not helpful and applicable, then you have to copy/paste your lines which are so hard to write.

Cheers

jorahood commented 14 years ago

First of all, thanks again for the work you've put into this, I find it very useful! I'm sorry I didn't explain what I was asking for very well; just being lazy.

What I was referring to was the ability to define Textmate-style "code snippets" for Cucumber. Netbeans calls these snippets "code templates". You can define sets of code templates for different languages (See Preferences->Editor->Code Templates). What I would like is to be able to define new code templates for the .feature files (written in Gherkin) to allow automating step creation.

E.g., I would like to define a code template with the abbreviation "see", that would expand out to "Then I should see "[]", with the cursor placed inside the quotation marks for me to enter the text I'm looking for. This seems to me like a handy and generally useful feature to save repetitive typing. Do you see what I mean?

Thanks, Andy

QuBiT commented 14 years ago

Hi, I understood what you wanted, but initially I didn't had a clue on how to do it, so I tried to convince you to not need it :) BUT ...

I've started right after you've written back to search the web, found many tutorials, each describing something different and each should work in combination with the other one ... tried to copy that all into my module ... installed, reloaded, debugged, retried again ... and nothing worked for the feature files.

5mins before 8pm I was close to be frustrated and to postpone it until there is a tutorial which really work, since I've my time not stolen from somebody else, I found "THE" solution.

"EUREKA!" I managed to find http://platform.netbeans.org/tutorials/nbm-code-template.html which describes what you and I want and now I am implementing all those snippets I find useful.

Just one REMARK: It will be not possible to define custom snippets, as the tutorial lacks the information on how to define a new language in the tools -> options -> editor -> code templates menu (yes the whole bunch of frustration was based on this outcome, that seems to be more than complicated to create this entry, please proof me wrong)

So stay tuned ^^ a new version is coming very very soon. I will create a list in the wiki for supported code templates/snippets and will accept useful requests for codetemplates.

Cheers, Roland

QuBiT commented 14 years ago

It is done.

Check the download section for the new Version 1.3.2

Read the Wiki page about "Snippets / CodeTemplates" http://wiki.github.com/QuBiT/cucumber-netbeans-plugin/snippets-codetemplates to get started.

Have now more fun coding and tell me if you like it or what you want to change and if everything is correct.

Cheers, Roland

QuBiT commented 14 years ago

Since Version 1.4.0 you can add/remove/change code templates as expected, read the wiki for more.

jorahood commented 14 years ago

Well this gets a big WOOHOO from me! WOOHOO! Thanks a lot for the time you put into this QuBiT!

QuBiT commented 14 years ago

You're welcome. ^^ Hope more people will enjoy this new module and cherish the work. ;-) Cheers

jorahood commented 14 years ago

I've started working on a few snippets that take advantage of the ability to position the cursor in spots within the snippet to fill in parameters. E.g: Abbr. Expansion ss * I should see "${1 default="text"}" ssw * I should see "${1 default="text"}" within "${2 default="scope"}"

The ability to insert points where you can fill in parameters make the snippets much more useful I think.

QuBiT commented 14 years ago

of course, I just had not the time to go into that topic, but I'll add this functionality to V.1.4.1 tomorrow.

heisee commented 14 years ago

Also a BIG WOOOHOOOO from me :-) I use your plugin regularly and am really happy with it. Thank you for this great plugin!

QuBiT commented 14 years ago

version 1.5.0 is ready to download (yes 1.5.0 ... as there are now 23 languages inside)