Bug 536998 - Bad autocompletion in anonymous functions
Summary: Bad autocompletion in anonymous functions
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-13 04:21 EDT by Thomas Lallement CLA
Modified: 2020-05-14 11:24 EDT (History)
1 user (show)

See Also:


Attachments
Auto completion works (218.79 KB, image/png)
2018-07-13 04:21 EDT, Thomas Lallement CLA
no flags Details
Alternative auto completion works (155.05 KB, image/png)
2018-07-13 04:21 EDT, Thomas Lallement CLA
no flags Details
Auto completion doesn't works (in anonymous function) (110.26 KB, image/png)
2018-07-13 04:22 EDT, Thomas Lallement CLA
no flags Details
Installed Software (210.78 KB, image/png)
2018-07-19 02:49 EDT, Thomas Lallement CLA
no flags Details
Error after fresh install (Eclipse IDE for PHP Developers 4.8.0) (15.16 KB, text/x-log)
2018-07-19 04:03 EDT, Thomas Lallement CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Lallement CLA 2018-07-13 04:21:14 EDT
Created attachment 274963 [details]
Auto completion works

I have a strange behavior because the completion works when I write:

$fieldDefinition->getRuleDefinition()->|

But not if I write:

$ruleDefinition = $fieldDefinition->getRuleDefinition();
$ruleDefinition->|

But it's only the case when those statements are in an anonymous function.

Do you know what could be wrong?
Comment 1 Thomas Lallement CLA 2018-07-13 04:21:40 EDT
Created attachment 274964 [details]
Alternative auto completion works
Comment 2 Thomas Lallement CLA 2018-07-13 04:22:19 EDT
Created attachment 274965 [details]
Auto completion doesn't works (in anonymous function)
Comment 3 Dawid Pakula CLA 2018-07-13 06:15:15 EDT
Could you provide working example? zipped project or couple PHP classes? 

I'm afraid this can be another design error (similar to traits madness :P) :/
Comment 4 Thomas Lallement CLA 2018-07-13 12:07:19 EDT
I will try to do it next week.
Comment 5 Thomas Lallement CLA 2018-07-18 04:05:38 EDT
Please find here a very simple example that reproduce the issue:

http://sandbox.onlinephpfunctions.com/code/6acfcb1148c21ba637a36eea821e8ed830388cf5

In this case we don't have auto completion on the $formDefinition object in $configCallback anonymous function:

$formDefinition->| <- No default proposal

Note that when we replace:

public function configureFields()
{
    $configCallback = function ()
    {
        $formDefinition = new FormDefinition();

        return $formDefinition->getFields();
    };

    return [
        'fields' => $configCallback,
    ];
}

With:

public function configureFields()
{
    return [
        'fields' => function ()
        {
            $formDefinition = new FormDefinition();
                
            return $formDefinition->getFields();
        },
    ];
}

$formDefinition->| <- getFields() // Works as expected

http://sandbox.onlinephpfunctions.com/code/cdf6f9d422405ad9e868e6f087bc426a57ba60d1
Comment 6 Dawid Pakula CLA 2018-07-18 06:31:48 EDT
With this example forks fine for me in both cases :/ Even if I split into file per-class.

Have you something in logs?
Comment 7 Thomas Lallement CLA 2018-07-18 11:32:25 EDT
I just have this:

