Bug 269347 - No Code Assist launched after a dot operator.
Summary: No Code Assist launched after a dot operator.
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: PHP UI CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-19 08:17 EDT by Kalin CLA
Modified: 2020-05-14 10:16 EDT (History)
4 users (show)

See Also:


Attachments
screenshot (71.63 KB, image/jpeg)
2010-03-19 04:38 EDT, Kalin CLA
no flags Details
patch v1 (4.16 KB, patch)
2010-03-22 12:04 EDT, Jacek Pospychala CLA
no flags Details | Diff
patch v2 (46.89 KB, patch)
2010-03-25 09:34 EDT, Jacek Pospychala CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kalin CLA 2009-03-19 08:17:57 EDT
Have the next code in editor:

<?php
require_once dirname(__FILE__).|   //<-- Invoke code assist here (Ctrl+Space)


Expected:
CA should be launched.

Actual:
No completions available.

pdt-all-in-one-win32-2.1.0M5
Comment 1 Zhongwei Zhao CLA 2010-01-24 04:21:00 EST
Can you explain the Expected result,it is better to show some example.Thanks
Comment 2 Zhongwei Zhao CLA 2010-03-16 05:42:46 EDT
Hi,Kalin

Can you tell me the expected result or does this bug still exist?
Because i got the CA,but i am not sure if the result is right.
Comment 3 Kalin CLA 2010-03-19 04:38:00 EDT
Created attachment 162498 [details]
screenshot
Comment 4 Kalin CLA 2010-03-19 04:42:55 EDT
Hi Zhaozhongwei,
Sorry for my late answer!
The suggested items should be:
1. The php files/folders from the current project.
2. The php files/folders from projects which are in include path of the current project.

I attached a screenshot for better clarification.

Kalin
Comment 5 Zhongwei Zhao CLA 2010-03-19 11:47:29 EDT
Thanks very much!
Comment 6 Zhongwei Zhao CLA 2010-03-20 13:00:19 EDT
It seems now there are code assist after

require_once dirname(FILE).|

for example there is a folder named "abc",then choose this proposal,the result will be:
require_once dirname(FILE).abc/

but i think here should insert "abc/" or 'abc/' instead of abc/.
Comment 7 Jacek Pospychala CLA 2010-03-22 09:21:14 EDT
hi, I'm looking into this too.

I see that content assist works always when user types some special character and then waits a moment. It brings all file/dir proposals from current dir. User can type:

require_once .
require_once )
require_once WhatEverBlaBlaHelloZhaoKalinJacek)

and it always brings content assist.


However when I press Ctrl+Space, the content-assist  always has no proposals.
Comment 8 Jacek Pospychala CLA 2010-03-22 12:00:01 EDT
ok, the problem is that when pressing Ctrl+Space, context assist is explicitly requested by user. This automatically enables GlobalStatementContext (with variables and functions proposals).

Based on the cursor location, also IncludeStatementContext is added - this one serves file names. It's added both on Ctrl+Space and with automatic content assist.

So when pressing Ctrl+Space, two contexts are available. They're both exclusive so noone is used.
Comment 9 Jacek Pospychala CLA 2010-03-22 12:04:42 EDT
Created attachment 162687 [details]
patch v1

Obvious solution is to make context non-exclusive. With the patch applied, automatic content-assist contains ONLY files suggestions and when activated with Ctrl+Space it brings both file names and functions/variables/etc.

This also requires Global content assist strategies to support NULL in some cases to avoid NPEs.

The downside is that Ctrl+Space brings HUUGE list of vars and functions and the file names are somewhere at the bottom - practically impossible to find.
Comment 10 Jacek Pospychala CLA 2010-03-22 12:38:25 EDT
(In reply to comment #6)
> It seems now there are code assist after...

oh sorry, I missed this comment earlier and assumed it's open. Zhao, did you already make any changes to this bug? To which branch?
Comment 11 Jacek Pospychala CLA 2010-03-23 07:47:40 EDT
Looking further at this issue, I see that Ctrl+Space always works inside quotes, so problem happens only when using Ctrl+Space without quotes:

WORKS: (brings CA with file proposals)
require_once '|' // <-- invoke code assist here (Ctrl+Space)
require_once '|' // <-- wait for automatic code assist 
require_once | // <-- wait for automatic code assist
require_once .| // <-- wait for automatic code assist

DOESN'T WORK: (brings CA with NO proposals)
require_once |  // <-- invoke code assist here (Ctrl+Space)
require_once .|  // <-- invoke code assist here (Ctrl+Space)
Comment 12 Zhongwei Zhao CLA 2010-03-23 11:56:30 EDT
(In reply to comment #11)
> Looking further at this issue, I see that Ctrl+Space always works inside quotes,
> so problem happens only when using Ctrl+Space without quotes:
> 
> WORKS: (brings CA with file proposals)
> require_once '|' // <-- invoke code assist here (Ctrl+Space)
> require_once '|' // <-- wait for automatic code assist
> require_once | // <-- wait for automatic code assist
> require_once .| // <-- wait for automatic code assist
> 
> DOESN'T WORK: (brings CA with NO proposals)
> require_once |  // <-- invoke code assist here (Ctrl+Space)
> require_once .|  // <-- invoke code assist here (Ctrl+Space)


No,i did not upload any changes!Because I could not commit code now,and I have not create any patch for this bug!
Sorry for reply you so late,I will see you patch tomorrow:)
Comment 13 Roy Ganor CLA 2010-03-23 20:21:44 EDT
Hi Jacek,
Can we add the "." character as a trigger to content assist? this way we get this instantly from the engine?  Also can you explain what are the nullity checks are needed for?

Thanks!
Comment 14 Zhongwei Zhao CLA 2010-03-23 23:39:36 EDT
Hi,I just run you patch,it is really a HUUGE list:)
Comment 15 Jacek Pospychala CLA 2010-03-25 08:05:38 EDT
(In reply to comment #13)
> Can we add the "." character as a trigger to content assist? 

is already works that way.

> Also can you explain what are the nullity checks are needed for?

I've NPE's in those places when testing, however now I see all works fine without null checks.

(In reply to comment #14)
> Hi,I just run you patch,it is really a HUUGE list:)

yea, but that's in fact normal CA contents you get anywhere else..
I'd only bump-up files priority to be at the top of the list AND put them in quotes when CA is invoked outside quotes.

I'll improve this patch a bit to remove (or clarify why needed) null checks and bump-up files hints to the top of the list + add quotes arounr them.
Comment 16 Jacek Pospychala CLA 2010-03-25 09:34:59 EDT
Created attachment 162987 [details]
patch v2

Improved patch:
- ICompletionReporter: Added reportResource(...) method with new prefix argument. To be able to provide proposals with quotes.
- PHPCompletionEngine: Hook old reportResource(...) method (without prefix arg) to use new reportResource(...) method with empty prefix by default
- GlobalStatementContext and IncludeStatementContext - same as previously. Just disable Exclusive mode
- IncludePathStrategy: detect if we're inside quote or not and produce proposals with(out) quotes accordingly

Null checks removed -I didn't hit them anymore.