为什么Eclipse代码完成不能在某些项目上工作?

时间:2023-01-17 15:31:32

I have Eclipse 3.3.2 with PDT doing PHP development. All projects that I create, even SVN projects have code completion. Now I just opened another SVN project and it has no code completion or PHP templates (CTRL-space does nothing in that project). However, I can open the other projects and code completion all work in them.

我有一个使用PDT进行PHP开发的Eclipse 3.3.2。我创建的所有项目,甚至SVN项目都有代码完成。现在我刚刚打开了另一个SVN项目,它没有代码完成或PHP模板(CTRL-space在该项目中什么都不做)。但是,我可以打开其他的项目并完成其中的所有工作。

Why would code completion and templates be "off" in just one project and how can I turn it back on?

为什么代码完成和模板在一个项目中是“关闭”的?我如何将它重新打开?

17 个解决方案

#1


42  

Maybe Eclipse doesn't understand the project has a "PHP nature". Try comparing the .project file on both projects to look for differences. It should contain something like:

也许Eclipse不理解这个项目具有“PHP特性”。尝试比较两个项目上的.project文件,以寻找差异。它应该包含以下内容:

 <natures>
  <nature>org.eclipse.php.core.PHPNature</nature>
 </natures>

The .project file will be in your workspace under the project directories.

项目文件将位于项目目录下的工作区中。

#2


6  

Look out for the file .buildpath in your project... put this line between the tag:

在您的项目中查找文件.buildpath…把这一行放在标签之间:

<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>

< buildpathentry类型=“骗”路径= " org.eclipse.php.core.LANGUAGE " / >

Save it and restart eclipse. Now everything should be OK... This worked for me. :)

保存并重新启动eclipse。现在一切都好了……这为我工作。:)

#3


5  

Thank you! I spent all day long to figure out why I did not have code completion...

谢谢你!我花了一整天的时间来弄明白为什么我没有完成代码……

The problem is that if you create a SVN project the .project is a basic file without codecompletion reference. You have to create a basic PHP project and compare the two files and replacing the missing part in the SVN project one.

问题是,如果您创建一个SVN项目,那么.project是一个基本的文件,没有codecompletion引用。您必须创建一个基本的PHP项目,并比较这两个文件,并替换SVN项目1中缺失的部分。

Now I have code completion for every file in the project, even for Zend Framework library

现在,我对项目中的每个文件(甚至Zend Framework库)都有了代码补全

#4


5  

It is just one line to add in the .project file and then restarting eclipse to get codecompletion: Where it says

只需要在.project文件中添加一行,然后重新启动eclipse以获得codecompletion:它说的地方

---
 <natures>
 </natures>
---

after the change has to be

在改变之后

---
 <natures>
  <nature>org.eclipse.php.core.PHPNature</nature>
 </natures>
---

That should do.

这应该做的。

#5


4  

@Guido PHPNature does not fix this.

@Guido PHPNature没有解决这个问题。

@Edward Tanguay Yes, that's because when you create new PHP project, eclipse adds .buildpath file with

@Edward Tanguay:是的,这是因为当您创建新的PHP项目时,eclipse添加了.buildpath文件

<?xml version="1.0" encoding="UTF-8"?><buildpath>
<buildpathentry kind="src" path=""/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/></buildpath>

when you import existing project you eclipse does not generates .buildpath file, but you can add it by hand or create new PHP project with existin source (you can choose in wizard).

当您导入现有项目时,eclipse不会生成.buildpath文件,但是您可以手工添加它,或者使用existin源代码创建新的PHP项目(您可以在向导中选择)。

#6


3  

I have the same issue sometimes. For me it works to rebuild the PHP project with "Project" -> "Clean".

我有时也有同样的问题。对我来说,用“project”->“Clean”重新构建PHP项目是可行的。

#7


2  

If you have this problem, follow these steps :

如果你有这个问题,遵循以下步骤:

  • Select "PHP Include Path" in your project tree
  • 在项目树中选择“PHP Include Path”
  • Right click on it then click "Build Path>Configure Build Path"
  • 右键点击它然后点击“构建路径>配置构建路径”
  • On the opening window,add folder that you want to build, so it can do code assist.
  • 在打开的窗口中,添加您想要构建的文件夹,这样它就可以执行代码辅助。

Thats all :) I hope it resolves your problem, I solved my one :)

我希望它能解决你的问题,我解决了我的问题。

#8


1  

Be sure the file opens with the "PHP editor". Right-click the file, and select open with to select the right editor.

确保文件以“PHP编辑器”打开。右键单击该文件,并选择open with以选择正确的编辑器。

If it turns out you've been using the wrong editor, you can change the association under Preferences » General » Content Types

如果发现您使用了错误的编辑器,您可以在Preferences»一般»内容类型下更改关联

