Bug 169954 - [content assist][api] provide better access to ContentAssistant
Summary: [content assist][api] provide better access to ContentAssistant
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.2.1   Edit
Hardware: All All
: P3 enhancement with 3 votes (vote)
Target Milestone: 3.4 M1   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed, helpwanted
Depends on:
Blocks:
 
Reported: 2007-01-09 06:35 EST by Guy Gurfinkel CLA
Modified: 2007-07-30 06:26 EDT (History)
1 user (show)

See Also:


Attachments
patch allowing subclassing and replacing the AutoAssistListener (2.07 KB, text/plain)
2007-06-20 02:47 EDT, Guy Gurfinkel CLA
no flags Details
patch allowing subclassing and replacing the AutoAssistListener (2.56 KB, text/plain)
2007-06-20 09:58 EDT, Guy Gurfinkel CLA
no flags Details
patch with fixes (3.26 KB, text/plain)
2007-06-21 03:36 EDT, Guy Gurfinkel CLA
no flags Details
update documentation (3.72 KB, text/plain)
2007-06-21 06:50 EDT, Guy Gurfinkel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Guy Gurfinkel CLA 2007-01-09 06:35:58 EST
Hi,
I am a committer for the PDT project. 
As a Java developer, I always missed the automatic content assist triggered by any character, and not only by the '.' or any other configurable list of characters. 
for example, if the user types the following:
class MyClass extends | 
(the "|" is the carret position)
in other words if the user put a space after the word "extend" a list of classes to override will automatically pop up.

Lately, we received several similar requests from the PDT users about the content assist. This can only emphasise the need for this feature. 

I saw that in bug #101420 someone asked for a similar feature, but I guess my request is simpler.
I'm willing to implement it myself as a patch if you will approve it as a necessary feature (and assuming you are not working on something like this currently).

Thanks,
Guy
Comment 1 Dani Megert CLA 2007-01-09 07:21:43 EST

*** This bug has been marked as a duplicate of bug 159157 ***
Comment 2 Guy Gurfinkel CLA 2007-01-09 08:06:11 EST
Our suggestions are different, he asks to expend the triggers range, and I think we need to extend the mechanism and give the processors the option to be activated regardless to the user typing.
I also think we should integrate the solution inside org.eclipse.jface.text.contentassist.ContentAssistant
and not as an external plugin. 
Comment 3 Dani Megert CLA 2007-01-09 08:26:28 EST
>Our suggestions are different
I know it's a little bit different but it goes into the same direction and thought this might be enough for you. There are no plans to put a general trigger mechanism into content assist as this would affect typing performance considerably. Feel free to subclass content assistant and provide this feature in your editor.

>I also think we should integrate the solution inside
>org.eclipse.jface.text.contentassist.ContentAssistant
>and not as an external plugin. 
Sure. That's why the other bug is still open.
Comment 4 Guy Gurfinkel CLA 2007-01-09 09:19:00 EST
The problem is that I can't access some important data members like fContentAssistSubjectControlAdapter for instance since they are private (and its Type ContentAssistSubjectControlAdapter is package).

