NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Remove duplicate items in code completion


Joined: 30 May 2006
Posts: 92
Reply with quote
Hi,

please would it be possible to remove duplicate items in dropdown autocompletion list - screen bellow:



It often happens, that classes inherit properties and this dropdown shows all duplicates, sometime 2-3-4 identical items.
Each item however results into adding same code.
Duplicity thus makes dropdown list sometime very long and takes place away from other needed items - one must scroll down & look for them ..

Thank you.
Lubos
View user's profileFind all posts by lubosdzSend private message


Joined: 31 Jul 2019
Posts: 1
Location: United States
Reply with quote
Use this method:

function uniques(array: any[], key: string) {
return array.reduce((acc, curr) => {
if (!acc.find(item => item[key] === curr[key])) { acc.push(curr); }
return acc;
}, []);
}
View user's profileFind all posts by susanburlingSend private message


Joined: 30 May 2006
Posts: 92
Reply with quote
susanburling wrote:
Use this method:

function uniques(array: any[], key: string) {
return array.reduce((acc, curr) => {
if (!acc.find(item => item[key] === curr[key])) { acc.push(curr); }
return acc;
}, []);
}


Hi,

what do you mean?
Where should I put it?
Somewhere into PhpEd?
I am not C++ programmer ... dont want to end up hacking IDE Smile

Thanx
Lubos
View user's profileFind all posts by lubosdzSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Lubos, duplicates should not be in the code completion popup. Еry to refresh Code Explorer, then wait until parse finished its work and corresponding icon disappeared from the status bar.
If duplicates are still shown after that, please create a sample that will reproduce the duplicates and open ticket for support. In reply to our email you'll attach the sources. Please pack them using zip or rar.

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


Joined: 30 May 2006
Posts: 92
Reply with quote
Hi Dmitri,

thanx for response.
After refreshing include parser duplicates are still there.
I did small demo and figured out, that duplicates are caused by different namespaces - screen bellow:



Technically it's not error, but when all objects refer to the same inherited property, it's useless to show such duplicates.

I am not sure if I should open ticket ..

Demo ZIP files can be downloaded from https: //uloz.to/file/pjRTCmmdpQA9/nusphere-dups-zip.
View user's profileFind all posts by lubosdzSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Sorry, but your URL brings up a page with links to several archives, including v5.6 of PhpED with serial number. Is it what you wanted to show me? Really?

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


Joined: 30 May 2006
Posts: 92
Reply with quote
Not sure what you see, but the link should be correct (checked now) - just remove spacing inside https: and double slash //.
You should see "nusphere-dups.zip" title then just click violet button "Fast download" (switch to english at the top).
There are 4 files + screenshot / 35 kb, created today in PhpEd build 19026 / PHP 7.1.

Actually here is demo:

File ApplicationBase:

Quote:
namespace app\base;

class Application
{
public $request;
}



File ApplicationConsole:

Quote:
namespace app\console;

if(!class_exists('\app\base\Application', false)){
require __DIR__ .'/ApplicationBase.php';
}

class Application extends \app\base\Application
{
public $request;
}



File ApplicationWeb:

Quote:
namespace app\web;

if(!class_exists('\app\console\Application', false)){
require __DIR__ .'/ApplicationConsole.php';
}

class Application extends \app\console\Application
{
public $request;
}



File index.php:


Quote:
require __DIR__ .'/ApplicationWeb.php';

class ClassAAA
{
/**
* @var \app\web\Application|\app\console\Application|\app\base\Application The application instance
*/
public static $app;
}

/*
* code completion lists 3x the "request" property
* This is due to 3 different namespaces, which all extend from inherited public property "request"
* Technically it's not an error, but practically it's useless, because all objects refer to the same property
* and choosing any of them will also insert same string "request".
*/
$request = ClassAAA::$app->request; // <== here will show 3x "Application"

View user's profileFind all posts by lubosdzSend private message
Remove duplicate items in code completion
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