#9


1  

Right click in the edit screen, goto Java -> Editor -> Content Assist -> Advanced ...select proposals accordingly

右键点击编辑屏幕,goto Java ->编辑器->内容协助->高级…选择相应的建议

#10


1  

ATTENTION

注意

Besides the already mentioned solutions to get the whole autocomplete help to work, there is another quirk: it might not be enabled.

除了前面提到的使整个自动完成帮助工作的解决方案之外,还有另一个问题:它可能没有被启用。

Go to Window > Properties and then to PHP > Editor > Code Assist (JAVA has a similar option) and set "Enable auto activation", preferably with a delay that you see comfortable (0ms). If you are bothered by the program suddenly deciding to do things for you without prompt (and doing it wrong), deselect "Insert single proposals automatically" and you should be fine.

转到窗口>属性,然后转到PHP >编辑器>代码辅助(JAVA也有类似的选项),并设置“启用自动激活”,最好延迟(0ms)。如果你被程序突然决定为你做一些没有提示的事情而困扰(而且做错了),取消选择“自动插入单一提案”,你应该没问题。

#11


0  

I've noticed sometimes when you checkout a project from svn in eclipse (subversive or subsclipe "checkout a project as") and even though you check it out as a php project it will either delete the .project file or it would be a generic project. I've found to just go in that directory and delete the .project .settings/ and .cach/

我注意到,有时当您在eclipse中从svn签出项目时(颠覆性或subsclipe“签出项目”),即使您将它作为一个php项目进行检查,它也会删除.project文件,或者它将是一个通用的项目。我发现只要进入那个目录并删除。project .settings/和。cach/

Then create a new php project and point the directory where you checked out the files. And you should have code completion and svn should be link to your repo.

然后创建一个新的php项目,并指向签出文件的目录。您应该有代码完成和svn应该链接到您的repo。

#12


0  

I had a problem that build path was empty, so no code completion for any of the files i tried to edit. Make sure you setup properly your build path, especially if you're linking the source from some other location than the workspace.

我有一个问题,构建路径是空的,所以我试图编辑的任何文件都没有代码完成。确保正确地设置了构建路径,特别是当您从工作区之外的其他位置链接源时。

Like the apache htdocs folder for example.

比如apache htdocs文件夹。

#13


0  

I have solved this by enabling the Full C/C++ indexer (Windows-> properties -> C/C++ -> Indexer), and also hit the radio button "Use active button configuration". After that Clean, and Build all.

我通过启用完整的C/C+索引器(Windows->属性-> C/ c++ ->索引器)来解决这个问题,同时点击单选按钮“使用活动按钮配置”。在清理之后,把所有的东西都建好。

That worked on Eclipse CDT 3.4

在Eclipse CDT 3.4中工作。

#14


0  

If you came here looking for code completion in php eclipse not working, make sure your project is being supported as a php project. Right click on the project and then go to configure -> Add php support. If you have the right settings for code assist it should work instantaneously. Sometimes newbies as me tweak around with the projects or start projects as clean and not as php so eclipse doesn't know how to treat the project.

如果您在这里寻找php eclipse中的代码完成功能,请确保项目作为php项目得到支持。右键单击项目,然后配置—>添加php支持。如果您有正确的代码帮助设置,它应该立即工作。有时像我这样的新手会对项目进行调整,或者启动项目时像php一样干净,这样eclipse就不知道如何处理项目。

#15


0  

I had to right click the project in the PHP Explorer, go to "PHP Build Path". This was empty. I clicked "Add Folder", selected the checkbox next to the root folder of my project and clicked "OK", then "OK" again.

我必须在PHP浏览器中右键单击项目,转到“PHP构建路径”。这是空的。点击“添加文件夹”,选中项目根文件夹旁边的复选框,点击“OK”,再次点击“OK”。

After that code completion seemed to work. Should just work out of the box if you ask me, but whatever.

在代码完成之后,似乎可以工作了。如果你问我的话,应该直接从盒子里算出来,但不管怎样。

#16


0  

Check the lib of your project. It may be that you have include two such jar files in which same class is available or say one class in code can be refrenced in two jar files. In such case also eclipse stops assisting code as it is totally confused.

检查项目的lib。您可能已经包含了两个可用类的jar文件,或者说代码中的一个类可以在两个jar文件中重构。在这种情况下,eclipse将停止辅助代码,因为它完全被混淆了。

Better way to check this is go to the file where assist is not working and comment all imports there, than add imports one by one and check at each import if code-assist is working or not.You can easily find the class with duplicate refrences.

检查这一点的更好的方法是进入协助不工作的文件并注释那里的所有导入,而不是一个一个地添加导入并检查每个导入是否正常工作。您可以很容易地找到具有重复折射率的类。

