At runtime the functions and classes defined in the wp-includes directory are available to the scripts in the /themes and /plugins directories without an explicit require or include. I don’t even know where most of the functions I regularly invoke are located.
I’ve tried a couple of things to make Code Intelligence work. First, I tried setting my project’s base directory to the /wordpress directory. Second, I tried adding a local version of wordpress to Languages|PHP|PHP directories in preferences. Neither had any effect.
Is it possible to make Code Intelligence work for Wordpress development?
Hi, when I created a project in a stock WP directory, Komodo prompted me to scan all files in the WP directory. However, for whatever reason the directory depth was set to 0 by default. I changed this to 10 and asked Komodo to go ahead and scan. Komodo then spent the next 10 minutes scanning. After the scan completed, I opened “wp-content/index.php” and started typing “wp”. Eventually Komodo gave completions including “wp_clone”, “wp_cron”, etc. This indicates to me that codeintel is working for WP.
I’m guessing the default depth of 0 for you is causing the problem. Try reseting your codeintel DB (Help > Troubleshooting > Reset CodeIntel DB) and changing the depth in the scan prompt to 10. See if that helps.
I did have Code Intel at depth 10. I have attached some screen shots showing that Code Intelligence is working for a local function, but not for Wordpress functions. I placed this file exactly where you did. I created a project in the top Wordpress directory, and it did scan the Wordpress directories. I thought maybe the problem was that I hadn’t selected Wordpress as the framework when I created the previous project (What does this do?) but this time I did select Wordpress.
When I look at the error log, I see a bunch of errors like this:
[2017-11-20 17:43:23,272] [ERROR] console-logger: TypeError: data is null (2) in chrome://codeintel/content/sdk/feature/completions.js:129
Traceback (most recent call last):
File “chrome://codeintel/content/sdk/feature/completions.js”, line 129, in
I was on 11.0.0. After seeing this, I upgraded to 11.0.1 last night. Before Code Intelligence at least worked for local functions. Now it seems almost useless. In the above file, if I type ‘hell’ it does after maybe three seconds show suggested completions including the local function. If I select or click the function it completes ‘hello’, but oddly does not add parentheses. I would expect the result to be ‘hello()’ with the cursor inside the brackets and the function parameters shown in the calltip. I do have ‘Show completions while typing’, ‘Show completions that fully match the query’ and ‘Show calltips while typing’ all checked in preferences.
If I type ‘wp_’, after 4 or 5 seconds some completions do pop up, but no calltip for the function I select appears and if I right click to go to definition, it just says "Could not find definition’.
So right now it seems like Code Intelligence is very slow, and basically useless. Maybe this is better as a bug report?
It does work with PHP, but not with “additional libraries/directories”, so to speak. Scanning depth is 10. Could this have something to do with the fact that the “sources” I’m editing is via SFTP (i.e. “remote”)? But then, OTOH, the “sources” is a WordPress installation, so then it should have scanned it on the remote if it doesn’t do it locally.
Well, it’s a shame that it doesn’t work anyway, it would really help to have CI on the specified paths.
@joho68, so the remote directory is mounted locally through your OS? What makes them “local”?
When I refer to remote files in the context of Komodo I mean either File menu > Open > Remote File or Places pane > Gear icon > Open Remote Directory.
If you’ve opened them in Komodo using either of those two methods then CI will not work.
If you mounted the dir locally through your OS then I’m not 100% sure what will happen without double checking the code. If it IS scanning it could take a VERY long time. Wordpress is huge and CI would be greatly hampered not having the files on the local hard drive. I do know that Komodo has a few tricks on how it determines if a file is local or not and it could determine that it’s just a mounted remote dir and still not scan it.
I have specified a local directory (/home/user/dev/wordpress) in the Komodo IDE setup for PHP. It’s an “empty” WordPress site/directory, freshly unpacked from the WordPress distribution archive. It’s not a “mounted remote” directory made to look “local”, it actually is local
I edit the project via Open Remote Directory, and there I edit code. And I was expecting Komodo IDE to scan the local directory/directories specified for PHP for anything PHP.
But it sounds like #2 could be the problem, and that it’s possibly telling Komodo IDE to simply ignore all local directories?
@joho68, thanks for clarifying. Code Intel is disabled with remote files, so no, this setup won’t work. I’m confident that no IDE supports this. The performance hit would render the feature useless I believe.
To answer your question from before: Komodo WILL scan the Wordpress you installed locally that you specified in the PHP Prefs.
If you don’t mind a little pedantic feedback, this doesn’t sound like a very safe setup. You should have a local checkout of your code, make changes local and test then push those changes to the remote server either through source code control our Komodo’s publishing tool. You generally shouldn’t be editing the remote files directly. I break that rule all the time with small applications but I’d be very hesitant to edit a Wordpress site live. </unsolicited feedback>
You’re probably right on both accounts (well, I know you’re right on the second issue ) The remote installation is actually easier to develop with because it has all the metrics monitoring tools in place and it gives me a better way to test real-time delays, loss of connectivity, etc. In other words, it’s a more realistic working environment. When I’m done, I clean up, gitify it and commit The WordPress site is a lab site. It’s just a remote lab site.
OK, but as far as CI being disabled on remote files, it does show CI for PHP core functions, but I guess they are somehow bundled then. Considering how popular WordPress is (for better or for worse #LOL), it’d be nice if there was some way to get this working too.
That sounds pretty awesome, and yeah, if it’s not a live/production site that sounds like a great env to work in then.
I might actually be wrong here. If it works for the built-ins I’m not sure why it wouldn’t work for scanned code. Now that I look back up the thread I don’t see a bug report so this might have been sitting idle this whole time and unfortunately it’s not something I can put time aside for investigating.
I’m sorry this wasn’t a helpful thread and it took me so long to get to that!