How to see output from multiple File Watchers in JetBrains IDE - intellij-idea

I'm using JetBrains GoLand IDE however I assume the answer would be common for any JetBrains IDE such as IntelliJ etc.
I've configured file watchers for:
go fmt, golint and go test
go fmt does not have output so it works fine.
golint and go test both have output. If I enable just one of them I see that output. If I enable both I see the output of golint for only a split second then it is replaced by the output of go test So I will never actually be able to read the output of golint
For now I solved this by making go test only display output on error, if it errors I figure I do not yet care about the output of golint but thought I'd ask anyway.

You don't need to enable go test as a File Watcher as the default test runner can execute on file changes.
To enable this feature, you can enable the Toggle test auto-rerun feature, which is the third button from top to bottom on the left side of the run test window. You can also configure the interval after which the tests run via the cog wheel.
Here's a reference for how to do this in IntelliJ IDEA, which is the same as in GoLand https://twitter.com/intellijidea/status/807239309992591361?lang=en

Known issue, please vote for WEB-14387 to be notified on any progress with it

Related

How can I run the current test with a keybinding in IntelliJ IDEA 2018.2?

Recently upgraded to IDEA 2018.2
In previous versions of IDEA, I was able to bind Run configuration... to a key (ctrl-shift-F10 is what I used) in order to run the current test ("current" meaning the test that my editor cursor was inside).
Note that the functionality itself still exists, you can right-click on test name and select "Run" and it will run that test.
But I can't figure out how to map that functionality to a keyboard now - does anyone know the new way?
EDIT:
The answer below is correct, but be aware that you might need to restart IDEA to pick up the new key mapping.
You can bind a keyboard shortcut of your choice to the action Run context configuration.
If you go to the keymap settings and search for that you should be able to set the keyboard config of your choice and be able to run the current test.
Keep an eye of conflicting keyboard shortcuts (inside and outside intellij!)

Why do I have to run 'rebuild project' for every change in Intellij?

For any change I made to my class, which contains a main() method, I have to run "Build->rebuild project", to make the changes effective. I am afraid my environment or settings have a problem.
Please help.
Please check that you still have Build step in the Before launch setting of the Run/Debug configuration. This is the default, but you could have removed it by accidentally clicking on the — icon.
I think you'll have to repeat this for every JUnit test case.
To alter the behaviour for all test cases:
Run -> Edit Configurations...
In left-hand column, select Templates -> JUnit
Make your changes
Hit OK
I had the same problem and I solved it setting the SDK. You need to go in Project Setting and select the Project tab, as show below
Then you can download a JDK or add a new SDK. Finally, you click on OK and run the code.

Is there a way to find output of previous runs in IntelliJ?

Every time I run some program, the output of previous run of some other program seems to be overwritten by the new output. Is there a way to see the output of previously run programs?
There is not. In the Run/Debug configuration, on the log tab, you can turn on the option "Save console output to file". (You can set this under the "Defaults" configuration so that it always there by default. That however only applies to the current project. To set as a default for all future projects as well, from the Welcome screen (i.e. close all projects) go to Configure > Project Defaults > Run Configurations) Unfortunately, that output file is (also) overwritten on each new run. To the best of my knowledge, there is no way to add a timestamp to the file name. You can open a feature request asking they enhance this to retain the last x number of runs or allow a timestamp.
In the meantime, there are two options you can use for a workaround.
Option 1 - Logging Framework
The first option is to use a logging framework. This won't include the start up information or any System.out/err that the console has (unless you use something like sysout-over-slf4j). On the same "Logs" tab in the Run/Debug configuration, you can set to have the log file shown in the console tool window. The nice thing is that IntelliJ IDEA only shows new output for that run. But the output from previous runs is still in the log file (assuming your logger is set up to append and not overwrite on new runs). When specifying the log name, you can use wild characters (to deal with things like a date stamp in the log). It use Ant fileset pattern notation. Click the help button on "Edit Log Files Aliases" dialog for more information. By default, IDEA only shows the latest log, unless you select the "Show all files coverable by pattern" on the "Edit Log Files Aliases".
Option 2 - Use a Script
Another option would be to use the "Save console file output to file" option. Then write an external script or Ant task that moves/renamed that output. (You could make it fancy so it only saves the last x runs, rolling the previous ones names.) Then in the run/debug configuration, use either the "Run External tool" or "Run Ant Target" option in the "Before Launch" section to run your script. (Again, you can set this on the default configurations so it is there automatically.) This way your script will run, renaming the file, before the new output is created and overwrites the old.
In addition to the options mentioned by Javaru, it is possible to tell IntelliJ to save all console outputs til a local file:
Edit Run Configuration -> Logs -> Save console output to file

unable to set breakpoint in intellij

