简体   繁体   English

Eclipse Mars:代码不见了

[英]Eclipse Mars: code is gone

Please, help!请帮忙! I opened Eclipse Mars to continue coding and my code is gone!我打开 Eclipse Mars 继续编码,但我的代码不见了! I don't know what could have caused this but it's all gone.我不知道是什么原因造成的,但一切都消失了。 Does anyone have any idea what can I do?有谁知道我能做什么?

在此处输入图像描述

Note: I tried to right-click the java file->Replace With->Previous from local history.注意:我尝试右键单击java文件->替换为->本地历史记录中的上一个。 But a message says "No local history available for selected resource".但是一条消息显示“没有可用于选定资源的本地历史记录”。 Is there any other way?还有其他方法吗?

Thank you in advance!先感谢您!

The first step in debugging this problem is to find out if the code is still exists without using Eclipse.调试此问题的第一步是在不使用 Eclipse 的情况下找出代码是否仍然存在。 Several possibilities come to mind:想到了几种可能性:

  1. The code is still where you expect, the files exist and the content is OK.代码仍然在您期望的位置,文件存在并且内容正常。
  2. The code is still where you expect, the files exist, but the files are empty.代码仍在您期望的位置,文件存在,但文件为空。
  3. The workspace directory does not exist any more.工作区目录不再存在。

You need to use a file explorer program to find the files and check they are not empty.您需要使用文件资源管理器程序来查找文件并检查它们是否为空。 Try opening them with Notepad++ or similar.尝试使用 Notepad++ 或类似工具打开它们。 If you are lucky, option 1 will be the answer, and Eclipse has got confused.如果幸运的话,选项 1 将是答案,而 Eclipse 对此感到困惑。 Just use File/Switch Workspace to set the workspace to the directory and all should come right.只需使用 File/Switch Workspace 将工作空间设置为目录,一切都应该正确。

Options 2 & 3 indicate you have lost data.选项 2 和 3 表示您丢失了数据。 There is probably little chance of recovery.可能恢复的可能性很小。 Revert to your backups (you do have them?).恢复到您的备份(您有吗?)。 Otherwise learn a lesson and set up a GIT or SVN server (or subscribe to a cloud service).否则吸取教训并设置 GIT 或 SVN 服务器(或订阅云服务)。 I just use a very old laptop running Ubuntu with SVN server installed.我只是使用一台运行 Ubuntu 并安装了 SVN 服务器的非常旧的笔记本电脑。

As a side issue, Eclipse does not randomly delete or empty files.作为一个附带问题,Eclipse 不会随机删除或清空文件。 There are millions of developers world-wide using Eclipse, and if it existed, such behavior would be all over the internet.全世界有数以百万计的开发人员在使用 Eclipse,如果它存在,这种行为将遍布整个互联网。

I had the same problem and found my file with a strange name in local history with this path:我遇到了同样的问题,并在本地历史记录中发现我的文件名称很奇怪,路径如下:

".metadata/.plugins/org.eclipse.core.resources/.history/" “.metadata/.plugins/org.eclipse.core.resources/.history/”

It was not the last version but better than nothing :)这不是最后一个版本,但总比没有好:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM