NetBeans PHP 代码完成自己的代码

发布于 2024-07-20 17:44:42 字数 1278 浏览 14 评论 0原文

最近,我开始使用 NetBeans 6.7 beta 进行 PHP 开发,而不是 TextmateMacGDBp。 我对它的功能集感到非常惊讶,大多数东西都是开箱即用的,或者很容易根据我的喜好进行配置。

不过,我对代码完成功能有疑问; 它们适用于内置函数, SPL 和我的一些代码,但并非我的所有代码,具体来说,无论 PHPDoc 注释如何,它都不适用于我的类中的任何方法。

我似乎找不到任何像样的问题,更不用说在任何地方找到关于这个特定主题的答案了。 看起来其他所有遇到代码完成问题的人都没有启用自动弹出功能。

所以最大的问题是:

是否有任何方法来影响代码完成缓存,或者我必须添加一些东西到我的代码中才能使其工作? 我真的很想为我编写的方法提供代码补全。

PS:我尝试了几个旧版本的netbeans,它们都出现了同样的问题。

编辑:我已经将当前测试项目的 .zip 压缩了。 在此处获取。 这是一个非常年轻的项目,思考一天半的时间。

edit2:下面是我正在查看的屏幕截图。 正如您所看到的,它几乎没有完成任何事情,也没有看到 PHPDoc 文档。

替代文本

Recently I started using NetBeans 6.7 beta for PHP development instead of Textmate and MacGDBp. I am rather amazed with it's feature set and most everything worked out of the box, or was easily configured to my liking.

I am having an issue with the code completion features though; they work for built-in functions, SPL and some of my code, but not all of my code, specifically, it never works for any methods in my classes, regardless of PHPDoc comments.

I can't seem to find any decent questions, let alone answers about this specific subject anywhere. It looks like everybody else who has problems with the code completion just hasn't enabled the auto-popup feature.

So the big question is:

Is there any way to influence the code completion cache, or something I have to add to my code to make it work? I'd really like to have code completion for the methods I write.

PS: I have tried several older versions of netbeans, they all exhibit the same problem.

edit: I've put a .zip up of my current test project. get it here. It's a very young project, think a day and a half.

edit2: Below is a screenshot of what i'm looking at. As you can see, it fails to complete pretty much anything, nor does it see the PHPDoc documentation.

alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

鸠魁 2024-07-27 17:44:42

我尝试打开你的项目,完成情况似乎对我来说效果很好。

我唯一能想到的就是尝试删除整个 NB 缓存,它应该位于 $HOME/.netbeans/$VERSION/var/cache/ 中。 这是一个疯狂的猜测

先创建备份,我没有尝试过!

如果失败了,也许你应该尝试创建一个新项目,也许这会踢 NB 的屁股。

请注意,在 NB 7.2 beta 中,缓存已移至 $HOME/.cache/netbeans/$VERSION。

I've tried opening your project, and the completion seems to be working just fine for me.

The only thing I can think of is to try to delete your entire NB cache, which should be located in $HOME/.netbeans/$VERSION/var/cache/. This is a wild guess

Create a backup first, I didn't try this!

If that fails, maybe you should try creating a new project, maybe that will kick NB in the butt.

Note that in NB 7.2 beta, the cache has moved to $HOME/.cache/netbeans/$VERSION.

倦话 2024-07-27 17:44:42

对我有用的是删除旧的 nbproject 文件夹(在 Windows 中创建)并从现有源重新创建 PHP 项目。 这是在 NB 7.0.1 Mac OS X 上。清除缓存对我来说不起作用。

What worked for me was deleting the old nbproject folder (that was created in windows) and recreating the PHP project from existing sources. This is on NB 7.0.1 Mac OS X. Clearing the cache did not work for me.

仙女 2024-07-27 17:44:42

请注意 @property some 语法。 如果代码中不再存在对象某物,NetBeans 可能会在正确完成代码时出现问题。 考虑示例:

/** in main file: **/

use ABC as _ ;

/** in file ABC: **/

/** 
  *  @property \Something $something
  */

如果您不再使用 $something,NetBeans 很可能会生成异常,从而无法完成代码。

Be aware of @property something syntax. If object something does not exists in your code anymore, NetBeans might have problems with proper code completion. Consider example:

/** in main file: **/

use ABC as _ ;

/** in file ABC: **/

/** 
  *  @property \Something $something
  */

If you do not use $something anymore, NetBeans will most likely generate an exception, thus failing to complete the code.

凡间太子 2024-07-27 17:44:42

对我有用的是清除缓存,然后在全局包含路径中显式包含一些关键子目录。 似乎由于某种原因 NB 6.7 没有递归目录。

包括在项目层面也起作用
项目->属性->包含路径
Netbeans 7.01 + Windows 7

What worked for me was clearing the cache, then explicitly including some key subdirectories in the Global include path. Appears that for some reason NB 6.7 wasn't recursing the directories.

Including at project level also worked
Project->Properties->Include Path
Netbeans 7.01 + Windows 7

悲喜皆因你 2024-07-27 17:44:42

例如,如果您使用 netbeans 打开一个 php 文件而不是项目的一部分,则代码完成根本不起作用。 您需要做的是创建一个包含该文件的项目。

在 NetBeans 7.0.1 上测试过

If, for instance, you open a php file with netbeans without being part of a project, code completion doesn't work at all. What you need to do is to create a project having that file in it.

Tested this on NetBeans 7.0.1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文