Reputation: 399
I'm writing a small Sonar Plugin for Abap Code. I alread have presented metrics in Sonar, and also have the source Code of some Abap Files in the Sonar Database (i checked it with a sql client). But now I really have no clue how could I present this source code with sonar. I already looked through the sonar source code and some sonar plugins (like the CXXPlugin https://github.com/SonarCommunity/sonar-cxx which also have the Function to output the source Code), but I didn't get smarter. Is there an easy way how to present source code with the sonar api? Is there any kind of SourceViewer part of the Sonar Core (https://github.com/SonarSource/sonar).
EDIT: I'm now one step closer but I have a problem with the drilldown-view. My erb-file has the following code snippet:
%= format_measure(loc_measure, :suffix => '', :url => url_for_drilldown(loc_measure)) -%>
But my drilldown view do not list the sources which I have in my folder which was analysed by sonar:
In my Database I looked at the table 'projects':
Afterwards I tried to directly link in the drilldown view to a source file (in that case with the id 122) and it worked:
So my question is, why are the subfolder and source files not listed like classes and package in a normal Java project?
Upvotes: 0
Views: 1125
Reputation: 26843
You can take a look at some of our open-source language plugins that we develop for Sonar. For instance, you can go and see the Javascript plugin - which is probably a better option that the CXX plugin that is not developed by us and there that may not fully comply with our conventions and coding best-practices & guidelines.
To sum up:
Create a source importer like the JavascriptSourceImporter
Create a colorizer like what you can find in the "org.sonar.plugins.javascript.colorizer" package
And obviously do not forget to declare those extensions in your plugin class
Upvotes: 1