Community
Participate
Working Groups
This bug is the first iteration of CodeMining contribution of https://bugs.eclipse.org/bugs/show_bug.cgi?id=526969. It provides basic support for CodeMining with SourceViewer: * an ICodeMiningProvider API to retrieve list of code minings which are resolved or not. * an ICodeMiningResolver API to resolve code mining. * an new ISourceViewerExtension5 API to configure code minings and run it. This contribution draw code minings with Annotation (by using AnnotationPainter) and line spacing of line (by implementings new APY StyledTextLineSpacingProvider).
New Gerrit change created: https://git.eclipse.org/r/111912
Created attachment 271562 [details] Code Mining demo Here a demo with the CodeMiningDemo that you can find in the gerrit patch. I have done a lot of choice and try to comment the most possible, but I think it's not perfect. I'm aware to change anything! Please note that it's the first iteration of Code Mining, there are another improvement to do in another gerrit patches (extension point, custom renderer, etc). If you need some more explanation, don't hesite to tell me. I have created an project org.eclipse.jface.text.examples to set the Code Mining demo, but I have not done pom.xml, etc. I wanted to set the demo in my gerrit patch (@Mickael please help me with pom.xml, build.properties, etc with this new project) @Dani, @Mickael any feedback are welcome! And if you can, please help me with contribution. Thanks!
*** Bug 501546 has been marked as a duplicate of this bug. ***
A couple questions: - Will there be any restrictions on the SourceViewers that can benefit from it? - are line number of the underlying document touched? I assuem not? - Is it possible to edit content in a code mining section?
(In reply to Pascal Rapicault from comment #4) > - Will there be any restrictions on the SourceViewers that can benefit from > it? The SourceViewers would need to implement ISourceViewerExtension5 ( https://git.eclipse.org/r/#/c/111912/1/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java ) . The "default" SourceViewer most editors do rely on will implement this interface ( https://git.eclipse.org/r/#/c/111912/1/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java ) > - are line number of the underlying document touched? I assuem not? Nope, see bug 527675. The underline implementation only affects drawing by "shifting" the drawing of actual text of the necessary dx/dy to let the CodeMining be drawn in the created space. But the underlying text and document isn't modified at all. So would be the line numbers. > - Is it possible to edit content in a code mining section? The proposed API in SourceViewer doesn't include that at the moment. And I think it would be too early to introduce it and it would better be done later. But as it's all about drawing, I belive there wouldn't be too much of an issue with drawing editable content.
@Angelo: do you see a possible relationship between the CodeMinungManager and a Reconcilier? Ie could CMM be a specific reconcilier?
> @Angelo: do you see a possible relationship between the CodeMinungManager and a Reconcilier? Ie could CMM be a specific reconcilier? My idea is that CodeMiningManager should be host in an internal package and after we have ISourceViewerExtension5 like this: ---------------------------------------------------- public interface ISourceViewerExtension5 { /** * Update minings */ void updateCodeMinings() /** * Register the code mining providers. * * @param codeMiningProviders the code mining providers */ void setCodeMiningProviders(ICodeMiningProvider[] codeMiningProviders); } ---------------------------------------------------- With that, we can execute codemining manager like we wish: * with generic editor, just implement a reconciler which call ISourceViewerExtension5#updateCodeMinings(); * with JDT implements an org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener and execute ISourceViewerExtension5#updateCodeMinings(); in reconciled method: ---------------------------------------------------- @Override public void reconciled(CompilationUnit ast, boolean forced, IProgressMonitor progressMonitor) { ((ISourceViewerExtension5)viewer)updateCodeMinings(); } ---------------------------------------------------- like I had done with my CodeLens & JDT POC https://github.com/angelozerr/codelens-eclipse/blob/master/org.eclipse.codelens.jdt/src/org/eclipse/codelens/jdt/internal/JavaCodeLensController.java#L55 I'm waiting for https://bugs.eclipse.org/bugs/show_bug.cgi?id=527720 to do a new gerrit patch with this idea. In this gerrit patch, I would like too configure ICodeMiningProvider with SourceViewerConfiguration#getCodeMiningProviders(ISourceViewer sourceViewer) exactly like getHyperlinkDetectors. In a an another bugs, I will provide an extension point for ICodeMiningProvider with TextSourceViewerConfiguration#getCodeMiningProviders(ISourceViewer sourceViewer) & SourceViewerConfiguration#getCodeMiningProviderTargets(ISourceViewer sourceViewer) which will return Map<String, IAdaptable> exactly like hyperlink.
New Gerrit change created: https://git.eclipse.org/r/113149
@Mickael please review my gerrit patch https://git.eclipse.org/r/#/c/113149 which provides public API for codemining with ISourceViewerExtension5.java
Gerrit change https://git.eclipse.org/r/113149 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=b3478c79243610fa7a44d42504f8671098d2bda0
New Gerrit change created: https://git.eclipse.org/r/113349
@Mickael, please review my gerrit patch https://git.eclipse.org/r/113349 for N&N Thanks!
Gerrit change https://git.eclipse.org/r/113349 was merged to [master]. Commit: http://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=bb1617e70833d82ad500224ea2b9512f51c67963
Thanks @Mickael for having reviewed my N&N!
@Mickael I think we can close this issue?
Thanks Angelo.