Code/Text completion in comments section

I tried implementing completion for Java/JavaDoc comments.

I tried:
1.
ReferenceProvidersRegistry registry = ReferenceProvidersRegistry.getInstance(project);
registry.registerReferenceProvider(PsiComment.class, new MyReferenceProvider());

but it doesn't work (getReferencesByElement of MyReferenceProvider is not called when I press ctrl+space after xxx. withing the comment)

2.
CompletionUtil.registerCompletionData(StdFileTypes.JAVA, new MyCompletionData());

doesn't work as well (completeReference of MyCompletionData is not called when I press ctrl+space after xxx. withing the comment. It is called outside the comment)

Any ideas how to implement it for java and javadoc comments?

0
5 comments

Jacek Jaroczynski wrote:

I tried implementing completion for Java/JavaDoc comments.

I tried:
1.
ReferenceProvidersRegistry registry = ReferenceProvidersRegistry.getInstance(project);
registry.registerReferenceProvider(PsiComment.class, new MyReferenceProvider());

but it doesn't work (getReferencesByElement of MyReferenceProvider is not called when I press ctrl+space after xxx. withing the comment)

2.
CompletionUtil.registerCompletionData(StdFileTypes.JAVA, new MyCompletionData());

doesn't work as well (completeReference of MyCompletionData is not called when I press ctrl+space after xxx. withing the comment. It is called outside the comment)

Any ideas how to implement it for java and javadoc comments?


Extending java comment & javadoc completion is very hard in IDEA 7. What
functionality do you want to implement?

0

Scenario:

  • during start the plugin is caching all JIRA issues matching criteria from plugin settings, for example PL-120 to PL-130 and PL-220-PL-230

  • during typing in method javadoc comment (or just code comment) // text PL-1 {ctrl-space here} I would like to see a list of matching JIRA issues PL-120 to PL-130


The same in commit dialog but this is another story.

The same question about making such links clickable with CtrlMouse and CtrlB

0

Scenario:

  • during start the plugin is caching all JIRA issues matching criteria from plugin settings, for example PL-120 to PL-130 and PL-220-PL-230

  • during typing in method javadoc comment (or just code comment) // text PL-1 {ctrl-space here} I would like to see a list of matching JIRA issues PL-120 to PL-130


The same in commit dialog but this is another story.

The same question about making such links clickable with CtrlMouse and CtrlB


You can't register references in this case. So you should patch
corresponding CompletionData: JavaDocCompletionData, JavaCompletionData
and Java15CompletionData. You should add a CompletionVariant to them,
and add a KeywordChooser (or a ContextGetter) to them that returns your
issue names. And pass your comment element type (PsiComment or
PsiDocComment) to CompletionVariant constructor.

These data's are returned by
CompletionUtil#getCompletionDataByElementInner, but you need to have
PsiElement (PsiComment or PsiDocComment in your case). So you should get
them from some action where you have this PsiElement, and add the
described CompletionVariant there, but only once during IDEA session.

Good luck! In IDEA 8 this is much easier, BTW.

0

Hello Jacek,

Have you looked at ALMworks TrackLink? It has quite similar functionality
(although it doesn't do issue ID completion).

http://almworks.com/tracklink/overview.html

Scenario:

  • during start the plugin is caching all JIRA issues matching criteria

from plugin settings, for example PL-120 to PL-130 and PL-220-PL-230

  • during typing in method javadoc comment (or just code comment) *_//

text PL-1_* {ctrl-space here} I would like to see a list of matching
JIRA issues PL-120 to PL-130

The same in commit dialog but this is another story.

The same question about making such links clickable with Ctrl+Mouse
and Ctrl+B

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

TrackLink looks interesting. It has an issue linking feature. I will definitely try it. Just for future readers convenience TrackLink source code is available at: http://code.google.com/p/tracklink/source/checkout

I will also try Peter's clues as well.

Thanks!

0

Please sign in to leave a comment.