Using marker interfaces in android studio / IntelliJ IDEA - java

I am trying to manage relatively large projects in Android Studio and IntelliJ IDEA. I want to use a marker interface to indicate a class that is unfinished in some way.
public interface ToDo {
}
The trouble is that when I click the "has implementations" icon, I get a list of all subclasses of classes that include the words implements ToDo, including anonymous ones (as I should). Is it possible to do a search so that I only get a list of classes where the words implements ToDo actually appear? If not, is there an alternative way to do it?

Alternative way for intellij & Android Studio
From the app menu, Edit > Find > Find in Path (quick tip the keyboard shortcut will be listed next to the menu option)
type in " implements ToDo" in text to find
For Scope, Select Custom "Project Files" (this will help you avoid some generated classes coming up in your search results)
For File name filter, check the checkbox for "File masks" and type in "*.java" in the textbox next to it.
Click "find".

"Find in path" on the project folder will do the work.

Related

How to make Spring/Eclipse IntelliSense autocomplete like in Visual Studio?

I am a .net developer and from last year I started learning Java. But something make me sad, and that is the Java autocomplete IntelliSense. After I choose something from IntelliSense, a method name for example, it put the method name with the default parameter as well. I don't want that!!! I want to work like in Visual Studio, just to put there the name and that's it because usually when I do that I already copy paste a line from above and I want to change only the class method name...
How to change how this autocomplete works?
I attached a photo after I choose a method from that object, but that line was copied from above before choosing.
Do one of the following:
Press Ctrl while selecting a code completion proposal
Configure overwrite instead of insert code completion behavior as default:
In Window > Preferences: Java > Editor > Content Assist in the first section choose Completion overwrites
Your question was already asked here. Basically the gist of it:
Eclipse already has its own sort of Intellisense that only gets triggered by a "." by default. You can change the settings under:
Window -> Preferences -> Java/Editor/Content Assist
A problem, if you want the Intellisense to be always active. The "fix" would be to always use "ctrl"+"space" to open the Intellisense GUI. (Or, even better, to add every letter and character to the Intellisense triggers under: Window -> Preferences -> Java/Editor/Content Assist)

The code behind filesystem.normalize

I'm new to Java and OOP. I have a strange disorder that makes me extremely curious how things work. So I copied this code that use normalize() and I'm trying to get the source code of it but all I found is
public abstract String normalize(String path);
In:
FileSystem.java file
Of course, know what it does. But I'm curious how and why i cant find the code behind it.
Thank you
Michal
If you are using an IDE (like Eclipse), you can use it to find the concrete implementations of that method.
In Eclipse:
Ctrl + Shift + T and type java.io.FileSystem; click "OK"
Hover over the normalize method name. A menu will appear like below.
Click "Open Implementation"
If there is more than one implementation available, you will see a list. Click on the one you want to open.
If there is only one, then that single implementation will be opened automatically.

How to automate adding multiple methods in android studio 1.0?

I am following a tutorial on how to create a flappy bird clone from http://www.kilobolt.com/day-3-understanding-the-libgdx-framework.html
This is where I am at
I know what's going because GScreen is a concrete class, it has to provide implementations of all the methods in the Screen interface.
To do this, I looked up "Add unimplemented methods" feature in the Android Studio
and used the control o shortcut to get to this dialog.
However from this dialog, is there a way of selecting multiple methods that you want stubs for? If I double click one, I just get the stub for that method. Is there a way to get multiple stubs at a time, for efficiency sakes?
You can select multiple methods using the control (Command on a Mac) key or the shift key, then single click. The shift key selects a continuous list of methods, the control key allows non-contiguous selections.
You can right click on the class name in java file. A drop down arrow will come containing an various options like "GENERATE". Click it and select which unimplemented you want to apply it will be automatic generated.

Eclipse Quick Fix or menu option for importing different Java class?

I have written a project that includes a Character class. In this project, in a different package, I have another class that's trying to use it:
for (int i = 0; i < NUM_CHARACTERS; i++) {
Character c = new Character(10);
}
The problem is that Eclipse is automatically trying to use java.lang.Character:
What I would like to do, is find a way either via the contextual menu, keyboard shortcut, Quick Fix menu, etc. to have Eclipse provide me with alternate imports.
The issue is obviously that the class is part of the standard API, otherwise it would certainly ask me which Character class to import. Normally if you've imported the wrong one accidentally, you can just delete it from your import block at the top, and use Quick Fix to pick the right one.
But how, in this case, can I easily tell Eclipse I want to use a different class, without having to manually type the import into the top? I have a number of classes that will be named similarly to the java.lang classes, so I'm looking for a time-saving solution.
Ctrl+Space will give you an option to select the required package.
Just place the cursor at end like Character^ and press Ctrl+Space
where ^ show your cursor position. For example
Date class is present in java.util as well as java.sql, so when you will type
Date^ Ctrl + Space, it will pop-up with all the packages where Date class is present and you can choose your desired import from there.
Another way, Just delete all the auto imports & press Ctrl + Shift + O to organize imports. Eclipse will prompt you for all the place wherever there is any ambiguity in identifying the right package.

How to quickly navigate between Java class method definitions in a large class without the 'Find' dialog in Eclipse?

I use what I think is a typical layout in Eclipse: my workspace contains the Project Explorer on the left and the Java editor window taking up most of the screen, with the small console window at the foot of this editor pane.
When I open a very long Java class, containing a large number of method definitions, in the editor pane, it can take a long time to move between methods. I use CTRL-F to open the Find dialog and then type in the name of the method if I can remember it.
Is there a better way to navigate between method definitions in a large class in Eclipse?
Ctrl+O will open a dialog with the methods (and variables) list. It supports "advanced" :-) searching so you can just type a few letters of the method's name
Use the Outline View.
I use a layout much like yours but I keep the Outline panel open in it beneath the project/package explorer. This makes it easy to see the project's outline as well as the current editor's outline at a glance.
In addition to the Ctrl+O option for a quick outline, one can type (on a Mac) Cmd-Alt-Q then O to focus the Outline view. Once focus is in the Outline view, you can use the arrow keys or letter keys to navigate through the list of methods.
Cmd-Alt-Q is useful for opening many of the views. In my Eclipse Helios right now, a momentary delay after playing the chord presents a quick list of many different views, many of which have their own hot key.
Finally, you can use the "Next/Previous member" chord to jump to the previous or next method definition in the file. Again in my Helios build, the Next member key is Ctrl-Alt-down . Yours may be different.
To find out what the keystrokes are in your Eclipse build, open the eclipse preferences. Use the searcher to search for 'keys'. Open the configuration for Keys . Then in the keys search bar look for "member". There should be an item for "Next member" with a bound shortcut key/chord. Browsing the list of hotkeys is a great way to improve Eclipse productivity in the long run ;)

Categories