!ENTRY org.eclipse.equinox.p2.metadata.repository 2 0 2018-07-18 16:29:41.061
!MESSAGE Error parsing metadata repository
!SUBENTRY 1 org.eclipse.equinox.p2.core 2 0 2018-07-18 16:29:41.061
!MESSAGE Error in file:/home/lallement/opt/eclipse-photon/p2/org.eclipse.equinox.p2.repository/cache/content321157045.jar at line 46, column 62: Missing required attribute in "property": value
!SUBENTRY 1 org.eclipse.equinox.p2.core 2 0 2018-07-18 16:29:41.061
!MESSAGE Error in file:/home/lallement/opt/eclipse-photon/p2/org.eclipse.equinox.p2.repository/cache/content321157045.jar at line 611, column 62: Missing required attribute in "property": value
!SUBENTRY 1 org.eclipse.equinox.p2.core 2 0 2018-07-18 16:29:41.061
!MESSAGE Error in file:/home/lallement/opt/eclipse-photon/p2/org.eclipse.equinox.p2.repository/cache/content321157045.jar at line 1051, column 62: Missing required attribute in "property": value
!SUBENTRY 1 org.eclipse.equinox.p2.core 2 0 2018-07-18 16:29:41.061
!MESSAGE Error in file:/home/lallement/opt/eclipse-photon/p2/org.eclipse.equinox.p2.repository/cache/content321157045.jar at line 1065, column 62: Missing required attribute in "property": value
!SUBENTRY 1 org.eclipse.equinox.p2.core 2 0 2018-07-18 16:29:41.061
!MESSAGE Error in file:/home/lallement/opt/eclipse-photon/p2/org.eclipse.equinox.p2.repository/cache/content321157045.jar at line 2441, column 62: Missing required attribute in "property": value
!SUBENTRY 1 org.eclipse.equinox.p2.core 2 0 2018-07-18 16:29:41.061
!MESSAGE Error in file:/home/lallement/opt/eclipse-photon/p2/org.eclipse.equinox.p2.repository/cache/content321157045.jar at line 2657, column 62: Missing required attribute in "property": value
!SUBENTRY 1 org.eclipse.equinox.p2.core 2 0 2018-07-18 16:29:41.061
!MESSAGE Error in file:/home/lallement/opt/eclipse-photon/p2/org.eclipse.equinox.p2.repository/cache/content321157045.jar at line 3951, column 62: Missing required attribute in "property": value

!ENTRY org.eclipse.jface 2 0 2018-07-18 16:39:17.772
!MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2018-07-18 16:39:17.772
!MESSAGE A conflict occurred for CTRL+SHIFT+N:
Binding(CTRL+SHIFT+N,
	ParameterizedCommand(Command(org.eclipse.jdt.debug.ui.commands.AllInstances,All Instances,
		View all instances of the selected type loaded in the target VM,
		Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true),
		org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@2347ca7a,
		,,true),null),
	org.eclipse.ui.defaultAcceleratorConfiguration,
	org.eclipse.ui.contexts.window,,,system)
Binding(CTRL+SHIFT+N,
	ParameterizedCommand(Command(org.pdtextensions.core.ui.command.phpcsfixer,Run PHP-CS-Fixer,
		Run PHP-CS-Fixer on files and folders,
		Category(org.eclipse.core.commands.categories.autogenerated,Uncategorized,Commands that were either auto-generated or have no category,true),
		org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@5b7bd551,
		,,true),null),
	org.eclipse.ui.defaultAcceleratorConfiguration,
	org.eclipse.php.core.phpsource,,,system)
Binding(CTRL+SHIFT+N,
	ParameterizedCommand(Command(org.eclipse.php.debug.ui.commands.InspectDelegate,Inspect,
		Inspect result of evaluating selected text,
		Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true),
		org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@54c543a5,
		,,true),null),
	org.eclipse.ui.defaultAcceleratorConfiguration,
	org.eclipse.php.ui.phpEditorScope,,,system)
Comment 8 Thomas Lallement CLA 2018-07-19 02:49:23 EDT
Created attachment 275040 [details]
Installed Software
Comment 9 Thomas Lallement CLA 2018-07-19 03:03:20 EDT
It's a bit strange because when I check for available updates this morning, Eclipse show me: PDT 6.0.0.20180612250.

But I already have the release 6.1.0.201807152250
Comment 10 Thomas Lallement CLA 2018-07-19 04:03:12 EDT
Created attachment 275042 [details]
Error after fresh install (Eclipse IDE for PHP Developers 4.8.0)
Comment 11 Dawid Pakula CLA 2018-07-19 04:11:34 EDT
(In reply to Thomas Lallement from comment #10)
> Created attachment 275042 [details]
> Error after fresh install (Eclipse IDE for PHP Developers 4.8.0)

You can ignore this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=535954 ;)
Comment 12 Thomas Lallement CLA 2018-07-19 04:18:44 EDT
Ok so I see nothing special but the auto completion doesn't works for me with the fresh install.
Comment 13 Dawid Pakula CLA 2018-07-19 10:34:59 EDT
OK I see this now. You shared working version ;)
Comment 15 Eclipse Genie CLA 2018-07-19 11:49:24 EDT
New Gerrit change created: https://git.eclipse.org/r/126335
Comment 17 Thomas Lallement CLA 2018-07-20 07:46:58 EDT
Thanks. It works like a charm!