26

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

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Kris
  • 40,604
  • 9
  • 72
  • 101

5 Answers5

42

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.

Community
  • 1
  • 1
dr Hannibal Lecter
  • 6,665
  • 4
  • 33
  • 42
  • 2
    I was _really_ hesistant to try this, but it did actually fix the problem. (rm -rf'ing the cache) – Kris May 17 '09 at 16:04
  • Kewl, now I know what to do if this ever happens to me :) Strange that it happened at all... – dr Hannibal Lecter May 17 '09 at 17:59
  • I've got a similar problem, in that the project only seems to be scanned when netbeans starts, so code completion doesn't work for variables/methods that were defined in this coding session. (The code navigator knows about though). Unfortunately deleting my netbeans home directory hasn't fixed this. For reference, this is on: NetBeans IDE 6.7 (Build 200906241340), Java: 1.6.0_14; Java HotSpot(TM) 64-Bit Server VM 14.0-b16, System: Linux version 2.6.28-14-generic running on amd64; UTF-8; en_GB (nb) – John Carter Jul 29 '09 at 14:36
  • I've worked out a trigger for the bug I'm seeing - it's something to do with adding folders to the PHP include path within netbeans. If I add the project root to the path (actually duplicating what's set in the include_path), then I get code completion for stuff from my other projects, but it won't update without a restart. If I don't add it then I only get code completion for the current project, but it will update for new code. Frustrating! – John Carter Jul 29 '09 at 14:59
  • 1
    had some odd issues with code completion in NB6.8 for python. Clearing the cache solved my problems. – David Jan 16 '10 at 15:54
  • 1
    Worked beautifully with 7.2 when my "hints" suddenly went away. On Linux I did cd ~/.cache/netbeans/ ; tar cvfz backup.tgz ./7.2.1; rm -rf 7.2.1. My project is rather large so I had to wait about 10-12 minutes for the background scan to complete, but once it finished the previously missing auto-complete was back in action! Thanks! – Lance Cleveland Mar 07 '13 at 19:21
  • code completion went bizzare on my java project after I combined two projects to one... rm -r the cache (7.3) solved it like a charm. thanks. – Dror Cohen Jan 13 '14 at 08:03
  • Im at 8.0 and Ubuntun 14.04LTS NB says`no suggestion` for built-in PHP functions. any clue what's going on? – Junaid Qadir Shekhanzai May 18 '14 at 19:09
  • 1
    @JeyKeu: Sorry mate, no idea, I'm still on 10.10... Could it be a packaging issue? Have you tried a non-repo version (or vice versa if it is a repo version)? – dr Hannibal Lecter May 19 '14 at 12:03
  • It's 8.0 release version – Junaid Qadir Shekhanzai May 19 '14 at 12:11
  • This helped me on Netbeans 8.1 on Windows. BTW you can always find the actual cache path in menu: Help -> About. – volvpavl Sep 28 '17 at 08:22
2

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

Community
  • 1
  • 1
Jonathan Hendler
  • 1,239
  • 1
  • 17
  • 23
2

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.

Jonathan
  • 315
  • 3
  • 8
  • I haven't run into the same problem since netbeans 7.0 (though code completion can still be flaky from time to time) – Kris Aug 31 '11 at 06:24
2

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.

Kristoffer Sall-Storgaard
  • 10,576
  • 5
  • 36
  • 46
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