This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 303356 - Add content assist that inserts Hyperlink markup to JavaDoc for Java classes
Summary: Add content assist that inserts Hyperlink markup to JavaDoc for Java classes
Status: RESOLVED WONTFIX
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: David Green CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 304871
Blocks:
  Show dependency tree
 
Reported: 2010-02-19 13:45 EST by Philipp Kursawe CLA
Modified: 2013-08-02 12:42 EDT (History)
2 users (show)

See Also:


Attachments
mylyn/context/zip (13.14 KB, application/octet-stream)
2010-02-19 23:12 EST, David Green CLA
no flags Details
Initial implementation (1.83 KB, text/plain)
2010-02-22 10:07 EST, Philipp Kursawe CLA
no flags Details
Definition of variable resolver (464 bytes, application/xml)
2010-02-22 10:08 EST, Philipp Kursawe CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Kursawe CLA 2010-02-19 13:45:05 EST
I have the following usecase:
I write a .textile file and want to include the java doc location for "java.lang.Runnable" by pressing M1+Space. The content assist should then provide me with the entry "JavaDoc reference" and when I select it it should transform "java.lang.Runnable" to {{{Runnable":http://www.sun.com/javadoc/....}}}.

How would the content assist perform this replacement? It would try to look up the HTML file for "java/lang/Runnable.html" at Sun's server. The same would go for Eclipse classes. It would convert all "." with "/" and tries to load the website. If that was successful the content assist inserts the URL.

I would like to implement that in my own plugin, and need some tips:

# How do I contribute to the Mylyn WikiText content assist? The org.eclipse.mylyn.wikitext.ui.contentAssist EP only allows static assists.
# How would I get access to the currently used Markup processor and as it for its Hyperlink markup so I can generate that markup at the current cursor position (and replacing the former text)

I would provide a preference page where one can add JavaDoc locations and a regex when the location should match.
This would also allow me to reference my own classes and their javadoc at github.
Comment 1 David Green CLA 2010-02-19 23:11:31 EST
Sounds like a very cool feature.  Normally to add content assist to the WikiText editor you would add something like this to your plugin.xml:

bc. 
<extension
         point="org.eclipse.ui.editors.templates">
      <template
         name="%exampleTemplate.name"
         contextTypeId="org.eclipse.mylyn.wikitext.ui.editor"
         id="org.eclipse.mylyn.wikitext.ui.examples.assist.template"
         description="%exampleTemplate.description">
          <pattern>my pattern ${text} goes here</pattern>
      </template>
</extension>

Unfortunately this standard mechanism for adding templates does not provide a mechanism for having dynamic template patterns such as the one you describe.

You might consider making a contribution to enhance the content assist mechanism to support dynamic templates.  If you're interested I suggest that you start having a look in @org.eclipse.mylyn.internal.wikitext.ui.editor.assist@ in the org.eclipse.mylyn.wikitext.ui bundle.  Also pay special attention to @org.eclipse.jface.text.templates.TemplateProposal@.
Comment 2 David Green CLA 2010-02-19 23:12:21 EST
Created attachment 159659 [details]
mylyn/context/zip
Comment 3 Philipp Kursawe CLA 2010-02-22 06:46:31 EST
OK, I will look around how this could be accomplished. As described before I would need a way to merge dynamic content proposals with the ones currently active for the editor (provided by the contentAssist wikitext EP).
Just today I wanted to add the link to a MSDN class into my textile document and the workflow should have been like this:
1. Type the Class/Function I would like to create a link to. In this example "ReadDirectoryChangesW"
2. Press M1+Space for the content assist. It should present me: "Find Link with google", "Find JavaDoc Link"
3. I select "Find Link with google" and using the Google search API it would find the first entry that google returns and change the "ReadDirectoryChangesW" text into the appropriate "link" for the current text processor. In my case it should have changed into "ReadDirectoryChangesW":http://msdn.microsoft.com/en-us/library/aa365465%28VS.85%29.aspx

So first I need to find out how mylyn creates the content proposals and how to hook into that.
Comment 4 Philipp Kursawe CLA 2010-02-22 09:36:33 EST
What I did was just implementing a template variable resolver for the "url" type. The result is visible here:
http://screencast.com/t/ODY1Y2Zj

It queries google using the Google search AJAX API and provides the resulting URLs.
That's ok, but I would like to have something more. What I also often need is a reference to a source file on github. I just have no idea yet how to resolve that. One would have to read out the workspace projects .git informations and see if github is references there as a remote. If it is, it would compose the URL with the projects remote + the classname (replacing "." with "/").
Comment 5 Philipp Kursawe CLA 2010-02-22 10:07:58 EST
Created attachment 159790 [details]
Initial implementation
Comment 6 Philipp Kursawe CLA 2010-02-22 10:08:56 EST
Created attachment 159791 [details]
Definition of variable resolver
Comment 7 Philipp Kursawe CLA 2010-02-22 10:09:09 EST
I also works on Eclipse classes, although some manual changes might be necessary.
http://screencast.com/t/YWQ4MTFmMD
Comment 8 David Green CLA 2010-02-22 12:08:38 EST
(In reply to comment #4)
> What I did was just implementing a template variable resolver for the "url"
> type. The result is visible here:
> http://screencast.com/t/ODY1Y2Zj
> 
> It queries google using the Google search AJAX API and provides the resulting
> URLs.

I just watched the screencast and it looks really cool!  Nice job.  It's impressive how simple it is.

(In reply to comment #4)
> What I also often need is a reference to a source file on github. I just have no idea yet how to resolve
> that. One would have to read out the workspace projects .git informations and
> see if github is references there as a remote. If it is, it would compose the
> URL with the projects remote + the classname (replacing "." with "/").

You may want to consider a contribution to "EGit":http://www.eclipse.org/egit for github-related content assist.
Comment 9 Philipp Kursawe CLA 2010-02-23 01:46:38 EST
Any thoughts how we could bring this into WikiText? Should it be a separate bundle or included into wikitext.ui?
Comment 10 David Green CLA 2010-02-23 17:22:54 EST
(In reply to comment #9)
> Any thoughts how we could bring this into WikiText? Should it be a separate
> bundle or included into wikitext.ui?

Philipp, unfortunately we cannot add to dependencies of the WikiText ui bundle.  That said, your contribution would be welcomed by many, so I'd like to see if there's a way to include it. 

Currently there's interest in maintaining a JSON library in orbit (bug 301578 for which CQ 3603 was approved).  In case you're not aware Orbit is the preferred way for Eclipse bundles to work with 3rd party libraries.  If it doesn't already your contribution would have to be modified to use an approved library.

I suggest that you join our "weekly conference call":http://wiki.eclipse.org/Mylyn/Meetings if you can.  I'll bring up this issue and we can discuss our options.
Comment 11 Philipp Kursawe CLA 2010-02-24 02:56:20 EST
(In reply to comment #10)
> (In reply to comment #9)
> > Any thoughts how we could bring this into WikiText? Should it be a separate
> > bundle or included into wikitext.ui?
> 
> Philipp, unfortunately we cannot add to dependencies of the WikiText ui bundle.
>  That said, your contribution would be welcomed by many, so I'd like to see if
> there's a way to include it. 
> 
> Currently there's interest in maintaining a JSON library in orbit (bug 301578
> for which CQ 3603 was approved).  In case you're not aware Orbit is the
> preferred way for Eclipse bundles to work with 3rd party libraries.  If it
> doesn't already your contribution would have to be modified to use an approved
> library.

I am only using JSON from the Jetty utils bundle, which is Orbit approved.

On Thursday I will be not available for the call. But you can bring the issue up and see what others think about the addition and possible further enhancements (like the git integration).
Comment 12 David Green CLA 2010-02-24 10:52:43 EST
(In reply to comment #11)
> I am only using JSON from the Jetty utils bundle, which is Orbit approved.

Great to hear!

> On Thursday I will be not available for the call. But you can bring the issue up
> and see what others think about the addition and possible further enhancements
> (like the git integration).

No problem, I've put it on the agenda.
Comment 13 David Green CLA 2010-03-04 13:32:34 EST
We'd like to better understand the use cases for this feature and would like to give users a chance to try it out before including it in the main WikiText distribution.  The best way to facilitate this is to create a new WikiText bundle and feature in the Mylyn sandbox.  That way users would be able to install it and try it out simply by adding the sandbox update site URL.

There were some concerns raised about how this feature handles unrelated search results.  To help with this we discussed always scoping the search to one or more websites.  This could be done via workspace preferences (requiring new UI) or via extension points.

If you're willing to work with us to tweak and polish this feature we'll gladly welcome your very cool contribution!
Comment 14 Philipp Kursawe CLA 2010-03-05 09:13:43 EST
(In reply to comment #13)
> We'd like to better understand the use cases for this feature and would like to
> give users a chance to try it out before including it in the main WikiText
> distribution.  The best way to facilitate this is to create a new WikiText
> bundle and feature in the Mylyn sandbox.  That way users would be able to
> install it and try it out simply by adding the sandbox update site URL.

Sure I can provide such a bundle.

> There were some concerns raised about how this feature handles unrelated search
> results.  To help with this we discussed always scoping the search to one or
> more websites.  This could be done via workspace preferences (requiring new UI)
> or via extension points.

Yes, we could provide a preference page for the URLs to use to fetch potential candidates.

> If you're willing to work with us to tweak and polish this feature we'll gladly
> welcome your very cool contribution!
I would be happy to contribute.

I will add the scoping and create the bundle next week and report back here.
Comment 15 David Green CLA 2010-03-05 14:38:39 EST
(In reply to comment #14)
> Sure I can provide such a bundle.

Don't worry about creating a bundle for now.  I'll set up the sandbox bundle.  That way you won't have to worry about bundle naming, package naming etc.

> Yes, we could provide a preference page for the URLs to use to fetch potential
> candidates.
> ...
> I would be happy to contribute.

Great!

> I will add the scoping and create the bundle next week and report back here.

For now you can continue evolving your code against the wikitext.ui bundle until such time as we've got the sandbox set up.
Comment 16 David Green CLA 2010-03-29 11:27:54 EDT
Philipp, you'll notice that we've added the Mylyn WikiText sandbox projects to CVS under tools/org.eclipse.mylyn/sandbox (see bug 304871 for details)
Feel free to continue working on your patch here, preferably changing package names to match those in the @org.eclipse.mylyn.wikitext.sandbox.ui@ project.
Comment 17 Philipp Kursawe CLA 2010-03-29 11:57:50 EDT
Thanks David, I will see when I will be able to work on that.
Comment 18 David Green CLA 2013-08-02 12:42:47 EDT
Closed as part of backlog clean-up.  Please re-open if you'd like to see this revisited, perhaps with a contribution.