#17


-1  

One solution could be to include a dummy php file wich requires all your PHP classes. So that the PHP parser recognizes these classes too. Example dummy file:

一种解决方案是包含一个需要所有php类的虚拟php文件。这样PHP解析器也可以识别这些类。虚拟文件示例:

if(false) {
     require_once 'class/one.php';
     require_once 'class/two.php';
     require_once 'class/three.php';
}

#1


42  

Maybe Eclipse doesn't understand the project has a "PHP nature". Try comparing the .project file on both projects to look for differences. It should contain something like:

也许Eclipse不理解这个项目具有“PHP特性”。尝试比较两个项目上的.project文件,以寻找差异。它应该包含以下内容:

 <natures>
  <nature>org.eclipse.php.core.PHPNature</nature>
 </natures>

The .project file will be in your workspace under the project directories.

项目文件将位于项目目录下的工作区中。

#2


6  

Look out for the file .buildpath in your project... put this line between the tag:

在您的项目中查找文件.buildpath…把这一行放在标签之间:

<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>

< buildpathentry类型=“骗”路径= " org.eclipse.php.core.LANGUAGE " / >

Save it and restart eclipse. Now everything should be OK... This worked for me. :)

保存并重新启动eclipse。现在一切都好了……这为我工作。:)

#3


5  

Thank you! I spent all day long to figure out why I did not have code completion...

谢谢你!我花了一整天的时间来弄明白为什么我没有完成代码……

The problem is that if you create a SVN project the .project is a basic file without codecompletion reference. You have to create a basic PHP project and compare the two files and replacing the missing part in the SVN project one.

问题是,如果您创建一个SVN项目,那么.project是一个基本的文件,没有codecompletion引用。您必须创建一个基本的PHP项目,并比较这两个文件,并替换SVN项目1中缺失的部分。

Now I have code completion for every file in the project, even for Zend Framework library

现在,我对项目中的每个文件(甚至Zend Framework库)都有了代码补全

#4


5  

It is just one line to add in the .project file and then restarting eclipse to get codecompletion: Where it says

只需要在.project文件中添加一行,然后重新启动eclipse以获得codecompletion:它说的地方

---
 <natures>
 </natures>
---

after the change has to be

在改变之后

---
 <natures>
  <nature>org.eclipse.php.core.PHPNature</nature>
 </natures>
---

That should do.

这应该做的。

#5


4  

@Guido PHPNature does not fix this.

@Guido PHPNature没有解决这个问题。

@Edward Tanguay Yes, that's because when you create new PHP project, eclipse adds .buildpath file with

@Edward Tanguay:是的,这是因为当您创建新的PHP项目时,eclipse添加了.buildpath文件

<?xml version="1.0" encoding="UTF-8"?><buildpath>
<buildpathentry kind="src" path=""/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/></buildpath>

when you import existing project you eclipse does not generates .buildpath file, but you can add it by hand or create new PHP project with existin source (you can choose in wizard).

当您导入现有项目时,eclipse不会生成.buildpath文件,但是您可以手工添加它,或者使用existin源代码创建新的PHP项目(您可以在向导中选择)。

#6


3  

I have the same issue sometimes. For me it works to rebuild the PHP project with "Project" -> "Clean".

我有时也有同样的问题。对我来说,用“project”->“Clean”重新构建PHP项目是可行的。

#7


2  

If you have this problem, follow these steps :

如果你有这个问题,遵循以下步骤:

  • Select "PHP Include Path" in your project tree
  • 在项目树中选择“PHP Include Path”
  • Right click on it then click "Build Path>Configure Build Path"
  • 右键点击它然后点击“构建路径>配置构建路径”
  • On the opening window,add folder that you want to build, so it can do code assist.
  • 在打开的窗口中,添加您想要构建的文件夹,这样它就可以执行代码辅助。

Thats all :) I hope it resolves your problem, I solved my one :)

我希望它能解决你的问题,我解决了我的问题。

#8


1  

Be sure the file opens with the "PHP editor". Right-click the file, and select open with to select the right editor.

确保文件以“PHP编辑器”打开。右键单击该文件,并选择open with以选择正确的编辑器。

If it turns out you've been using the wrong editor, you can change the association under Preferences » General » Content Types

如果发现您使用了错误的编辑器,您可以在Preferences»一般»内容类型下更改关联

#9


1  

Right click in the edit screen, goto Java -> Editor -> Content Assist -> Advanced ...select proposals accordingly

右键点击编辑屏幕,goto Java ->编辑器->内容协助->高级…选择相应的建议

#10


1  

ATTENTION

注意

Besides the already mentioned solutions to get the whole autocomplete help to work, there is another quirk: it might not be enabled.

