Say i'm looking at some file, and i'd like to see if there are similar files in a different package. I don't really know what the different files might be called - they were coded by different people, so could well be named differently.
I do know they're probably in a package of roughly the same name - for example, if i'm looking at a file in the com.sandwiches.ham.artisan package, and i think there should be a similar (although, in this case, sadly unrelated) file in the com.sandwiches.avocado.artisan package, what is the fastest way to jump to said package and check it out?
I'm fed up of scrolling through reams of artisan sanwiches, its making me hungry.
Well, no matter what, you are going to have to do some typing. There is a Go-to navigation item for packages, its just not bound to any quick keys. To bind it to a key combination of your choice, do the following:
Eclipse->Preferences, and type in Keys as your filter.
Search for the Go To Package command, click on the Binding entry field, and type whatever keys you want to use for the keybindings (in my screenshot I have it set to Command-Shift-0). Then click OK to save and close the preferences dialog.
After that, typing your chosen key bindings will bring up a package explorer that lets you type in whatever package you want and navigate to it.
From the Breadcrumb (press Alt+Shift+B to open it) it is quite quick to navigate your way through the sandwich menu ehm I meant packages structure...
Ctrl + Shift + R its a good shortcut to find files in every package in your proyects, i use it everytime... hope it help...
Related
I have an android project with a package name like com.example.alexander.app and I want to change this to a name containing only three parts, like com.alexapps.firstapp. However, after searching several sites, I still have no idea how to do that in AndroidStudio (2.1.3).
I found the following answer, which do not fully answer my question:
Answer 1 requires the file R.java which I cannot find
Answer 2 looked very good by using methods in AndroidStudio. Unfortunately, even after cleaning and rebuilding the project, the package name was not changed on my single activity.
Answer 3: I searched for the string, and found more than 1000 hints!! Therefore I have not continued with this solution to replace more than 1000 hits, as this does not sound right. I have only 1 (one!) single activity in this test app...
Answer 4: Very good answer, but only useful if you want to change each of the package name parts (and neither increasing nor decreasing the number of parts in the package name).
So is there a way to remove a part of a package name with AndroidStudio?
The easiest thing to do is right click the folder/package, and refactor.
This however i think is limited to the final folder, and does not remove a hierarchy.
So the solution in this scenario, is to
create a new folder
move all the folders/files into it. (this should initate a refactor on each file)
Rename any references to your activities etc in the manifest to the correct package names (it should have done this for you)
Clean and rebuild (to fix the R file)
I'm working with an old Java project, which uses the naming convention where interface is named MassiveWormholeGenerator and its implementation is named MassiveWormholeGeneratorImpl. Point is that the names are so long that the end of the file name is not visible in Eclipse editor tab. This means that I have to spend time to determine if I'm looking at the interface or implementation. Is there an easy way to keep this information visible constantly?
NamingConventionFlameWars > /dev/null
It seems that Show in Breadcrumb action does just this. It can be found from the editor's popup menu.
Title bar of the eclipse shows the full name of the file selected in editor
As per Joshua Goldberg's comment I interpret that you can copy the entire type hierarchy to clipboard. However I am unable to find the keyboard shortcut to do this, tried searching on bug page.
Right now I select the classes one by one from type hierarchy that implement interface or extend a class, and copy them to text file, but I would guess there is a keyboard shortcut or feature to copy the entire hierarchy or even export it in some format. I just want to minimize the human error while listing all the classes.
Can somebody please point me to the right place. I am working on eclipse Kepler release build 20130614-0229, on Windows 7 64 bit.
Thanks.
EDIT: As per comment from PopoFibo below, there does not seem a way to do this.
I would be under impression, that since the type hierarchy is shown as a tree, and someone parses and fills those data slots. It would be just another extension to export them as XML or text file. Too much wishful thinking.
I was looking for tool on Java that does the same (similar) functionality of "inspect element" of "Google Chrome". Does anyone has information whether this is available and how it can be implemented?
The question refers to cases when you have the Source code and you don't know the inside of it. Thus, the idea is to inspect elements (objects) on UI while running code!
Since you have access to the code you can use the Java Object Inspector.
Just add one line of code at the right place:
Inspector.inspect(objectToInspect);
Inspect Element in Chrome/Firefox and View Source in Safari are there because the internet is open sourced. The HTML code pushed to a user's machine is viewable by them (obviously not the spreadsheets or other static files held on a server.)
Compiled projects don't have this feature for practical reasons.
In many languages it is impossible to "decompile" an object into its source.
If you could go to Microsoft Word and Inspect any element, you could just copy and paste their application without paying.
So no, you cannot take a compiled Java object and click to see its source code.
I remember hearing about a project that did something like that a few years ago. I can't recall the name, but I ran across this while searching for it. https://github.com/cozycode/Swing-Inspector Based on the description, at least. it looks like it might be useful. If I remember what the original project was i'll post a follow up.
for you to find the java code, in the inspect element go to Sources. Look in the picture below. I inspected google and went to Sources this what i found. press on the files. that say js, and the java code will appear.
if you cant see the pic, tell me. or try to download it, and open it on paint.
enter image description here
What is the difference between Ctrl + Shift + R and Ctrl + Shift + T?
Do we have a blog with all eclipse tips/shortcuts?
Ctrl-Shift-R: Find a resource, which can include XML files, Ant scripts etc.
Ctrl-Shift-T: Find a type, regardless of the filename. (This can be handy if you're looking for a nested type, or basically if you don't want to see anything other than types...)
For Eclipse shortcuts, there are lots of Eclipse keyboard cheat sheets. From the search, I like this PDF, this shorter list, and this list with more explanations.
Ctrl+shift+R is for Open Resource, it
searches for all types of files in
your projects.
Ctrl+shift+T is for
Open Type, it looks for Java classes
and interfaces.
A great feature of the Open Type dialog is that you can search for say DataInputStream by typing DIS.
T : open a type (Java artifact)
R : open any file (any resource)
Ctrl-Shift-T will find Java types including those imported in JAR files without source (e.g. Java standard API)
Ctrl-Shift-R will only find Java types present as source code, but will also find other kinds of source files such as Text and XML.
To see all key bindings look under Window -> Preferences -> General -> Keys.
Also, Ctrl+Shift+L will show you which keyboard shortcuts are active right then.
Blatant advertising coming up:
If you like these two search options, you would love nWire. It is an Eclipse plugin for Java developers which provides, among other things, much stronger search. You get to search as you type for methods, fields, packages... practically everything you have in Java.
As for some more tips, I have written the following article in EclipseZone. I really suggest adding EclipseZone to your RSS feeds reading list. Lots of tips and good stuff there.