Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323595

Summary: Content Assist does not suggest '::' for constants of a class
Product: z_Archived Reporter: Petyo Tanchev <petyo_tanchev>
Component: PDTAssignee: Zhongwei Zhao <zhaozhongwei>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: ganoro, qiangsheng.w, silviya, zhaozhongwei
Version: unspecifiedFlags: zhaozhongwei: review? (ganoro)
qiangsheng.w: review+
zhaozhongwei: review? (zhaozhongwei)
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
patch none

Description Petyo Tanchev CLA 2010-08-25 07:52:35 EDT
Use code like this:

<?php
class  CCC{
	const xxx = 2;
}

CCC|

Calling the Content Assist at | does nothing. If you type '::' then it suggests 'xxx'.

Expected:
To suggest/add '::xxx'

CCC::xxx


If there is a static member also, then the '::' is added automatically and a suggestion for both the static member and the constant is shown.
Comment 1 Zhongwei Zhao CLA 2010-08-25 08:25:56 EDT
fixed in head and branch
Comment 2 Roy Ganor CLA 2010-08-25 09:33:29 EDT
I am not sure I understand this request (enhancement?).
Eclipse doesn't usually suggest things like this. for example the following scenario doesn't behave as you mentioned and it is ok.

class A { function foo() )
$a = new A();
$a|

we don't complete the "->foo()" as "->" is a trigger that must be specified by the user.

Am I missing something?
Comment 3 Zhongwei Zhao CLA 2010-08-25 09:39:27 EDT
(In reply to comment #2)
> I am not sure I understand this request (enhancement?).
> Eclipse doesn't usually suggest things like this. for example the following
> scenario doesn't behave as you mentioned and it is ok.
> 
> class A { function foo() )
> $a = new A();
> $a|
> 
> we don't complete the "->foo()" as "->" is a trigger that must be specified by
> the user.
> 
> Am I missing something?

sure,for me it is wired,but it exists for a long time from I use pdt,so I have no idea about this.
Comment 4 Zhongwei Zhao CLA 2010-08-25 09:43:17 EDT
and now we have to made much extra effort to judge if we should add "::".
Comment 5 Sylvia Tancheva CLA 2010-08-25 10:15:30 EDT
The issue is that if you have a static member for example and you type
CCC| <- ctrl+space
you will get automatically 
CCC::<the_static_member>
This works both for static fields and methods, but not for constants, even though they share the same syntax.

In the given by Petyo example when typing
CCC| <- ctrl+space
you get nothing.
But if you add to the code a static member for example:
class  CCC{
    const xxx = 2;
    static $yyy;
}
and you type again
CCC| <- ctrl+space
then :: are added automatically and xxx and $yyy are suggested.

So it seems that if you have only constants it is a kind of exception from the rule.

Anyway it is minor bug.
Comment 6 Zhongwei Zhao CLA 2010-08-25 10:19:24 EDT
(In reply to comment #5)
> The issue is that if you have a static member for example and you type
> CCC| <- ctrl+space
> you will get automatically 
> CCC::<the_static_member>
> This works both for static fields and methods, but not for constants, even
> though they share the same syntax.
> 
> In the given by Petyo example when typing
> CCC| <- ctrl+space
> you get nothing.
> But if you add to the code a static member for example:
> class  CCC{
>     const xxx = 2;
>     static $yyy;
> }
> and you type again
> CCC| <- ctrl+space
> then :: are added automatically and xxx and $yyy are suggested.
> 
> So it seems that if you have only constants it is a kind of exception from the
> rule.
> 
> Anyway it is minor bug.

Thanks,and I have fixed the minor bug,because it is easy to fix,hehe!
But it seems that Roy does not like the way of adding "::".
Comment 7 Roy Ganor CLA 2010-08-25 10:31:30 EDT
;)

well, I just think it's a minor issue and not sure if it's a slick behavior.
anyway if it's the current behavior let's keep it as is.

thanks for explaining this
Comment 8 Petyo Tanchev CLA 2010-09-01 02:47:55 EDT
Tested on 2.2.1.v20100829
Reproduced again.
Comment 9 Zhongwei Zhao CLA 2010-09-03 19:58:49 EDT
Created attachment 178205 [details]
patch
Comment 10 Zhongwei Zhao CLA 2010-09-06 01:21:40 EDT
fixe
Comment 11 Petyo Tanchev CLA 2010-10-06 09:04:44 EDT
Tested on 2.2.1.v20101001
Fixed