dubreuia / intellij-plugin-save-actions

Supports configurable, Eclipse like, save actions, including "organize imports", "reformat code" and "rearrange code".
MIT License
531 stars 101 forks source link

Code does not format for files not checked into git #342

Open viedt opened 3 years ago

viedt commented 3 years ago

Describe the bug This issue was previously reported in #188 and appears to be back in version 2.2.0. When a file is not checked into git, it does not trigger the save actions at all.

What triggered the plugin Any new file not tracked by git seems to reproduce this issue.

Versions IntelliJ IDEA 2020.2.2 (Community Edition) Build #IC-202.7319.50, built on September 14, 2020 Runtime version: 11.0.8+10-b944.31 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 GC: ParNew, ConcurrentMarkSweep Memory: 1979M Cores: 16 Non-Bundled Plugins: com.dubreuia, org.sonarlint.idea, org.jetbrains.kotlin, com.bruce.intellijplugin.generatesetter

viedt commented 3 years ago

Looking at your other bug reports this may be related to switching to Visual Studio key mapping as well. I switched to that and noticed it at first and switched back to windows and it still didn't work, so I'm not entirely sure which one is the root cause, but everything worked after I checked in the new file with windows keymap. I switched to Visual Studio again and it didn't work for any file, then switch back to Windows keymap and it works again as well.

dubreuia commented 3 years ago

Hey @viedt sorry I missed this issue, but thank you for letting me know. This is a long standing issue I was never able to reproduce. If you are able to reproduce consistently, can you post your idea.log please? Thanks

viedt commented 3 years ago

