Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Extend Content Assist questions
Extend Content Assist questions [message #250778] Tue, 22 January 2008 08:45 Go to next message
Philipp Bouillon is currently offline Philipp BouillonFriend
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 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
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.
>
Re: Extend Content Assist questions [message #251047 is a reply to message #251027] Tue, 29 January 2008 08:00 Go to previous message
Philipp Bouillon is currently offline Philipp BouillonFriend
Messages: 16
Registered: July 2009
Junior Member
Thanks.
I feared as much; so now, I am parsing the info myself. Works like a
charm...
Previous Topic:How to create project but not show in project navigator view
Next Topic:How to fire a install jre changed event programmatically?
Goto Forum:
  


Current Time: Wed Jan 15 07:07:05 GMT 2025

Powered by FUDForum. Page generated in 0.02961 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top