I'm working with Netbeans and would like run static code analysis when I save a java file.
I know I can use the "Inspect" function, but this has to be called manually each time which seems quite tortuous.
This is straightforward if you are only using FindBugs for static analysis:
Select Tools > Options > Editor, then select the Hints tab.
Select FindBugs from the Language drop list, then check the box labeled Run FindBugs in Editor. Note that the tooltip states "Will automatically run FindBugs on the currently edited file after save".
Notes:
I am not aware of any other static analysis tools being integrated into NetBeans in this manner. This solution is only good for FindBugs.
This will only run static analysis for the saved file, and not for the entire project. That may be viewed as good or bad, depending on your requirements.
Related
Question:
Is there a way to run an eclipse action that is available from the context menu in the editor on every file of an project.
Actual Case:
I have to work with the leon3 and my dull mind has trouble enough understanding the code, that I do not want to scan lines to see if there is a semicolon hidden in there to see if there are multiple instructions or if the end if happens to be behind another instruction rather than on a line of its own (I missed an end if, which caused me to think that statements were conditional,...), therefore I would like to format the source nicely. I have access to Sigasi PRO which offers the option to "beautify" code as an operation in the editor. I would like to run this operation on all files in the leon project automatically.
Sigasi indeed only offers formatting in the editor at this time. In the Sigasi editor, you can format a selection or the entire editor's content. But, you can not trigger the formatting action without an editor.
I have not tried this, but I think you can achieve this with the Eclipse EASE project. EASE is a scripting environment for Eclipse.
I am having tough time to figure out debugging UI parts of Eclipse. I couldn't find any information on google (or) Eclipse web site.
All I wanted to do is to find out the code that gets executed when we double-click a file in project explorer to open the file in Editor.
I tried to bring up Eclipse source code from Plug-ins view -> right click on the plugins -> import as Source Project. But, I am unsure what are all the components that constitutes to the UI part. I get some weird errors when I try to import everything that's found in plug-ins view.
Where can I find the information related to debugging Eclipse source code?
Instead of using Plug-ins->Import as Source Project, I would recommend opening the Plug-ins view, selecting all plug-ins, right click, and Add to Java Search.
Then you can use Open Type Ctrl-Shift-t to search for class names and the source will be attached so you can read it, set breakpoints, and debug.
In your case, I think you want to investigate IWorkbench, IWorkbenchWindow, and IWorkbenchPage. The openEditor(*) methods on IWorkbenchPage will be of particular interest.
You may also want to take a look at the org.eclipse.ui.editors and org.eclipse.core.contenttype.contentTypes extension points.
I am using the integrated CODAN static code analysis tool in Eclipse CDT. Is there a way to store the output of this analysis as displayed in the "Problems" window in Eclipse to a file which stores its formatting and stores the columns as shown in the Eclipse Problems Window.
I did a "Select All"--> "Copy" and "Paste" to a text file but it lost all the columns and formatting and was difficult to read.
Does Eclipse have any option/setting to store this Static code analysis output to a file?
After lot of searching I find Eclipse does not have what I asked for in my OP.
You must paste to program like OpenOffice Calc/Microsoft Excel and vola!
I have been using Eclipse for a long time, the feature that is less known but very useful is the Scrapbook Page, that allows you to execute sections of the Java code without having them to be complete classes. For example, if I need to execute this simple for-loop I can do this by creating a scrap page (File->New->Other->Scrapbook Page) and then typing the following and they pressing the "Execute the Selected Text" or Ctrl-U will execute the code directly
for (int i=0; i < 10; ++i)
{
System.out.println("Here is the scrapbook page line: " + i);
}
Please post other less known but useful features that are available with eclipse. I know that there are entries in SO that mention the useful shortcuts available in eclipse, however this one is about forgotten or less known features
The plugin Spy (Alt+Shift+F1) is certainly one not very advertised.
Yet if you have any question about "how I develop a feature X looking like the one in eclipse", it can be very useful to quickly locate the right eclipse java source which does implement that feature!
(source: willianmitsuda.com)
See also this Guide to eclipse3.5:
The Plugin Spy gives you easily information about the running UI.
Press Alt+Shift+F1 to get information about the current running Eclipse plugin / data types / screen.
This way you can get immediately access to the plugin which is currently running.
(source: vogella.de)
Eclipse 3.5 introduced the possibility to check which plugin contributed a menu. Press "Alt+Shift+F2" and select a menu to see who is contributing this menu
(source: vogella.de)
I like the fact, that you don't necessarily need to create a new class by using New->Class, when having the class source somewhere in the clipboard. You can simply select the destination package and paste the clipboard content.
In Eclipse, under Windows -> Preference -> Java -> Code Style, you can define code templates for comments and code, and you can setup a code formatter.
I'm wondering if it is possible in Eclipse to have these setting take affect every time I save a source file. Basically, instead of me highlighting everything and pressing Ctrl+Shift+F, I want Eclipse to be responsible for making sure my code is formatted properly.
Is this possible and how do you set it up?
Note On Using the Auto-Format: It's probably best to choose "Format Edited Lines" as merging changes becomes very difficult when you reformat a whole file that is in source control already that was not formatted properly. Already did this to a co-worker.
Under Preferences, choose Java --> Editor --> Save Actions. Check the Perform the selected actions on save, and check the Format source code box.
This may or may not be available in previous versions of Eclipse. I know it works in:
Version: 3.3.3.r33x_r20080129-_19UEl7Ezk_gXF1kouft<br>
Build id: M20080221-1800
I have a snapshot of the setting.
Please follow the path:
In the Preferences window, choose Java --> Editor --> Save Actions.
Check the Perform the selected actions on save, and check the Format source code box.
I strongly recommend checking your eclipse format xml descriptor into source control. That way all members of the team can use it and you don't get to and fro reformatting battles.
If you find that you do not have a Save Actions preference under Java--> Editor, it may be because you are using an older version of Eclipse. In that case you can install the Format on save plugin from here.
Then, under Preferences, choose Java --> Format on save. Select the Run Format option under Select a code formatting action