After a long period of creating apps with Android Studio I returned to Eclipse to program a pure Java application. Of course, I have noticed large differences in terms of auto completion between IntelliJ IDEA and Eclipse but IntelliJ is no alternative for me because of various reasons.
That is why I started to change the settings in Eclipse, inter alia, for the content assist. I want to have suggestions for variable names too, without having to write a dot first. As you can see in this image, I have changed the auto activation triggers to ._#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ as suggested in another thread on Stack Overflow.
The problem is, if I write short variable names like d it completes them automatically to something different (in this case DEFAULT_CURSOR) when I press the dot key. To avoid this, I have to choose the variable first, before pressing the dot key.
However, having to do it this way is a large waste of time. Is there a possibility to use the suggested variables or methods only when I have pressed the enter key, just like in IntelliJ?
Maybe there is an option to bind the dot key to the closing of the content assist?
No, Eclipse and IntelliJ are different and IntelliJ's level of auto completion is unique to itself. If you are comfortable with it, you should use it and then copy and paste to eclipse for windowbuilder. Also FYI there is a free alternative to windowbuilder for IntelliJ, you can read about it here: WindowBuilder equivalent for IntelliJ?
Related
Does IntelliJ have the ability to tab out of auto-completed brackets? As in, when you press "tab" key near a closing bracket, the cursor will jump over it instead of adding a new tab. This is a pretty standard feature in Eclipse. In IntelliJ IDEA you must use arrow keys to do so.
Similar question was asked 4 years ago here, but maybe 4 year isn't enough time to complete this complex feature, so I'm asking again.
UPDATE:
Initial implementation for this feature is available starting from IntelliJ IDEA 2018.2 version. It works more like in MS Visual Studio - without visual indication of tab 'exit' position. For now, it should work in Java, SQL, Python and some other files. It will take some time for other languages to catch up - some language-specific code changes are required. The feature is disabled by default, you can enable it in:
Settings (Preferences on Mac)| Editor | General | Smart Keys | Jump outside closing bracket/quote with Tab.
Original answer:
Nothing new since the original question was submitted, except a third-party plug-in that was started by one of the users.
For some reason the author didn't release a binary version of the plug-in yet.
I went ahead and built the plug-in, you can get the jar file here.
Copy it into the IDE plugins folder, restart IDEA and use Shift+Space.
Keyboard shortcut can be changed in the Keymap settings:
Feature requests and bug reports should go here.
Just type in the closing bracket again, it will get you out of the bracket.
For example if you are typing "Sandeep", as soon as you enter ".. it will be like ""... then you enter rest of the text "sandeep".. and at the end type " again... it will take you out of the double quotes.
I have demonstrated above for double quotes , you can do the same for any brackets.
I have used Eclipse for Java for the last few years and am trying out Intellij. I'm not using it permanently because it isn't as useful for quick programming (like how you can't just drag in files into the src folder) but for doing certain things, I think it will be faster for me.
I know there is Ctrl+Shift+Enter, but this is just annoying to press. Not because it is awkward to press, but because it takes so much time compared to just pressing enter like you can in Eclipse. I tried to rebind it to enter, but then it just doesn't work.
Is there a way to set up the Complete Current Statement so that it happens when I press enter?
Like, is there a way that I can bind it to Enter, but have it checked before the editor checks for enter as move to next line?
If you want only basic Code completion and not Type completion, use Ctrl+Space
IntelliJ and Android Studio are pretty highly customisable. You can rebind shortcuts too, I believe. Have you looked here? https://www.jetbrains.com/idea/help/configuring-keyboard-shortcuts.html
Also cheatsheet might be of use: https://www.jetbrains.com/idea/docs/IntelliJIDEA_ReferenceCard.pdf
And Android specific bindings: https://developer.android.com/sdk/installing/studio-tips.html
I'm new to Eclipse.
I haven't found a way to fold blocks of code in Java smaller than a method.
I have a legacy project to maintain with huge and frequent nested conditionals. Refractoring is not an option at this point.
I searched StackOverflow, there was some mention of a plugin called Coffee-Bytes which enhances Eclipse code folding, but the GoogleCode site where it is hosted said the project is no longer being developed and there were no downloads to download.
Can anyone suggest an alternative?
I already have a better IDE ( Visual Slickedit ), but I am trying to get used to using Eclipse, at least for a while as it seems to be an industry standard.
Thanks
Put the cursor in front of the code block to the left. I used a long conditional
Press the PageDown key with numlock on/off.
You do not get any graphical indication that anything is folded.
I had line number display enabled so I could see that a sequence of numbers were missing.
I've just recently become interested in programming, and I want to create Android apps for phones or tablets. I've come a long way in a couple weeks from knowing almost nothing about java/xml. I'm very serious about this. I'm going to find the answer to this question one way or the other. In fact, I hope to have it figured out before anyone answers this. I've fixed many issues without resorting to asking anyone, but I've just been stuck on this issue too long. I figured I'd give this a shot.
I'm using an older tutorial to build a practice twitter app (the tutorials for these seem to be everywhere, which is why I chose it). I'm using Eclipse for an editor.
The following is an example of code from the tutorial. which relates to my question:
#Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.timeline);
Apparently since the intro of ADT 14, you can no longer use the (R.layout.timeline) phrase, which the error message refers to as a "switch statement."
Now, in a post I found on another site, someone who had a similar issue shows a screenshot of the "quick fix" in Eclipse using ctrl+1. in the screenshot, the fix that pops up says "convert switch to 'if-else' statement." This fix does not pop up in my version of Eclipse. My quick fix options are "migrate Android code", "create field 'timeline' in type 'layout'", "create constant 'timeline' in type 'layout'" or "rename in file."
If I choose "migrate Android code", a window pops up informing me of the ADT 14 update, and how switch statements are no longer allowed in library projects. It says to convert the switch statement to an "if-else" statement by pressing ctrl+1 for the quick fix, then choosing "switch to 'if-else' statement" like it does in the screenshot I found. But again, when I do this, that option does not pop up.
I would much rather know what needs to be changed in the code than know how to make the right quick fix pop up. If it isn't too much trouble, an explanation of why exactly these changes are affective would be very helpful. I have many (MANY) errors in my java files right now, but most of them are due to this exact problem in different forms. If I could see just one before/after example I could probably figure it out from there without an explanation. But after hours of searching, I cannot find that so far by googling.
Thanks so much in advance....
And for the record, I don't see any switch classes in any of my java files, if that makes a difference for the answer...
Make sure you click on the switch keyword itself then press Ctrl + 1.
This confused me at first as well...
If it still doesn't show up, what version of Eclipse are you using?
If you are using a Mac select the keyword switch and click Shift + Command + 1.
That will show a prompt to change switch to if else conditions.
I've been having the same issues. For me, I was switching on view.getId(). Before the switch, declare int id = view.getId();. Then switch in id. Then you can ctrl+1 click and the "Convert Switch to If/Else" should pop up.
They made this change to decrease the build speed. My projects now build in roughly 1/10th of the time. I'm glad I upgraded the ADT.
The issue happens because since ADT 14 resource identifiers are no longer final.
The quick solution you can change switch statements with if-else statements.
With Android Studio 4.1.3
Step:1. Just right click on the switch keyword of statement.
Step:2 Click on the first option Show Context Actions.
Step:3 Click replace switch with if.
Done
To me, it looks like you don't have a timeline resource.
Breaking down R.layout.timeline
R refers to Resources
layout refers to the collection of layouts in your application
and timeline refers the specific resource that you are trying to apply setContentView() too.
If my hunch is correct, you don't have the timeline resource.
Create a new XML file in your layout folder in eclipse and name it 'timeline'
That should resolve the issue.
I hope you got things working.
I agree that this sounds like some weird Eclipse error that is not what it seems, and not what Quick Fix says it is. Eclipse has been known to lie from time to time. Cleaning your project (as #Stephen Dubya said), cutting out the offending code, saving the file, pasting it back in, and saving again...these are some of the non-obvious tricks that sometimes get Eclipse to behave.
In general, I think it would be good for you to get more familiar with some of the Java basics like switch; I think it will make your learning of Android a lot easier. Although the tools and documentation keep improving, Android is still young and not always easy to learn using tutorials, especially when you aren't used to writing code at all or using complicated IDEs like Eclipse.
But I digress. It is only in Android library projects, not regular projects, that Android doesn't treat resources as constants (final variables), since ADT 14. That means means that in library projects, you can't use R.layout.timeline or similar resource variables in your switch statements. You can only switch on whole numbers or enum values.
Using if-else all the time may be your best bet, anyway. switch can, especially for beginners, lead to logic errors in your code, and anything you can write using switch can be rewritten using if-else blocks. Personally, I've stopped using switch in Android and other Java code altogether.
You need to place the curse right before the s in the word switch, and the press cmd 1 . If you switch statements have fall-through clauses, the option to convert won't be available.
Somehow I overworked this error. I have deleted my project from workspace. Reverted it's .project files to old ones commited at SVN. Then at Eclipse uninstalling ADT and install it again. Then import my project. - > Libraries are added the old way and as result all fields at R.java are now final. Hope this helps.
I've started up with developing Java.
However, These days I've started iPhone project and gave me lazy writing code;auto code generate functionality in xCode.
Are there any non-pay free edition add-on exist that does similar to xCode?
I mean, I do know Eclipse already has partial auto method look up when you put '.' (dot) token after class name which shows the list of methods.
thank you all.
The functionality is called content assist in Eclipse. It comes as default.
To trigger content assist, normally you have to click Ctrl+Space (Windows/Linux). But as you said, on Java it will be auto-activated when user press ..
You can however change this behavior. Go to Preferences -> Java -> Editor -> Content Assist and change the Auto activation triggers for Java.
For example to get the behavior of xCode, you could change it to ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.
It comes by default with eclipse.
You need to press . then ctrl + spacebar
If ctrl + space doesn't work, you may try Alt + /
I used to think the autocompletion was slow, but it turns out you can make it instant. Go to Window / Preferences / Java / Editor / Content Assist / Auto-Activation and decrease Auto activation delay to zero.
I've been using Code Recommends. This is a very useful Eclipse plugin you must have.
One of my most favorite functionality is
Subwords Completion (you don't need to remember exactly the first letter of method's name, just type in other whatever letter you remember even they're inside).
It also offers many other functionality that may meet your need.