Any chance you could change some of those members and types in order to make it more available for subclassing.
(I'll send the full list of members and types I need if you agree).
Comment 5 Dani Megert CLA 2007-01-09 09:26:56 EST
Access to fContentAssistSubjectControlAdapter  could be granted but not to the class. fContentAssistSubjectControlAdapter could be be access via type 'IContentAssistSubjectControl'.
Comment 6 Guy Gurfinkel CLA 2007-05-21 07:34:06 EDT
Here is the list of things I need access for:
1. running the following functions
fProposalPopup->isActive()
fProposalPopup->showProposals(boolean)

fContextInfoPopup->isActive()
fContextInfoPopup->showContextProposals(boolean)

prepareToShowCompletions()
promoteKeyListener()

2. option to set fLastAutoActivation

3. We want to override manageAutoActivation()
for that we need access for:
fContentAssistSubjectControlAdapter - we need access for the member according to IContentAssistSubjectControl interface
fAutoAssistListener - only getter and setter will do.


please reconsider
Comment 7 Dani Megert CLA 2007-05-21 07:49:50 EDT
I assume you would write your own subclass of the ContentAssist then, right?
Comment 8 Guy Gurfinkel CLA 2007-05-21 08:09:30 EDT
yes
Comment 9 Dani Megert CLA 2007-05-21 08:11:38 EDT
I suggest you attach a patch (as small as possible) here that adds protected methods to ContantAssistant and fits your needs. I can then review.
Comment 10 Guy Gurfinkel CLA 2007-06-20 02:47:49 EDT
Created attachment 71837 [details]
patch allowing subclassing and replacing the AutoAssistListener

What I did is added an option to replace the AutoAssistListener and question the ContentAssistant regarding fContextInfoPopup and fProposalPopup state.

Of course we can extend the support for subclassing even more, I would be glad to debate we you about it if you like.

Thanks.
Comment 11 Dani Megert CLA 2007-06-20 09:32:03 EDT
The attachment is not a valid patch. You need to load the 'org.eclipse.jface.text' project from CVS, modify the file(s) and then create the patch.
Comment 12 Guy Gurfinkel CLA 2007-06-20 09:58:15 EDT
Created attachment 71882 [details]
patch allowing subclassing and replacing the AutoAssistListener

hope it's ok now...
Comment 13 Dani Megert CLA 2007-06-20 10:59:53 EDT
>Of course we can extend the support for subclassing even more, I would be glad
>to debate we you about it if you like.
I want to keep it to a minimum unless we have a clear use case. The last 6 years went quite well the way it's currently implemented ;-)

Now to your patch: I can accept something along those lines. Here are the detail comments:

- since there's already a public setAutoActivationDelay I would simply add a corresponding getter as public API. This makes the story consistent.

- isProposalPopupActivated ==> isProposalPopupActive

- the 'not' in isContextInfoPopupNotActivated is ugly. I would change the name to isContextInfoPopupActive and adjust the logic.

- the new methods need Javadoc and you need to put your name into the header comment along these lines below the initial contributor:
  full name, e-mail - bugNr bugSummary
Comment 14 Guy Gurfinkel CLA 2007-06-21 03:36:20 EDT
Created attachment 71995 [details]
patch with fixes 

I changed the patch as you requested.
One point though

> - the 'not' in isContextInfoPopupNotActivated is ugly. I would change the name
> to isContextInfoPopupActive and adjust the logic.

the method functionality was:
(fContextInfoPopup != null && !fContextInfoPopup.isActive())
(like in line 312 in the original file).
changing the name to a "positive" one, will get us to:
(fContextInfoPopup == null || fContextInfoPopup.isActive())
which means it will return that the fContextInfoPopup is active although the fContextInfoPopup is null.

That's why I had to split this method into two, isContextInfoPopupInitiated and isContextInfoPopupActive.
Comment 15 Dani Megert CLA 2007-06-21 04:58:54 EDT
I don't see why you would need isContextInfoPopupInitiated(). The field is not null as soon as content assist is installed.

Please add full Javadoc as in all other methods of the class and don't forget to add the @since 3.4 tag.
Comment 16 Guy Gurfinkel CLA 2007-06-21 06:48:33 EDT
> I don't see why you would need isContextInfoPopupInitiated(). The field is not
> null as soon as content assist is installed.

The same reason you do in line 312.
Comment 17 Guy Gurfinkel CLA 2007-06-21 06:50:31 EDT
Created attachment 72023 [details]
update documentation

hope its OK now
Comment 18 Dani Megert CLA 2007-06-21 11:07:11 EDT
Do you only need the new is* methods in your AutoAssistListener subclass?
Comment 19 Guy Gurfinkel CLA 2007-06-21 11:16:32 EDT
and the getAutoActivationDelay().
As I said I tried to keep it as minimal as possible.

But I guess if we wanted to make it even more accessible for subclassing than we could also open the CompletionProposalPopup and ContextInformationPopup for the public.
Comment 20 Dani Megert CLA 2007-06-22 06:43:23 EDT
I don't like the two isContext* methods. I suggest we add protected getContextInfoPopup() and getContextInfoPopup() to the AutoAssistListener. This way you can do with them whatever you like.
Comment 21 Guy Gurfinkel CLA 2007-06-24 03:03:10 EDT
But then we'll have to open ContextInformationPopup and CompletionProposalPopup for the public.
is that ok with you?
Comment 22 Dani Megert CLA 2007-06-25 04:15:10 EDT
I've thought about this again and there is really no need to have isContextInfoPopupInitiated().

I've applied your patch
- isContextInfoPopupInitiated()
+ small modifications inside ContentAssistant to use the new is* methods
+ cosmetics (formatting, wording of Javadoc)
Comment 23 Guy Gurfinkel CLA 2007-06-25 04:34:27 EDT
Thank you very much, it was pleasure working with you.