NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
[resolved] Code completion seems broken


Joined: 27 Aug 2008
Posts: 25
Reply with quote
Hi All,

Just wondering if others are having the same issues as I am.

I have come across this a few times now with different code bases - but code completion / type hinting does not always work - when it used to in PhpEd 6.*

I have a project (wordpress) and I am getting the error:

Code:
Code completion is not available due to the following error(s):
Failed to find "wpdb"class


I also had this error on my own Database encapsulation class when there was no PHP Doc. Once I added PHP doc code completion (drop down list of functions) started to work - but only if I had the file open in the editor.
The common factor here is that in this project workspace I also wordpress and a whole bunch of plugins. If required I can provide a list of plugins that we are using.

I am using V7.0 b7019

My Programmer spidey senses are telling me this is something to do with the code parser bailing out when it cannot figure something out instead of handling the error gracefully and continuing.
View user's profileFind all posts by BoxieSend private message


Joined: 27 Aug 2008
Posts: 25
Reply with quote
that'd be right - I should have checked if I was running the latest version of PhpEd *before* I posted.

I am downloading v7.0 b7021 which the changelog says fixes this problem.
View user's profileFind all posts by BoxieSend private message


Joined: 27 Aug 2008
Posts: 25
Reply with quote
Well, I have installed the latest and greatest v7.0 b 7021 version of PhpEd and there is still a problem with code completion and my wordpress install.

With just my theme file (sidebar.php) open, and the following code I get the following error:

Code:
Code completion is not available due to the following error(s):
Failed to find class of "$wpdb" member, (recognized as "wpdb" class)


Code:
function test_code_completion() {
   global $wpdb;
   
   $wpdb->get_results()
}


The problem disappears when I open the wp-includes/wp-db.php file (the one that has the class) and explicitly specify the variable type

Code:
function test_code_completion() {
   /** @var wpdb */
   global $wpdb;
   
   $wpdb->get_results()
}


It appears that PhpEd also caches these results, as once it have figured out the type it remembers it.

now this could just be a wordpress thing and phped has a hard time trying to figure out what is going on, but it would be nice if it all just worked out of the box Smile
View user's profileFind all posts by BoxieSend private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
That's strange, because I'm on 7021 and just opened a WordPress site that I haven't opened in 7.x before, I closed all files, stuck this into a new unsaved file:

Code:
<?php
  function test_code_completion() {
   global $wpdb;
   
   $wpdb->
   }


and code completion works, automatically listed the methods as I type including get_results(). I also did save/close, re-opened and did ctrl+space after the $wpdb-> and it listed all the methods.
View user's profileFind all posts by plugnplaySend private message


Joined: 11 May 2008
Posts: 78
Reply with quote
I concur with this one.
7019, the code above triggers autocompletion/code insight, with get_results() contained in, just right.
Maybe you try to reindex the whole project?
There is another topic on this same problem just few topics away in the forum.
View user's profileFind all posts by tedychSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Indeed 7019 had problems with refreshing Code Insight DB, as a result some (or even all) classes would not be found. It has been fixed in 7020.
But, no build would find your class if corresponding source file is not in your project tree. In other words, if you work with WordPress classes, you have to include WP directory as "Additional" project directory or make sure the sources are somewhere insight the project root directory tree. As soon as you add it either way, it will appear in Code Explorer tab, and Code Comletion dropdown will show it and its members too.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 11 May 2008
Posts: 78
Reply with quote
dmitri wrote:
Indeed 7019 had problems with refreshing Code Insight DB, as a result some (or even all) classes would not be found.

Is this only when upgrading from a previous version, or even after a totally clean install and indexing of projects?
View user's profileFind all posts by tedychSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
It is a problem of 7019. What's unclear?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 11 May 2008
Posts: 78
Reply with quote
I have written what's unclear. Just read again. For my testing clean, fresh install, I have not been witnessing this classes not found problem you talk about, that's why I was curious if this manifests itself only when upgrading. Anyway, thanks for your support.
View user's profileFind all posts by tedychSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
I didn't say that 7019 was 100% broken otherwise we'd notice this before the release and would stopped it. I mean it didn't re-index in <b>some</b> cases. If it did re-index for you, it's just fine. But it didn't work for some other customers regrdless how they installed - after v6 or clean. We released 7021 to fix this problem.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
[resolved] Code completion seems broken
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic