Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Content Assist within string literal of an annotation
Content Assist within string literal of an annotation [message #656455] Fri, 25 February 2011 17:06 Go to next message
Ovidio Mallo is currently offline Ovidio MalloFriend
Messages: 35
Registered: July 2009
Member
Hi all,

I would like to write a plug-in which provides completion proposal for a
method reference within a string literal in the Java editor. The string
is part of a JExample [1] annotation (@Given) and references a method
declaration. Here is an example:

@Test
public Stack whenEmpty() {
// ...
return stack;
}

@Given("#whenEmpty()") // <<< content proposal within string
public Stack shouldPush(Stack stack) {
// ...
return stack;
}

Since the format of the method reference is basically the same as you
would use in a @see JavaDoc tag, I was hoping that I could use the
existing content proposal logic used for JavaDoc references.

So far, I've implemented my own IJavaCompletionProposalComputer and
attached it through the
org.eclipse.jdt.ui.javaCompletionProposalComputer extension point which
is working fine. The actual implementation uses
CompletionProposalCollector#codeComplete() for retrieving the content
proposals but since I'm within a string literal, JDT does obviously not
recognize this as a context in which to retrieve method reference proposals.

My question is whether I can somehow let the CompletionProposalCollector
know that I want the same content proposals like in a @see JavaDoc tag
even if the cursor is within a string literal of an annotation?

Thanks in advance for any help!

Ovidio


[1] http://scg.unibe.ch/research/jexample
Re: Content Assist within string literal of an annotation [message #656519 is a reply to message #656455] Sat, 26 February 2011 06:44 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 25.02.2011 18:06, Ovidio Mallo wrote:
> Hi all,
>
> I would like to write a plug-in which provides completion proposal for
> a method reference within a string literal in the Java editor. The
> string is part of a JExample [1] annotation (@Given) and references a
> method declaration. Here is an example:
>
> @Test
> public Stack whenEmpty() {
> // ...
> return stack;
> }
>
> @Given("#whenEmpty()") // <<< content proposal within string
> public Stack shouldPush(Stack stack) {
> // ...
> return stack;
> }
>
> Since the format of the method reference is basically the same as you
> would use in a @see JavaDoc tag, I was hoping that I could use the
> existing content proposal logic used for JavaDoc references.
>
> So far, I've implemented my own IJavaCompletionProposalComputer and
> attached it through the
> org.eclipse.jdt.ui.javaCompletionProposalComputer extension point
> which is working fine. The actual implementation uses
> CompletionProposalCollector#codeComplete() for retrieving the content
> proposals but since I'm within a string literal, JDT does obviously
> not recognize this as a context in which to retrieve method reference
> proposals.
>
> My question is whether I can somehow let the
> CompletionProposalCollector know that I want the same content
> proposals like in a @see JavaDoc tag even if the cursor is within a
> string literal of an annotation?
No. You could try to create a dummy CU with almost the same contents as
your CU but replace "<stuff>" with /**<stuff>*/ and then invoke content
assist inside the Javadoc section.

Dani
>
> Thanks in advance for any help!
>
> Ovidio
>
>
> [1] http://scg.unibe.ch/research/jexample
Previous Topic:Eclipse Java - share code between 2 projects
Next Topic:How to enlarge eclipse java editor functionality using plugins?
Goto Forum:
  


Current Time: Fri Apr 26 06:09:57 GMT 2024

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

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

Back to the top