Eclipse shortcut - generate some a method from some code - eclipse

is there a shortcut to generate a method, when selecting a piece of code in my program? Sth like encapsule code or sth like that. Does that exist in eclipse? I cannot find anything in the help section.
I really appreciate your answer!

In order to move a code part to a method you have to do the following:
select the code which should be extracted
Right click and select: Refactor -> Extract Method
in the option window: enter a method name and click OK

Related

Get func placeholder values from a snippet to appear after hitting tab at top level code level

New to swift and xcode, version 11.3.1.
If I hit func<tab> in a class, the placeholder values pop in nicely and I can tab through them to complete them.
However, when I have a simple playground file open and hit func<tab> I don't see any placeholder values. Just the keyword func appears.
How do I turn on these placeholder values for top-level functions?
What you are talking about are "code snippets". You can insert them not only by typing the "magic word", but also by clicking on the plus sign on the top right, then choosing from the list:
If you search for "Function", you can find the one you're looking for.
But who wants to click a button when writing code, right? It seems like some of the snippets somehow can't be used in playgrounds, while others can. This seems like an Xcode bug. For me, things like var, varget, vargetset all worked.
As an workaround, you can create your own code snippet for a function. First, paste this code into Xcode:
func <#name#>(<#parameters#>) -> <#return type#> {
<#function body#>
}
Select all of it, then go to Editor -> Create Code Snippet. Give it a name, and most importantly, a "Completion".
Apparently, you can still put func as the "Completion" and it will work.
I'm not sure if there is a better answer but here is what worked to get the func snippet to show up while editing a "playground" file:
1) Edit snippets file with: sudo vim /Applications/Xcode.app/Contents/PlugIns/IDESourceEditor.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
2) Search for snippet and find the related scope key and modify the array of the scope key to <string>All</string>:
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
Yes, I could create my own snippet which is the same as the built-in snippet but then I have two different snippets that do the same thing, which I found annoying.

Is there a way to fire an event on the last select element in cofeescript

I work on a project which uses coffeescript, I have to generate a select element (combobox) dynamically, I generate it. But I want to fire an event on the last select element, but it doesn't work, I wrote like this.
$("select:last").change ->
But it fires the event only when I change the first select element.
Have you tried using the on event?
$('select:last').on 'chnage', ->
For those who have the same problem, you can do like this $(document.body).on 'change', 'select:last', ->
The code you wrote looks correct. Is the body of the method indented properly? It should be one tab further to the right than the line you posted.
I would try making some of the syntax more explicit to rule out weird issues related to tabbing:
$("select:last").change{ () -> }

Surround selection with method call

Often when I'm writing code I forget to surround a section of code with a method. For example, when printing an array, I realize that I forgot to pass the array into Arrays.toString().
String[] foo(){
return new String[3];
}
main() {
System.out.println(foo());
}
Is there a way in Eclipse that I can select foo() and then use auto complete or something to surround it with Arrays.toString()? So I want to end up with this:
main() {
System.out.println(Arrays.toString(foo()));
}
I know I could use templates, but I would have to make a template for each method I want to use. I'm looking for something like Eclipse's auto complete feature, which knows about every class and method in the build path.
Yes, you could use templates for that:
First, experiment with existing templates:
Go to the source editor and select "foo()".
Open the view General > Templates.
Select some template, for example, Java > toArray and see how it works.
Then, add your own template:
Windows > Preferences > Java > Editor > Templates > New.
I think the right context should be "Java".
Another way of accesing templates is through the content assist: In the source code, in a new line, start typing the first letters of your template, then press [CTRL][SPACE]. A selector will appear with the matching templates. You may find it useful to check the checkbox "Automatically inserted" in the template definition window.
And yet another way to access them is to select a line of code and then Context Menu > Surround With.
A quick way:
Double click or use select enclosing element and its cousins to select the expression you wish to wrap. ctrl-x to temporarily cut it. Type a few characters and ctrl-space to insert your method name and parentheses. Finally, ctrl-v to paste what you just cut.
with templates - under Java Statements: ${method}(${word_selection})${cursor}
You can make a template like the one described by #LittleSanti. If you use a fake template variable for the method name (like ${method} or ${name}) instead of a constant like foo, Eclipse will highlight it and let you paste or type or complete over it. Then when you hit return or tab, it will jump the cursor to the end (the position indicated by ${cursor}
Unfortunately I don't think Eclipse provides a "real" template variable for selecting methods in scope. It would be nice if it would let did completion for you on methods.

How to read from an already existing dropdown list and click on OK button using autohotkey?

ControlGet List,List,,DropDownList, Installer Language,English
Control,Choose,1,ComboBox,DropDown
This is the snippet which I am using to read from the dropdownlist and it is not working. Please tell me what is the right snippet to be use here.
Thanks
I'm not sure what you are trying here. This code is something similar to what you require...
Gui, Add, DDL, %chooseMonth% vMonthSelected,January||February|March|April|May|June|July|August|September|October|November|December
It allows you to select Month from the drop down list and stores the selected value in variable chooseMonth

Eclipse PDT: show every call of function

Is there an option in Eclipse PDT to show every call of chosen function.
I now if you select some kind of function and hit F3 key you will see a definition of selected function.
Open the Search Menu, Choose 'Search...', and navigate to the PHP tab, then
Enter the method name in the search string text box;
Select Method in the Search for group;
Select References in the Limit to group.
Find method usages http://img217.imageshack.us/img217/83/eclipsepdtfindmethodusa.png
We have a plugin for that... nWire for PHP. It's a comprehensive PHP code analyzer which represents all your code associations, invocations included in one quick and easy to use view. It can also represent the associations graphically.