Questions on implementing an IJavaCompletionProposalComputer [message #257721] |
Tue, 09 December 2008 13:28  |
Eclipse User |
|
|
|
Originally posted by: myawn.ebay.com
I'm making my first excursion into implementation of code completion,
and have run into a few questions.
I'm implementing an IJavaCompletionProposalComputer. When I construct
and return JavaCompletionProposals, the completion proposal is
essentially a String. I'm not sure how to indicate that certain parts
of the String are in fact placeholder parameters that will need to be
replaced with valid values (so that the editor will 'box' these
parameters, select the first one to be replaced, and move the cursor to
that position, as it does when the JDT suggests a method with parameters).
The other thing I'm not sure about is that I'll be proposing some
completions that are actually not currently visible. So if the user
selects one of the non-visible completions, I'd like to add the import
required to make it visible to the source file.
I think I can do this by subclassing JavaCompletionProposal and adding
the import in the selected(ITextViewer, boolean) method -- is that a
reasonable approach?
Thanks,
Mike
|
|
|
Re: Questions on implementing an IJavaCompletionProposalComputer [message #257733 is a reply to message #257721] |
Thu, 11 December 2008 04:05   |
Eclipse User |
|
|
|
Mike,
The "boxes" are known as "Linked Mode" in Eclipse speak. Have a look at
TemplateProposal (in jface.text) on how to apply a proposal and set up
linked mode. Note that linked mode is not tied to templates in any way -
this is just the simplest example that comes to my mind.
To see what the JDT does when inserting arguments into method calls, you
should look at ParameterGuessingProposal and its super classes.
-tom
Mike Yawn wrote:
>
> I'm making my first excursion into implementation of code completion,
> and have run into a few questions.
>
> I'm implementing an IJavaCompletionProposalComputer. When I construct
> and return JavaCompletionProposals, the completion proposal is
> essentially a String. I'm not sure how to indicate that certain parts
> of the String are in fact placeholder parameters that will need to be
> replaced with valid values (so that the editor will 'box' these
> parameters, select the first one to be replaced, and move the cursor to
> that position, as it does when the JDT suggests a method with parameters).
>
> The other thing I'm not sure about is that I'll be proposing some
> completions that are actually not currently visible. So if the user
> selects one of the non-visible completions, I'd like to add the import
> required to make it visible to the source file.
>
> I think I can do this by subclassing JavaCompletionProposal and adding
> the import in the selected(ITextViewer, boolean) method -- is that a
> reasonable approach?
>
> Thanks,
> Mike
|
|
|
|
Re: Questions on implementing an IJavaCompletionProposalComputer [message #257746 is a reply to message #257738] |
Thu, 11 December 2008 11:10  |
Eclipse User |
|
|
|
Originally posted by: myawn.ebay.com
Thanks Tom, I'll take a look at the areas you suggest.
Mike
Tom Eicher wrote:
> ... about the imports:
>
> ICompletionProposalExtension2#selected() is called when the proposal is
> selected in the list. You shouldn't add the import there, but rather
> from one of the apply methods. See JavaTypeCompletionProposal#apply as
> an example.
>
> -t
>
> Mike Yawn wrote:
>> The other thing I'm not sure about is that I'll be proposing some
>> completions that are actually not currently visible. So if the user
>> selects one of the non-visible completions, I'd like to add the import
>> required to make it visible to the source file.
>>
>> I think I can do this by subclassing JavaCompletionProposal and adding
>> the import in the selected(ITextViewer, boolean) method -- is that a
>> reasonable approach?
>>
>> Thanks,
>> Mike
|
|
|
Powered by
FUDForum. Page generated in 0.04836 seconds