I've had some problems with searching in Xcode, what is the best way to find and locate a method or class within a certain project?
command-shift-O will bring up the "open quickly" box, which searches textually and symbolically.
Press ⇧+⌘+O to open the 'Open Quickly...' dialogue window.
From there you can type any symbol name or filename to quickly zoom around your project.
Unfortunately, it doesn't do wildcard or partial searching (much to my frustration) so you need to know the name (or at least the beginning of the name) for it to be much use.
You can use it to open system symbols or headers too, eg, just type UITableView to view the header for it.
If you know the name of the method or class, a really easy way is to type it in whatever document you are in, then hold command and double-click the text. XCode will jump directly to the definition of whatever you double-clicked (even if it is not part of the project).
Project Find with the type of search set to definitions works well.
If you are trying to find the definition of a class from where it's being used, you can right click over the class name and select "Go to definition"
This will take you to where the class/function is defined
Alternatively there's "Find in project"
Pressing ⇧+⌘+F will open up Project Find. Type in what you want to find, and then in the drop-down next to it select "In Project" and press "find."
Voila! It should group the results by file for you.
Look on the left bar, you have a smart folder called "Project Symbols." When you click on it, it will display all the symbols (eg. classes, methods, properties) available in your project. You can even search in this folder by entering a term in the box in the upper right corner.
Related
I have the same set of files in N folders, one of them, say, blank.xhtml. The files contain somewhat similar information and it is becoming overwhelming to figure out which file comes from which folder every time I switch between the tabs. When I open one of them to edit and happen to open a file with the same name from another folder I get confused and more often than not end up editing the wrong file: nullifying my hard work. So I am wondering if there is a way to show the name of a containing folder in the tab like this G-06/blank.xhtml or G-07/blank.xhtml. I will be very very thankful to anybody who has pointers to how I can make this happen.
As an addition to the Maroun's answer there is an alternative solution.
It's not exactly what you want (full name in the tab's title), but may be useful sometimes.
In the "Project Explore" view (the same goes to "Navigator" view) click the "Link with Editor" button. That way, whenever you choose some file opened in the editor, it will be automatically selected/highlighted (see the picture) in the "Project Explorer" view.
Here is the picture:
Maybe this will be useful to you too.
If you hover the mouse over the tab containing the file name then a popup appears showing the full path. Not exactly what you wanted, but it should help. (This with Eclipse Neon.3 Release 4.6.3 on a Mac).
Not quite what you're looking for, but ctrl+shft+e will open the switch editor window that shows all the open editors with their filepaths. I use this shortcut for the same reason. I'll have multiple build.gradle files open from multiple projects and this helps pick the correct one
Is there a straightforward way to find references in my code to a class in an external library (jar without source) if I don't already have a file open that has a reference to the class?
For instance, say I want to find all references in my code to System.out.println() but I don't already have code open that uses println. How can I do this?
You can open any type (class or interface) via Ctrl+Shift+T (Command+Shift+T on a Mac). When the class/interface source opens, select a method or field (instance variable) in that class, right-click, and choose References.
If you don't have the source code, you'll see the Class File Editor, "Source not found" window. If you don't already have the "link with editor" icon enabled, either enable it or select the Navigate menu, Show In, Package Explorer. Then in the package explorer, select a method or field (instance variable) in that class, right-click, and choose References.
The only way I know to do this is to perform the following (not exactly straightforward) sequence:
Open and edit an existing class by adding a reference to, say, System.out.println()
Organize imports (ctrl-shift-o)
Place the cursor on println and type ctrl-shift-g or search, references, workspace.
Close the class without saving it.
It would be possible to do this using a File Search. Press Ctrl + H and put in System.out.println. Adjust the scope of the search according to your needs (I usually set it to Enclosing Project or Selected Resource).
For one reason or another, I have a few nasty JSON files in my XCode project. When I do searches, they will sometimes get hung up on these files.
Is there a way to prevent XCode4 from indexing certain file types, or files?
Go to the search navigator (⌘+3)
click on the magnifier within the search field
choose "Show Find Options"
click on "Find in", there should be "Workspace"
use "Custom…" and select "Path Extension" "is not equal to" "json"
give it a name e.g. SearchWithoutJson
next time you can enter something in the search field and select your search setting
//EDIT: actually the next search with selecting SearchWithoutJson doesn't work. You still need to display the search options and make sure the right one is selected in "Find in"
Don't include the JSON files in your project at all.
Instead insert a custom build phase that copies these files into the application bundle.
Or maybe you can put all JSON files into one big file, so indexing will be faster.
There is a shortcut in IntelliJ I'm looking equivalent in Eclipse, it is called 'Go to symbol'. CTRL-ALT-SHIFT-N lets you start typing and glob up classes, method names, variable names, etc, from the entire project.
Does someone know if there is such thing in eclipse?
General
For type names, you can use control-shift-t (open type) and enter partial names with globs or by upper letters in the camel-case name (like DTM for DefaultTableModel).
For resources (non java files like xml, properties, etc), you can use control-shift-r
For method and variable names, you'd need to use the Java Search function (the flashlight icon on the toolbar).
In the Java editor
If you're looking for references to a symbol in the editor, click on it and press control-shift-g.
If you're looking for the definition of a symbol in the editor, control-click or click on it and press F3.
If you want to find implementations of a symbol (like an interface or method that may be overridden) in the editor, press control-t on it.
This may be a Flash Builder-only thing, but ctrl+o will do the trick if you're just looking within the class you're in (which I realize is a variant of your specific question but is helpful and similar anyway).
Eclipse allows you to search the project. That's probably the closest to what you're looking for.
You can look at: Navigate > Open From Clipboard.
Shortcut assigned in Neon for this: Ctrl+Shift+V.
"Open element" is the closest I know, as it lets you start typing and glob up classes, method names, variable names, etc. as requested.
The shortcut is Ctrl+Shift+T
Is there any way to remove binary references from "call hierarchy" (Ctrl-Alt-H) ?
Our project setup is such that for many members we have duplicated references (one reference from source file and one from the jar file with class compiled from that source file). The navigation is inconvenient and I wondering if any ways to fix that is available.
Call hierarchy can be limited in scope to a working set. You just need to set one up to exclude all your libraries.
If you click on the white down arrow in the top right of the Call Hierarchy window a popup menu will appear. Choose Search Scope/Working set and then select or set up the working set you want. A working set can include a source folder or a jar. Once set up your working sets will appear at the bottom of the Search Scope menu so you can access them quickly in future.
I've discovered another way to accomplish this, and since this question is one of the top results in google, I thought it would be good to add it as an answer.
In the Call Hierarchy view, one can click the 'View Menu' (the downward facing arrow) and select "Search In...". In the window that pops up, the user can un-check the options they want to exclude. For example, I only have 'Sources' and 'Required projects' checked.