saveactions_settings.xml `<?xml version="1.0" encoding="UTF-8"?>

` Relevant part of idea.log `2020-12-03 15:26:44,884 [26585692] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:26:44,884 [26585692] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:26:44,884 [26585692] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:27:58,421 [26659229] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:27:58,421 [26659229] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:27:58,421 [26659229] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:31:47,346 [26888154] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:31:47,346 [26888154] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:31:47,346 [26888154] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:32:19,041 [26919849] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:32:19,042 [26919850] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:32:19,042 [26919850] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:32:54,560 [26955368] INFO - ntellij.analysis.SonarLintTask - Running SonarLint Analysis for 'CalculateDatesRunnable.java' 2020-12-03 15:32:54,753 [26955561] INFO - ntellij.analysis.SonarLintTask - SonarLint analysis done 2020-12-03 15:33:06,448 [26967256] INFO - ntellij.analysis.SonarLintTask - Running SonarLint Analysis for 'CalculateDatesRunnable.java' 2020-12-03 15:33:06,625 [26967433] INFO - ntellij.analysis.SonarLintTask - SonarLint analysis done 2020-12-03 15:33:09,851 [26970659] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:33:09,851 [26970659] INFO - re.component.SaveActionManager - Locating psi files for 1 documents: [DocumentImpl[file://C:/Projects/tstrackerservice/src/main/java/com/tst/web/runnables/CalculateDatesRunnable.java]] 2020-12-03 15:33:09,851 [26970659] INFO - re.component.SaveActionManager - Processing Project(name=tstrackerservice, containerState=COMPONENT_CREATED, componentStore=C:\Projects\tstrackerservice) files [PsiJavaFile:CalculateDatesRunnable.java] mode saveAll 2020-12-03 15:33:09,851 [26970659] INFO - re.component.SaveActionManager - Valid files [PsiJavaFile:CalculateDatesRunnable.java] 2020-12-03 15:33:09,851 [26970659] INFO - re.component.SaveActionManager - Start processors (26) 2020-12-03 15:33:09,851 [26970659] INFO - re.component.SaveActionManager - Filtered processors [organizeImports, reformat, missingOverrideAnnotation, useBlocks, unnecessaryThis, unnecessaryFinalOnLocalVariableOrParameter] 2020-12-03 15:33:09,851 [26970659] INFO - re.component.SaveActionManager - Execute command organizeImports on 1 files 2020-12-03 15:33:09,891 [26970699] INFO - re.component.SaveActionManager - Execute command reformat on 1 files 2020-12-03 15:33:09,925 [26970733] INFO - re.component.SaveActionManager - Execute command missingOverrideAnnotation on 1 files 2020-12-03 15:33:09,934 [26970742] INFO - re.component.SaveActionManager - Execute command useBlocks on 1 files 2020-12-03 15:33:09,936 [26970744] INFO - re.component.SaveActionManager - Execute command unnecessaryThis on 1 files 2020-12-03 15:33:09,937 [26970745] INFO - re.component.SaveActionManager - Execute command unnecessaryFinalOnLocalVariableOrParameter on 1 files 2020-12-03 15:33:09,940 [26970748] INFO - re.component.SaveActionManager - Exit engine with results [organizeImports:OK, reformat:OK, missingOverrideAnnotation:OK, useBlocks:OK, unnecessaryThis:OK, unnecessaryFinalOnLocalVariableOrParameter:OK] 2020-12-03 15:33:09,940 [26970748] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:33:11,999 [26972807] INFO - ntellij.analysis.SonarLintTask - Running SonarLint Analysis for 'CalculateDatesRunnable.java' 2020-12-03 15:33:12,171 [26972979] INFO - ntellij.analysis.SonarLintTask - SonarLint analysis done 2020-12-03 15:33:37,455 [26998263] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:33:37,455 [26998263] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:33:37,455 [26998263] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:35:22,166 [27102974] INFO - ta.index.VcsLogPersistentIndex - Indexing 1 commits in tstrackerservice 2020-12-03 15:35:22,266 [27103074] INFO - ta.index.VcsLogPersistentIndex - 100ms for indexing 1 new commits out of 1 in tstrackerservice 2020-12-03 15:36:34,713 [27175521] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:36:34,713 [27175521] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:36:34,713 [27175521] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:40:58,939 [27439747] INFO - om.intellij.ui.WinFocusStealer - Foreground lock timeout set to 0 2020-12-03 15:40:59,001 [27439809] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:40:59,001 [27439809] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:40:59,001 [27439809] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:40:59,022 [27439830] INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS) 2020-12-03 15:40:59,024 [27439832] INFO - j.compiler.server.BuildManager - Using preloaded build process to compile C:/Projects/tstrackerservice 2020-12-03 15:41:00,676 [27441484] INFO - lij.compiler.impl.CompilerUtil - COMPILATION FINISHED (BUILD PROCESS); Errors: 0; warnings: 0 took 1674 ms: 0 min 1sec 2020-12-03 15:41:00,680 [27441488] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:41:00,680 [27441488] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:41:00,680 [27441488] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:41:00,700 [27441508] INFO - ij.execution.JavaExecutionUtil - Agent jars were copied to C:\Users\philb\AppData\Local\JetBrains\IdeaIC2020.3\groovyHotSwap 2020-12-03 15:41:00,778 [27441586] INFO - ij.execution.JavaExecutionUtil - Agent jars were copied to C:\Users\philb\AppData\Local\JetBrains\IdeaIC2020.3\captureAgent 2020-12-03 15:41:01,084 [27441892] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2019.3.4/plugins/java/lib/jps-launcher.jar 2020-12-03 15:41:01,136 [27441944] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 2020-12-03 15:41:01,136 [27441944] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation 2020-12-03 15:41:01,136 [27441944] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 2020-12-03 15:41:01,778 [27442586] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:41:01,778 [27442586] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:41:01,778 [27442586] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:41:02,104 [27442912] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: An illegal reflective access operation has occurred 2020-12-03 15:41:02,104 [27442912] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil (file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%20Community%20Edition%202019.3.4/lib/util.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle) 2020-12-03 15:41:02,104 [27442912] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil 2020-12-03 15:41:02,104 [27442912] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations 2020-12-03 15:41:02,104 [27442912] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: All illegal access operations will be denied in a future release 2020-12-03 15:41:04,932 [27445740] INFO - om.intellij.ui.WinFocusStealer - Foreground lock timeout set to 200000 2020-12-03 15:41:15,658 [27456466] INFO - om.intellij.ui.WinFocusStealer - Foreground lock timeout set to 0 2020-12-03 15:41:15,669 [27456477] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:41:15,669 [27456477] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:41:15,669 [27456477] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:41:15,673 [27456481] INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS) 2020-12-03 15:41:15,675 [27456483] INFO - j.compiler.server.BuildManager - Using preloaded build process to compile C:/Projects/tstrackerservice 2020-12-03 15:41:15,799 [27456607] INFO - lij.compiler.impl.CompilerUtil - COMPILATION FINISHED (BUILD PROCESS); Errors: 0; warnings: 0 took 130 ms: 0 min 0sec 2020-12-03 15:41:15,802 [27456610] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:41:15,802 [27456610] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:41:15,802 [27456610] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:41:15,823 [27456631] INFO - ij.execution.JavaExecutionUtil - Agent jars were copied to C:\Users\philb\AppData\Local\JetBrains\IdeaIC2020.3\groovyHotSwap 2020-12-03 15:41:15,897 [27456705] INFO - ij.execution.JavaExecutionUtil - Agent jars were copied to C:\Users\philb\AppData\Local\JetBrains\IdeaIC2020.3\captureAgent 2020-12-03 15:41:16,174 [27456982] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2019.3.4/plugins/java/lib/jps-launcher.jar 2020-12-03 15:41:16,223 [27457031] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 2020-12-03 15:41:16,223 [27457031] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation 2020-12-03 15:41:16,223 [27457031] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 2020-12-03 15:41:17,120 [27457928] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: An illegal reflective access operation has occurred 2020-12-03 15:41:17,120 [27457928] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil (file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%20Community%20Edition%202019.3.4/lib/util.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle) 2020-12-03 15:41:17,120 [27457928] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil 2020-12-03 15:41:17,120 [27457928] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations 2020-12-03 15:41:17,120 [27457928] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: All illegal access operations will be denied in a future release 2020-12-03 15:41:17,434 [27458242] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:41:17,434 [27458242] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:41:17,434 [27458242] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:42:39,221 [27540029] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:42:39,221 [27540029] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:42:39,221 [27540029] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:43:12,674 [27573482] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:43:12,674 [27573482] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:43:12,674 [27573482] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:45:19,919 [27700727] INFO - .script.IdeScriptEngineManager - javax.script.ScriptEngineManager initialized in 314 ms 2020-12-03 15:46:06,102 [27746910] WARN - ConfigurableExtensionPointUtil - ignore deprecated groupId: language for id: preferences.language.Kotlin.scripting 2020-12-03 15:46:06,124 [27746932] WARN - ConfigurableExtensionPointUtil - use other group instead of unexpected one: build.android 2020-12-03 15:46:20,321 [27761129] INFO - ntellij.analysis.SonarLintTask - Running SonarLint Analysis for 'CalculateDatesRunnable.java' 2020-12-03 15:46:20,480 [27761288] INFO - ntellij.analysis.SonarLintTask - SonarLint analysis done 2020-12-03 15:46:41,483 [27782291] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:46:41,483 [27782291] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:46:41,483 [27782291] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:47:34,463 [27835271] INFO - om.intellij.ui.WinFocusStealer - Foreground lock timeout set to 200000 2020-12-03 15:47:40,901 [27841709] INFO - ntellij.analysis.SonarLintTask - Running SonarLint Analysis for 'CalculateDatesRunnable.java' 2020-12-03 15:47:41,057 [27841865] INFO - ntellij.analysis.SonarLintTask - SonarLint analysis done 2020-12-03 15:47:48,220 [27849028] WARN - ConfigurableExtensionPointUtil - ignore deprecated groupId: language for id: preferences.language.Kotlin.scripting 2020-12-03 15:47:48,221 [27849029] WARN - ConfigurableExtensionPointUtil - use other group instead of unexpected one: build.android 2020-12-03 15:47:54,007 [27854815] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:47:54,007 [27854815] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:47:54,007 [27854815] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:47:56,103 [27856911] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:47:56,103 [27856911] INFO - re.component.SaveActionManager - Locating psi files for 1 documents: [DocumentImpl[file://C:/Projects/tstrackerservice/src/main/java/com/tst/web/runnables/CalculateDatesRunnable.java]] 2020-12-03 15:47:56,103 [27856911] INFO - re.component.SaveActionManager - Processing Project(name=tstrackerservice, containerState=COMPONENT_CREATED, componentStore=C:\Projects\tstrackerservice) files [PsiJavaFile:CalculateDatesRunnable.java] mode saveAll 2020-12-03 15:47:56,103 [27856911] INFO - re.component.SaveActionManager - Valid files [PsiJavaFile:CalculateDatesRunnable.java] 2020-12-03 15:47:56,103 [27856911] INFO - re.component.SaveActionManager - Start processors (26) 2020-12-03 15:47:56,103 [27856911] INFO - re.component.SaveActionManager - Filtered processors [organizeImports, reformat, missingOverrideAnnotation, useBlocks, unnecessaryThis, unnecessaryFinalOnLocalVariableOrParameter] 2020-12-03 15:47:56,103 [27856911] INFO - re.component.SaveActionManager - Execute command organizeImports on 1 files 2020-12-03 15:47:56,111 [27856919] INFO - re.component.SaveActionManager - Execute command reformat on 1 files 2020-12-03 15:47:56,140 [27856948] INFO - re.component.SaveActionManager - Execute command missingOverrideAnnotation on 1 files 2020-12-03 15:47:56,149 [27856957] INFO - re.component.SaveActionManager - Execute command useBlocks on 1 files 2020-12-03 15:47:56,151 [27856959] INFO - re.component.SaveActionManager - Execute command unnecessaryThis on 1 files 2020-12-03 15:47:56,152 [27856960] INFO - re.component.SaveActionManager - Execute command unnecessaryFinalOnLocalVariableOrParameter on 1 files 2020-12-03 15:47:56,154 [27856962] INFO - re.component.SaveActionManager - Exit engine with results [organizeImports:OK, reformat:OK, missingOverrideAnnotation:OK, useBlocks:OK, unnecessaryThis:OK, unnecessaryFinalOnLocalVariableOrParameter:OK] 2020-12-03 15:47:56,154 [27856962] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:47:58,340 [27859148] INFO - ntellij.analysis.SonarLintTask - Running SonarLint Analysis for 'CalculateDatesRunnable.java' 2020-12-03 15:47:58,508 [27859316] INFO - ntellij.analysis.SonarLintTask - SonarLint analysis done 2020-12-03 15:47:58,614 [27859422] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:47:58,614 [27859422] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:47:58,614 [27859422] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:48:04,987 [27865795] INFO - re.component.SaveActionManager - [+] Start SaveActionManager#beforeAllDocumentsSaving 2020-12-03 15:48:04,987 [27865795] INFO - re.component.SaveActionManager - Locating psi files for 0 documents: [] 2020-12-03 15:48:04,987 [27865795] INFO - re.component.SaveActionManager - End SaveActionManager#beforeAllDocumentsSaving ` In the above log, I switched to Visual Studio added a few spaces to an existing file, and hit ctrl+s. Nothing happened, switched back to Windows and added another space and hit ctrl+s and it formatted the file again. Hope this helps.
dubreuia commented 3 years ago

@viedt Thank you very much for this. I'll try reproducing using your keymap method, but now I'm thinking we have the same issue with the ideavim keymapping (see #220 and #222) so it might be related.

KaiHufenbach commented 3 years ago

Hey, I have the same error, but the difference is, that I have set a keymap based on Eclipse for MacOS. Save Actions work when starting them explicitly but not on auto save. Changing the keymap to something else and back solved my problem.

dubreuia commented 3 years ago

Ok @KaiHufenbach, interesting :thinking:

Just for anyone reading this: current workaround is make sure that CTRL+S is mapped to the "Save all" action (NOT "Save").