除了前面提到的使整个自动完成帮助工作的解决方案之外,还有另一个问题:它可能没有被启用。

Go to Window > Properties and then to PHP > Editor > Code Assist (JAVA has a similar option) and set "Enable auto activation", preferably with a delay that you see comfortable (0ms). If you are bothered by the program suddenly deciding to do things for you without prompt (and doing it wrong), deselect "Insert single proposals automatically" and you should be fine.

转到窗口>属性,然后转到PHP >编辑器>代码辅助(JAVA也有类似的选项),并设置“启用自动激活”,最好延迟(0ms)。如果你被程序突然决定为你做一些没有提示的事情而困扰(而且做错了),取消选择“自动插入单一提案”,你应该没问题。

#11


0  

I've noticed sometimes when you checkout a project from svn in eclipse (subversive or subsclipe "checkout a project as") and even though you check it out as a php project it will either delete the .project file or it would be a generic project. I've found to just go in that directory and delete the .project .settings/ and .cach/

我注意到,有时当您在eclipse中从svn签出项目时(颠覆性或subsclipe“签出项目”),即使您将它作为一个php项目进行检查,它也会删除.project文件,或者它将是一个通用的项目。我发现只要进入那个目录并删除。project .settings/和。cach/

Then create a new php project and point the directory where you checked out the files. And you should have code completion and svn should be link to your repo.

然后创建一个新的php项目,并指向签出文件的目录。您应该有代码完成和svn应该链接到您的repo。

#12


0  

I had a problem that build path was empty, so no code completion for any of the files i tried to edit. Make sure you setup properly your build path, especially if you're linking the source from some other location than the workspace.

我有一个问题,构建路径是空的,所以我试图编辑的任何文件都没有代码完成。确保正确地设置了构建路径,特别是当您从工作区之外的其他位置链接源时。

Like the apache htdocs folder for example.

比如apache htdocs文件夹。

#13


0  

I have solved this by enabling the Full C/C++ indexer (Windows-> properties -> C/C++ -> Indexer), and also hit the radio button "Use active button configuration". After that Clean, and Build all.

我通过启用完整的C/C+索引器(Windows->属性-> C/ c++ ->索引器)来解决这个问题,同时点击单选按钮“使用活动按钮配置”。在清理之后,把所有的东西都建好。

That worked on Eclipse CDT 3.4

在Eclipse CDT 3.4中工作。

#14


0  

If you came here looking for code completion in php eclipse not working, make sure your project is being supported as a php project. Right click on the project and then go to configure -> Add php support. If you have the right settings for code assist it should work instantaneously. Sometimes newbies as me tweak around with the projects or start projects as clean and not as php so eclipse doesn't know how to treat the project.

如果您在这里寻找php eclipse中的代码完成功能,请确保项目作为php项目得到支持。右键单击项目,然后配置—>添加php支持。如果您有正确的代码帮助设置,它应该立即工作。有时像我这样的新手会对项目进行调整,或者启动项目时像php一样干净,这样eclipse就不知道如何处理项目。

#15


0  

I had to right click the project in the PHP Explorer, go to "PHP Build Path". This was empty. I clicked "Add Folder", selected the checkbox next to the root folder of my project and clicked "OK", then "OK" again.

我必须在PHP浏览器中右键单击项目,转到“PHP构建路径”。这是空的。点击“添加文件夹”,选中项目根文件夹旁边的复选框,点击“OK”,再次点击“OK”。

After that code completion seemed to work. Should just work out of the box if you ask me, but whatever.

在代码完成之后,似乎可以工作了。如果你问我的话,应该直接从盒子里算出来,但不管怎样。

#16


0  

Check the lib of your project. It may be that you have include two such jar files in which same class is available or say one class in code can be refrenced in two jar files. In such case also eclipse stops assisting code as it is totally confused.

检查项目的lib。您可能已经包含了两个可用类的jar文件,或者说代码中的一个类可以在两个jar文件中重构。在这种情况下,eclipse将停止辅助代码,因为它完全被混淆了。

Better way to check this is go to the file where assist is not working and comment all imports there, than add imports one by one and check at each import if code-assist is working or not.You can easily find the class with duplicate refrences.

检查这一点的更好的方法是进入协助不工作的文件并注释那里的所有导入,而不是一个一个地添加导入并检查每个导入是否正常工作。您可以很容易地找到具有重复折射率的类。

#17


-1  

One solution could be to include a dummy php file wich requires all your PHP classes. So that the PHP parser recognizes these classes too. Example dummy file:

一种解决方案是包含一个需要所有php类的虚拟php文件。这样PHP解析器也可以识别这些类。虚拟文件示例:

if(false) {
     require_once 'class/one.php';
     require_once 'class/two.php';
     require_once 'class/three.php';
}