I am trying to set breakpoints, nothing happens for couple of classes that I compiled recently with "mvn install". I am able to set breakpoints to classes which were already built by someone else.
Please let me know if anyone knows how to solve it.
Had the same issue while using IDEA CE 15:
Removing the Python CE plugin 5.0.143.103 fixed the issue... but no Python parsing! :(
File -> Invalidate Caches and Restart helped solve the problem. Thanks Tomasz Nurkiewicz for the directions
In my case, the issue was caused by PHP Plugin (https://plugins.jetbrains.com/plugin/?id=6610). Even after "Invalidate Caches and Restart", the issue persisted.
Uninstalling that PHP plugin, solved my problem.
By nothing happens do you mean that breakpoint isn't hit? Take a closer look at breakpoint icon. Especially see the difference between
and
icons. The latter indicates the code you run while debugging doesn't have any meaningful instruction on that line.
One of the reasons for such behaviour is when code you run is not the code you see. It can happen when application server can is still running old JAR or something similar. This seems to be the case since you say that breakpoints work in older code.
The solution to fixing breakpoints was adding the wildcard file extension "*.py" to the Python File Types in Python (it must have the wildcard symbol prefix, not just ".py") through taking these steps:
Go to:
IntelliJ IDE > Preferences (CMD+,) > Editor > File Types > Recognized
File Types
Under "Recognized File Types" heading:
Scroll down; Select "Python"
(associated Registered Patterns will be shown below)
Under "Registered Patterns" heading:
Click "+" icon; Enter "*.py", Click OK
(do whatever is necessary to achieve this, including removing/renaming others without the wildcard if necessary)
Add breakpoints by:
Select line(s) of code (not an empty line or comment); Going to: Run >
Toggle Line Breakpoint (CMD+F8)
Configure debugging with breakpoints by going to:
Run > Edit Configurations...; Click "+"; Select "Python"; Add a value
for the "Name" property; Select location of the ".py" file to debug
(in the "Script" property); Click OK
Debug using the breakpoints by going to:
Run > Debug... (Fn+CMD+F9); Wait until it stops at a breakpoint;
Inspect variable values shown in the file itself by hovering over
variable; Click variables and view the Frame and Variable details in
the Debug window by going to: View > Tool Windows > Debug (CMD+5)
Important Note: Initially I tried doing the following but after each one I was still unable to use breakpoints afterward:
Removing and reinstalling the Python plugin:
Entering CMD+,; In the dialog window going to Plugins > Install
Jetbrains Plugin.. > "Python" > Install
Updating IntelliJ Ultimate edition to the latest version v2016.3.4
Going to:
File > Invalidate Caches and Restart
Right click on the gutter (where you normally click to set breakpoint)
select "Configure Gutter Icons..." then enable the checkbox at the top that says
"Show gutter icons"
That fixed it for me
Simply closing and reopening file worked in setting gutter breakpoints
This is embarrassing but posting here in case this solution will help somebody else: A breakpoint will not show up if you attempt to place it between executable lines of code. The breakpoint must be located on an executable line of code to work. Make sure you click on the gutter next to an executable line or place your cursor on an executable line when you use the shortcut. Once I did this, the breakpoints worked.
"Click the gutter at the executable line of code where you want to set the breakpoint." https://www.jetbrains.com/help/idea/using-breakpoints.html#set-breakpoints

Submit Eclipse Project on Perforce

I have a noob Perforce question. I got my perforce plug-in on Eclipse working(for both Java and C).
I have no problems "opening" my perforce stored projects on Eclipse.
Scenario 1:
Whenever I want to change code, I open the project on Eclipse and right-click on it and go to "team" and check out, make changes and then submit. Works fine. But even after that I see a tick mark(indicating check-out) on my perforce screen.
Scenario 2:
I just open perforce code as Eclipse project and make changes(If read only, it prompts and asks if i have to allow write and I say yes). I make changes and save. It doesnt ask for submit. Also if I now open the code on Perforce screen, I already see the new changes made.
Scenario 3:
Just on a Perforce screen, if I check a file out and don't make any changes, I obviously dont want to submit as there are no changes. In this case, how can i "disable" check-out so that my fellow programmers dont think i'm working on it??
Scenario3:
So here are 2 ways i consider a good usage of the plugin:
Use Revert Unchanged Files:
Before you begin development of a feature, checkout the entire tree/branch that your changes will be concentrated around in future. You can do this by right-click the relevant package in package explorer. Once you want to submit, Project->Right-click->Team->Revert Unchanged Files. Now, you can submit your changelist.
This approach stands very useful if you know you will be editing a lot of files or replacing files.
Ofcourse, others can see that you have checked out the files.
Enable Auto checkout:
Incase you are going to make few changes, you should enable autocheckout. This will checkout the file when you begin to make edits. Eclipse->Preferences->Team->Perforce->Enable support for workbench edit..
detailed explainations here. Its a good idea to have this enabled always as it checks out on demand.
However, this does not monitor the filesystem so and code/libs you replace outside of eclipse are not checked out.
For Scenario 3, you can change a workspace option to prevent submitting unchanged files:
SubmitOptions: reverttunchanged
If you have a file checked out (open for edit), others will be able to see that. I guess I'm not clear on why you check a file out if you don't intend to modify it?
If you are going to setup this way and are also using the desktop client, I recommend the following steps in the desktop client:
1.) Open your desktop Perforce client
2.) Click “Connection” on the global menu
3.) Select “Edit Current Workspace…”
4.) Under the “Advanced” tab select “allwrite”
5.) Click Apply, then OK