Eclipse Randomly Deleting My Code when Refactoring - java

I have been using Eclipse for several years now with lots of ups and downs. Recently, I started having a brand new problem: I spend 20-30 min making changes to my code and suddenly (out of nowhere) Eclipse decides to revert all the changes I worked on in the last 20-30 minutes.
I followed the suggestion in this reply but Eclipse won't even show the new code I wrote in the Local History.
It's beginning to happen so frequently that it is really effecting productivity. One step ahead, two steps backwards. It occurs even when I religiously save my work every couple of minutes - even the "saved" changes are reverted.
Based on a quick analysis it seems this happens most frequently when I try to rename a variable and Eclipse says I need to select a variable (which I did, but that's besides the point) to refractor it. After I click OK in popup, at that point eclipse "undoes" all the code I worked on in the last twenty minutes or so. No questions asked.
Has anyone faced a similar situation? Really thinking of switching to IntelliJ IDEA even though I've been using eclipse for years.
Thanks
UPDATE 1:
I noticed the issue occurs only after I get the following message:
A fatal error occurred while performing the refracting
A local variable deceleration or reference must be selected to activate the Refactoring
UPDATE 2:
I am now able to restore recent edits via Local History. In other words, the recent edits are showing up now in Local History, so this was an oversight on my end. However the primary problem with Eclipse reverting changes when refactoring variable is still present. In other words, I still need to "restore" my work every 20-30 minutes (when refactoring variable that results in fatal error message above) via Local History.
UPDATE 3:
The error also occurs when I try to refactor and get the following message:
Rename Refactoring: Could not a method for project handle "null" with handle identifier..

Related

Eclipse & E-Git: checking out old Github revisions for comparison - but can't checkout/restore current HEAD revision

I have a longtime question here about checking out old Git revisions. There's a feature in Eclipse where you can view your "Git History" via the Team Version Control History view and see all of your commits. If you right-click old revisions, you can click "Checkout" in the context menu to revert your project to that version. It's extremely helpful for seeing where a specific bug began, since sometimes these bugs can be a single line in a project that's hundreds of thousands of lines long.
The problem is that, when I check out these old versions, I can't quite figure out through the Eclipse UI how to revert my project back to the main HEAD version, or newer versions in general, once I've finished scoping out an old one.
In particular, I opened the git history view in Eclipse and checked out a version from 4 days ago. However, I want to go back to the latest revision, and the history seems to stop at the current one I have checked out and I can't go above it. I've tried multiple things but it usually just ends up screwing up the project more, and I eventually give up - delete the project - and re-clone it. Which is tedious to say the least.
For some context, here is a question that goes over how this reversion process works. Unfortunately the answer to this specific post says to simply check-out the latest revision again when you're done to revert, but as I'll explain below, it hides the revisions after the one I checked out, after I've checked it out:
How to go to previous commits in eclipse and egit
How do I get it to show the revisions after the one I currently have checked out? This is a bit frustrating to say the least. You can see here, nothing is showing above this revision:
EDIT: After re-cloning again, here's what it looks like when the current version is the HEAD revision. The options above the old one I had checked out when I made this post disappeared:
And lastly, just to help out a bit more, here's a screenshot of the git history menu/context menu to show you exactly what functionality I'm talking about:
Thank you for your time!
In the toolbar at the top-right of the history view, there’s a dropdown button to control which commits to show. It’s the one that looks like a pale blue downward arrow splitting into two. By default it’s set to show only ancestors of the current HEAD, but you can select additional filters. The one you want is probably refs/heads/** which will show all local branches.

Why doesn't Android Studio see updates right away?

I am using Android Studio 4.1.1. windows 7. I write in Java. I noticed this feature of the program. Changing something in code, layout or resources. I run the program and see that my changes have not appeared! First comes the thought that I was wrong somewhere. I start looking for an error. I don’t find it. I run the program again and it already works as it should. Now I'm used to it. The larger the program, the more often this happens. To be sure of the result, you have to run the program twice each time, because I'm not sure if this time all the changes took effect. It is very uncomfortable. Tell me why this is happening and how to solve this problem.

Intellij - Debugger Breakpoints not working anymore

I was working/debugging normally on my Java-Maven project with IntelliJ 2018.2.1, I then click on Intellij to Stop the app to make some modifications to the code and when I start the application again in debug mode, it (the debugger) simply stopped working.
Now, the application takes about +10+20 seconds to start and when the breakpoints are hit, it simply hangs and do nothing else.
I have tried many of the suggestions posted on Internet, but none of those seems to work. I also tried to Invalidate/Restart the IDE, but nothing.
Now, the breakpoints aren't even marked as valid any more, it only shows the red circle without the tick verification check. And it also extended to all projects, so now none of the projects the debugger works and the same symptoms are in all projects.
If anyone have any suggestion on this, would really appreciate it.
Solved the issue. It ended up being that I am using another application (NetLimiter) to limit the traffic in the network and I limited few days ago IntelliJ to consume only 5 kbps at any time and this was the problem. I simply removed the limitation and the debugger starting working again normally at its usual speed.
This is typically caused because there is a process running that it is connected to but you have no way to find it.
The only way to resolve it is to reboot your machine.
Now, the application takes about +10+20 seconds to start and when the
breakpoints are hit, it simply hangs and do nothing else.
By this syptom I can suggest that you have accidentally added some field or method breakpoint. Please check that there are no field or method breakpoints present in Breakpoints window (Ctrl + Shift + F8). If they exist - remove them.

How on earth does he debug a running application like this, and more importantly, how can I?

"Debugception!"
You may notice that within the first 15 seconds of this YouTube video (from 1:01:01 to 1:01:16), Markus Persson (aka "Notch", creator of Minecraft) has somehow managed to save/update an application and attach a debugger to it while it was already under the process of being debugged, supposedly all with a simple keyboard shortcut. The previously coded application somehow magically became the newly edited one, and seemingly without relaunching it or spawning a new process... It's possible that this is just some form of locally remote debugging, but something about it just doesn't seem quite right.
I've spent several days Googling and asking around on how he was able to do this, yet to no avail. I've found no such option under Eclipse preferences, and whenever I try to save & debug an already running application, it simply launches a separate instance of the newly updated application, side-by-side with the older, outdated one.
Am I missing something? How was this possible?
How was he able to utilize such an astounding, powerful debugging feature?
Thanks in advance!
Update
Okay, so this appears to be a standard feature specific to Eclipse.
Coming from a background in NetBeans and Visual Studio, I'm astounded that this doesn't seem to exist elsewhere (or at least in NetBeans!)...
This is a built-in feature of Eclipse. If you edit a method while the program is running in debug mode, it will compile the new method, and replace the old method with the new version. If some thread was already running that method, it will jump back to the beginning (AFAIK; this might only happen when the program is paused).
You don't need to re-launch the program or set any special preferences. Just edit and save, and the magic will happen.
Eclipse can't always figure out how to merge your changes into the running program - usually if you changed anything outside a method body (including the method's parameters or return type). In this case, you will get a warning dialog, with the option to stop the program, restart the program or ignore the changes.

Eclipse screws up every time I type an object's method

So for example with my current object tabPanelMain, I'll type a dot after it and expect to see a drop down menu of all the object's available methods. Instead, the marker which shows my currently selected character on the editor disappears meaning I don't know where I'm typing. Worse than that is that the save and save all buttons stop working. And ctrl-s and the menu saves don't work either. I can't save my eclipse projects and have to restart, thus losing my work.
What could be wrong? This problem never used to exist but now I just can't get the methods of an object like I used to.
I hope that was clear enough, please ask me questions if not.
The save problem with not being able to save is one I've encountered before.
I don't know why it happens but for me it helps to minimize and then maximize eclipse again.
Not a fix but at least a workaround that lets you save.
Never heard of the other problem though.
I couldn't figure out what it was that was causing the problem, and while Martin Larsson provided an effective short term solution, I found it best to fresh install Eclipse.
The most annoying part about this was transferring my previous plug ins (like GWT, Subversion, etc) over to the new install. In the end I ended up re-installing them manually. If anyone could shed some light on how to keep previous plug ins, I'd like to hear how. Though I've heard this can be problematic with path urls in the files or something.

Categories

Resources