Some of my defined classes are not loaded by the IDE when I call Ctrl+B, Go to declaration, Ctrl+click.
I'm using Windows 7, NetBeans, PHP 7.0.1
My classes are defined under <project-root>/foloder00/folder01/folder02/MyClass.php
I call MyClass
<project-root>/index.php
Do you know what the problem is? And the workaround?
As suggested by Nam, it is cache related. So another approach could be to delete the cache:
- Close NetBeans
- Delete cache folder (by default, on Linux it is located in
/home/USER/.cache/netbeans
) - Open the project and wait for the
scanning project
task to finish.
Deleting the Netbeans cache and letting Netbeans rebuild the cache after start fixes the 'go to declaration' issue, as suggested by others.
On Windows 7 with Netbeans 8.0 the path to the cache is
c:\Users{username}\AppData\Local\NetBeans\Cache\
I found a workaround for myself. Share with you in case you might need it like me.
Project Property - Include Path - Add the location of the containing folder where it doesn't work/isn't loaded.
Cheers
For linux users:
Delete cache:
- rm -fR /home/user/.cache/netbeans_vesion
Restart netbeans
Go to Tools->Options-> click on PHP Icon on top -> General tab -> find "Global include path" -> Add Folder ->
if(onLinux) { choose /var/www; } if(onWindows) { choose c:\path_to_htdocs or whatever; }
Ah, too much programming for today.. :)
For me, this repaired autocompletion and ctrl+click on method call.
I had the same problem with Netbeans 8.0.2.
Clearing the cache had no effect then I noticed the syntax coloring was not working either. The issue was the abbreviated comment tag was not recognized <?
and when I changed it to <?php
then syntax coloring and Ctrl-B worked again.
If You working with Drupal in NetBeans and have the same ctrl+click (Go to declaration) issue:
- Add/associate *.module, *.inc extensions as text/x-php5 files (NetBeans > Options > Miscellaneous > Files).
- Close NetBeans.
- Clear NetBeans cache (as described above).
- Open the project and wait for the scanning project task to finish.
I resolved this issue deleting the nbproject directory on my project.
After deleteting this directory, just restart your ide. It'll start going to declarations, functions and classes again.
In windows system, we cannot see the AppData folder directly. So we need to browse the below given path to delete the Netbeans cache: C:\Users{username}\AppData\Local\NetBeans Delete the cache folder. If it still doesn't work then delete the sub-folders inside C:\Users{username}\AppData\Roaming\NetBeans\8.2\var Then reopen your netbeans and let it scan projects.
I encountered the same problem on Mac, I solved it by deleting netbeans cache directory:
- Close netbeans, Find and delete Cache directory of netbeans, it will solve your problem:
- Replace '7.1.2' with your installed version of Netbeans, in directory paths given below.
MAC:
Remove following directory:
~/.netbeans/7.1.2/var/cache/
command:rm -rf ~/.netbeans/7.1.2/var/cache/
Windows XP:
Remove following directory:
C:\Documents and Settings\(user)\.netbeans\7.1.2\var\cache
Windows Vista / 7:
Remove following directory:
C:\Users\(user)\.netbeans\7.1.2\var\cache
Linux:
Remove following directory:
.netbeans/7.1.2/var/cache
For me Ctrl + Click does not work when I choose 'Put NetBeans metadata into a separate directory' when doing PHP in Netbeans 7.3.1 on Ubuntu
I had the same problem on ubuntu 16.04 and I solved it doing what was written here
- Edit
netbeans.conf
(on Ubuntu 16.04/etc/netbeans.conf
) - Add the
--cp:p /usr/share/java/jcodings.jar
tonetbeans_default_options
I had the same problem and resolved by installing JRE
http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
For me, deleting the Cache didn't work. Deleting and recreating the project did.
For what it's worth, my Cache directory lives here:
C:\Users\{username}\AppData\Local\NetBeans\Cache
I'm using NetBeans 8.1 in Windows 7.
For me, deleting the Cache folder did not work.
Then i realized that the source files that i have opened in NetBeans, were not included as part of a project. So i went ahead and selected: File > Open Project > chose the original project folder in my htdocs (XAMPP).
Then the declaration mapping worked like a charm. Hope it helps someone out there.
I got the same issue in Netbeans 11.0. My OS is Ubuntu 18.04. I solved the issue by clearing the cache of netbeans. Cache path of Netbeans 11 is
/home/USER/snap/netbeans/common/cache/11.0
Go to Tools->Options-> click on PHP Icon on top -> General tab -> find "Global include path" -> Add Folder -> .
This worked for me on netbeans 11
also
来源:https://stackoverflow.com/questions/8369807/go-to-declaration-does-not-work-in-netbeans-php