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?
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
Related
I'm in the early stages of creating a new Eclipse plug-in in Eclipse 2019-06. I created the plug-in using the "Hello World" wizard option and created a debug configuration that successfully launches a secondary workbench for testing. I can click on my new menu option and step into my new code.
I want to use a modified version of org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne, so I added the package to my project and edited NewTestCaseWizardPageOne. However, when I try to debug, the debugger asks for a source location. It seems to want to load the file from the local repository (.p2/pool/plugins/org.eclipse.jdt.junit_3.11.400.v20190510-0840.jar), rather than my edited version. Why is that?
There must be some kind of classpath problem, but don't versions of files in the project have precedence over those in the dependent plugins? I've looked at a number of similar questions (1, 2) and other sources, but I haven't yet found the answer. Please help.
Following Alexander Federov's suggestion, I converted my plugin into a fragment. This was fairly easy to do following the advice from this StackOverflow page. The main changes were:
Renamed plugin.xml to fragment.xml and changed the top level xml
element from plugin to fragment.
Added a Fragment-Host entry to MANIFEST.MF
The key advantage that this provided is discussed in an Eclipse Wiki
page:
... a fragment appears much the
same as a normal plug-in. A fragment can specify libraries,
extensions, and other files. When it is loaded by the platform loader,
a fragment is logically, but not physically, merged into the host
plug-in. The end result is exactly the same as if the fragment's
manifest were copied into the plug-in manifest, and all the files in
the fragment directory appear as if they were located in the plug-in's
install directory. Thus, a runtime library supplied by a fragment
appears on the classpath of its host plug-in. In fact, a Java class in
a fragment can be in the same package as a class in the host and will
even have access to package-visible methods on the host's classes.
The last part having to do with access to package-visible methods was what I needed. Thanks, Alexander!
I've noticed that in eclipse if you Right click on a project -> Grails Tools -> You have the option to 'Download Source Jars'.
What is the point of this and what are some common reasons as to why you would want to do this?
Grails 2.2.3
Edit:
I'm not even sure what grails does instead of that.
Many (most) libraries (JARs, "artifacts" in the Maven terminology) publish a sources archive alongside their binary artifacts in the repositories. This can be useful for Eclipse to show you the Javadoc and source code when you're using the library in your projects. As #JonSkeet commented above, it's very useful to have source code available directly in the IDE when using a library.
By default, Grails does not download the sources for artifacts; this option triggers it to do so and attach the sources to the binary JARs.
Agreed with E-Riz.
Here are the reasons I use the sources:
i want to have a deeper understanding of how the library works when debugging my own depending code
i want to find a possible bug in the library, so I can fork it and apply my own patch. i will possibly share this with the maintainers as a pull request if I'm willing to spend that much time on it.
i want to find out what logging systems it uses that might be poorly documented, so I can see better what their code is doing during runtime, to troubleshooting complicated problems.
Hi I have fairly acceptable knowledge in python and java and I have recently decided that to further progress in my programming would be to creating my own language to use and manipulate when I needed to. I installed javacc plug-in for eclipse and have gone through some tutorials.
My problem is that when I create a new project (file> new > java project) and create a class in the "src" folder, everything I type into my workspace has an error. Eg:
STATIC = false;
"Syntax error on tokens, delete these tokens"
Eclipse does this for everything except my class name, note there are no errors on my javacc template under projects.
Please help me find a solution or if an empty project should be compiled differently. Even an up to date tutorial on the very basics of this topic would be highly appreciated. Thanks
You may want to check the Eclipse Java development user guide, it should cover all the issues you may face at the start.
If it's not, please provide more information on what "javacc plugin" you have installed, and what code you actually try to compile.
I'm quite a noob programmer and I recently discovered Java Processing Language which can be run on Android.
So far I've been using a dedicated IDE to program it in but I've just found out I can program it in Eclipse which is my preferred IDE. The only problem is that they only tell you which libraries to import when creating a Processing project from a standard Java project. So every time I want to create a new project I have to create a Java project, go through all the import menus, search for the Processing system library, import the files, create a new class and import the library for the class.
Does anyone know how to create an eclipse plugin so I can just go to the NEW directory in eclipse and have a PROCESSING folder and a NEW PROCESSING PROJECT item that already has a generic class with the imported libraries?
I've been looking at online tutorials and I can't even figure out where to start.
The steps to create a Processing project from a Java one are explained here.
Thanks for any help!
I recommend having a look at the Proclipsing plugin which seems to do pretty much what you want to achieve. It's also open source so you can see how it was written and modify if you like.
A Processing project is a standard Java project with the Processing libraries added to build path. There is nothing more to Processing in this regard. So a specific Eclipse Processing plugin for this seems overkill (there are some other things like the different targets or samples that could make it useful though).
To easen up your current process: Create an Eclipse User Library for the Processing libraries. Menu Window > Preferences, Java > Build Path > User Libraries, New.... Add the Processing libraries. Now you can easily add the whole set to a project (right-click on the newly created Java project in the package explorer, Build Path > Add libraries > User Library).
If you want to change the standard template for Java classes to one including everything for Processing: Window > Preferences, Java > Code Style > Code Templates, Code > New Java files. This changes every newly created class, maybe it is better to just create a simple template to manually call at start: Java > Editor > Templates, New.... Then you would call the template every time you create a Processing main class but not for "normal" classes.
Ok... regarding the target audience of Processing a plugin may be a good idea. But then there is the dedicated Processing UI. Eclipse is not exactly a good introductory IDE.
I intend to customize Openmeetings and am wondering if there is a GUI editor available for Openlaszlo.
There was apparently a plugin called IDE4Lazlo, mentioned both at IBM and Eclipse.org, but both links are dead. If the plugin has been definitely pulled, then is there a way to at least preview layouts?
The IDE4Laszlo is on old IBM project, which has not been maintained for a long time (since 2005/2006). Laszlo had been working on an Eclipse based plugin in 2008, which was unfortunately never released.
Spket works, but compared to IDEs like Flash Builder the functionality is relatively limited, since the IDE is not capable of scanning your application files to recognize new classes and methods.
An option is to use an XML editor with XSD support. Sebastian Wagner of OpenMeetings has created a build script which generates an XSD schema file from the OpenLaszlo classes and the custom classes in your application. The source code can be found here:
http://code.google.com/p/openlaszlo-schemagenerator/
There are two Eclipse IDE plugins that support OpenLaszlo, IDE4Laszlo and the more recent Spket.