Extend Content Assist questions [message #250778] |
Tue, 22 January 2008 08:45 |
Philipp Bouillon Messages: 16 Registered: July 2009 |
Junior Member |
|
|
Hi,
I am playing around and trying to write a plug-in which extends
Content-Assist in a way that additional proposals are given for Java. I
didn't get very far, though.
I extended the javaCompletionProposalComputer and implemented the
IJavaCompletionProposalComputer interface.
Now, when "computeCompletionProposals" is called, I can convert the
"ContentAssistInvocationContext" to a "JavaContentAssistInvocationContext"
and if I simply display some data, the "getCompilationUnit" and
"getProject" methods of the JavaContentAssistInvocationContext work as
expected.
However, getExpectedType() always returns null.
Now, as I understand it, getExpectedType should return the expected Type
of the prefix the user has entered, for example:
void someMethod(TypeA oneType, TypeB anotherType) {
oneType.<CTRL+SPACE>
}
now, I'd expect that "getExpectedType" would yield TypeA. No?
If this is not the intended purpose of this method, then how _can_ I
determine the type on which I should operate?
[Ok, If I just hit "<CTRL+SPACE>" in my ICU, I know I have to use _this
ICU_, but as soon as any "." is entered, I am referencing some type,
right? So, how do I get that information?]
Thanks for your help!
Philipp
And ps: If there's a good tutorial (an article even?) on how to extend
content assist, I'd be happy to know where I could find it. Thanks.
|
|
|
Re: Extend Content Assist questions [message #251027 is a reply to message #250778] |
Mon, 28 January 2008 17:40 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
Philipp Bouillon wrote:
> Hi,
>
> I am playing around and trying to write a plug-in which extends
> Content-Assist in a way that additional proposals are given for Java.
> I didn't get very far, though.
>
> I extended the javaCompletionProposalComputer and implemented the
> IJavaCompletionProposalComputer interface.
>
> Now, when "computeCompletionProposals" is called, I can convert the
> "ContentAssistInvocationContext" to a
> "JavaContentAssistInvocationContext" and if I simply display some
> data, the "getCompilationUnit" and "getProject" methods of the
> JavaContentAssistInvocationContext work as expected.
>
> However, getExpectedType() always returns null.
> Now, as I understand it, getExpectedType should return the expected
> Type of the prefix the user has entered, for example:
>
> void someMethod(TypeA oneType, TypeB anotherType) {
> oneType.<CTRL+SPACE>
> }
>
> now, I'd expect that "getExpectedType" would yield TypeA. No?
Nope. The expected type is used in things like assignements:
A myType;
myType= <code assist here>
==> expected type = A
You don't get more info. If you want to provide your proposals you have
to do the parsing. You can get a little bit more info from the core
context (see
org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationCont ext.getCoreContext()),
but not much.
Dani
> If this is not the intended purpose of this method, then how _can_ I
> determine the type on which I should operate?
> [Ok, If I just hit "<CTRL+SPACE>" in my ICU, I know I have to use
> _this ICU_, but as soon as any "." is entered, I am referencing some
> type, right? So, how do I get that information?]
>
> Thanks for your help!
> Philipp
>
> And ps: If there's a good tutorial (an article even?) on how to extend
> content assist, I'd be happy to know where I could find it. Thanks.
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02961 seconds