简体   繁体   English

在编程和自动完成不起作用时,Eclipse未编译

[英]Eclipse is not compiling while programming and auto-complete doesn't work

I installed a new plugin for Eclipse (named AgentZero). 我为Eclipse安装了一个新插件(名为AgentZero)。 I imported a project using MercurialEclipse, and the importing was ok. 我使用MercurialEclipse导入了一个项目,导入正常。 Now, while programming this project, there is no compilation. 现在,在对该项目进行编程时,没有任何编译。 In addition, there is no auto-complete. 此外,没有自动完成功能。 When I am trying to use auto-complete, I get the following message: "This compilation unit is not on the build path of a Java project". 当我尝试使用自动完成功能时,收到以下消息:“此编译单元不在Java项目的构建路径上”。 Afterwards, I get this message: "The 'org.eclipse.ui.JavaAllCompletionProposalComputer' proposal computer from 'org.eclipse.jdt.ui' plug-in did not complete normally. The extension took too long to return from the 'computeCompletionProposals()' operation. To avoid thus message, diable the 'org.eclipse.jdt.ui' plug-in or disable the 'Java Proposals' category int the content assist preference page." 之后,我收到此消息:“来自'org.eclipse.jdt.ui'插件的'org.eclipse.ui.JavaAllCompletionProposalComputer'提案计算机未正常完成。该扩展程序花费的时间太长,无法从'computeCompletionProposals( )操作。为避免出现此类消息,请禁用“ org.eclipse.jdt.ui”插件或在内容辅助偏好页面中禁用“ Java建议”类别。”

All the other projects are fine. 所有其他项目都很好。 What can I do? 我能做什么? Thank you 谢谢

You need to check, whether the import has correctly configured the project as a Java project. 您需要检查导入是否已将项目正确配置为Java项目。

Is it a Java project? 它是Java项目吗?

  • Does it have a "J" overlay on the project icon? 在项目图标上是否有“ J”覆盖?
  • Does it have pages like Java Build Path & Java Compiler in the project's property dialog? 在项目的属性对话框中是否有类似Java Build PathJava Compiler的页面?
  • On the Builders property page, does it show "Java Builder" and is that entry checked? 在“ Builders”属性页面上,它是否显示“ Java Builder”,并且该条目已选中?

Are the source folders correctly configured? 是否正确配置了源文件夹?

  • Check Java Build Path > Source in the project's properties 检查项目属性中的Java Build Path> Source
  • Make sure there are no unwanted inclusion/exclusion filters. 确保没有多余的包含/排除过滤器。

If any of these is missing or has errors, JDT lacks context for proposing any code completions -- hence the error dialog you are seeing. 如果其中任何一个丢失或有错误,JDT将缺少建议任何代码完成的上下文-因此,您将看到错误对话框。

I can't advise regarding AgentZero, nor did you specify how this plugin relates to the problem. 我不能为AgentZero提供建议,也没有指定此插件与问题的关系。

If the above doesn't resolve the issue, you should look for recent entries in the Error Log . 如果以上方法不能解决问题,则应在错误日志中查找最近的条目。

EDIT: 编辑:

If indeed the project is not correctly configured as a Java project, it might be interesting to know how you got into this situation. 如果确实没有将项目正确配置为Java项目,那么知道如何进入这种情况可能会很有趣。 If, eg, you simply forgot to select an option during project import, starting over might be the cleanest option. 例如,如果您只是在项目导入期间忘记选择一个选项,那么重新开始可能是最干净的选项。 If, OTOH, the import tool failed to do, what it was supposed do, you may want to report a bug (against MercurialEclipse in this case). 如果OTOH导入工具无法执行操作,应该执行该操作,则您可能需要报告一个错误(在这种情况下,针对MercurialEclipse)。

If the problem cannot be fixed by re-importing, a few careful modifications of project configuration files might get you back on track. 如果无法通过重新导入解决问题,则对项目配置文件进行一些仔细的修改可能会使您回到正轨。 In this case I suggest to create a fresh plain Java project and use the created configuration as a reference for your repair. 在这种情况下,我建议创建一个全新的纯Java项目,并使用创建的配置作为修复的参考。

For this you should know the purpose of these files (which all are by default hidden in the Package Explorer, due to the ".* resources" filter): 为此,您应该了解这些文件的用途(由于“。*资源”过滤器,所有这些文件默认情况下都隐藏在Package Explorer中):

.project 。项目

This file should attach the Java nature to the project. 该文件应将Java性质附加到项目中。 This is how Eclipse recognizes a project as a Java project. 这就是Eclipse将项目识别为Java项目的方式。 Additionally, .project declares all builders that are automatically invoked. 此外,.project声明所有自动调用的构建器 Adding nature and builder (if absent) is a safe operation and might already fix your issues. 添加自然和构建器(如果不存在)是安全的操作,并且可能已经解决了您的问题。 Check the result in the project properties dialog. 在项目属性对话框中检查结果。

.classpath .classpath

Here Eclipse stores everything you configured on the Java Build Path property page. Eclipse在这里存储您在Java Build Path属性页面上配置的所有内容。 Since the content of this file very much depends on how you manage dependencies (eg, using Maven?), no general advice can be given. 由于此文件的内容很大程度上取决于您如何管理依赖项(例如,使用Maven?),因此无法提供一般建议。 If possible use the properties dialog rather than manual editing. 如果可能,请使用属性对话框,而不要手动编辑。

.settings/org.eclipse.jdt.core.prefs .settings / org.eclipse.jdt.core.prefs

Here JDT stores all further configuration options, like compiler options. JDT在这里存储所有其他配置选项,例如编译器选项。

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

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