Skip to content

Commit b7da700

Browse files
authored
Merge pull request #171 from xdev-software/2024.3
Changes for 2024.3
2 parents f436d4d + c211a45 commit b7da700

File tree

5 files changed

+30
-55
lines changed

5 files changed

+30
-55
lines changed

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
pluginGroup=software.xdev.saveactions
33
pluginName=Save Actions X
44
# SemVer format -> https://semver.org
5-
pluginVersion=1.3.2-SNAPSHOT
5+
pluginVersion=1.4.0-SNAPSHOT
66
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
77
platformType=IC
8-
platformVersion=2024.2.3
9-
platformSinceBuild=242
8+
platformVersion=243.21565.23
9+
platformSinceBuild=243
1010
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
1111
# Example: platformBundledPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
1212
platformBundledPlugins=com.intellij.java

src/main/java/software/xdev/saveactions/core/listener/SaveActionsDocumentManagerListener.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
import java.util.Objects;
66
import java.util.Set;
77
import java.util.stream.Collectors;
8-
import java.util.stream.Stream;
98

10-
import com.intellij.openapi.application.ApplicationInfo;
119
import com.intellij.openapi.diagnostic.Logger;
1210
import com.intellij.openapi.editor.Document;
1311
import com.intellij.openapi.fileEditor.FileDocumentManager;
@@ -43,12 +41,6 @@ public void beforeAllDocumentsSaving()
4341
LOGGER.debug(
4442
"[+] Start SaveActionsDocumentManagerListener#beforeAllDocumentsSaving, " + this.project.getName());
4543

46-
if(REQUIRES_PROJECT_LOAD_IGNORE_WORKAROUND && isInvokedFromProjectLoadBefore243())
47-
{
48-
LOGGER.debug("Ignoring due to PROJECT_LOAD_IGNORE_WORKAROUND");
49-
return;
50-
}
51-
5244
final List<Document> unsavedDocuments = Arrays.asList(FileDocumentManager.getInstance().getUnsavedDocuments());
5345
if(!unsavedDocuments.isEmpty())
5446
{
@@ -83,38 +75,4 @@ private synchronized void initPsiDocManager()
8375
this.psiDocumentManager = PsiDocumentManager.getInstance(this.project);
8476
}
8577
}
86-
87-
// region PROJECT_LOAD_IGNORE_WORKAROUND
88-
// https://github.com/xdev-software/intellij-plugin-save-actions/issues/145
89-
private static final boolean REQUIRES_PROJECT_LOAD_IGNORE_WORKAROUND =
90-
determineIfRequiresProjectLoadIgnoreWorkaround();
91-
92-
@SuppressWarnings("checkstyle:MagicNumber")
93-
static boolean determineIfRequiresProjectLoadIgnoreWorkaround()
94-
{
95-
try
96-
{
97-
// Problem was fixed in 2024.3
98-
return ApplicationInfo.getInstance().getBuild().getBaselineVersion() < 243;
99-
}
100-
catch(final Exception ex)
101-
{
102-
LOGGER.warn("Failed to determine IDE version", ex);
103-
return false;
104-
}
105-
}
106-
107-
@SuppressWarnings("checkstyle:MagicNumber")
108-
static boolean isInvokedFromProjectLoadBefore243()
109-
{
110-
// The invoking method ProjectSettingsTracker$submitSettingsFilesRefresh is usually at index 17 and 18
111-
return Stream.of(Thread.currentThread().getStackTrace())
112-
.map(StackTraceElement::getClassName)
113-
.skip(16)
114-
.limit(5)
115-
.anyMatch(s -> s.startsWith(
116-
"com.intellij.openapi.externalSystem.autoimport.ProjectSettingsTracker$submitSettingsFilesRefresh"));
117-
}
118-
119-
// endregion
12078
}

src/main/java/software/xdev/saveactions/processors/BuildProcessor.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
import com.intellij.debugger.impl.DebuggerSession;
1818
import com.intellij.debugger.ui.HotSwapUI;
1919
import com.intellij.openapi.actionSystem.ActionManager;
20+
import com.intellij.openapi.actionSystem.ActionUiKind;
2021
import com.intellij.openapi.actionSystem.AnAction;
2122
import com.intellij.openapi.actionSystem.AnActionEvent;
2223
import com.intellij.openapi.actionSystem.DataContext;
24+
import com.intellij.openapi.actionSystem.ex.ActionUtil;
2325
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
26+
import com.intellij.openapi.application.ApplicationManager;
2427
import com.intellij.openapi.compiler.CompilerManager;
2528
import com.intellij.openapi.fileEditor.FileEditorManager;
2629
import com.intellij.openapi.project.Project;
@@ -83,8 +86,16 @@ public enum BuildProcessor implements Processor
8386
.add(EDITOR, FileEditorManager.getInstance(project).getSelectedTextEditor())
8487
.setParent(null)
8588
.build();
86-
AnActionEvent event = AnActionEvent.createFromAnAction(anAction, null, UNKNOWN, dataContext);
87-
anAction.actionPerformed(event);
89+
AnActionEvent event = AnActionEvent.createEvent(
90+
dataContext,
91+
anAction.getTemplatePresentation().clone(),
92+
UNKNOWN,
93+
ActionUiKind.NONE,
94+
null);
95+
96+
// Run Action on EDT thread
97+
ApplicationManager.getApplication().invokeLater(() ->
98+
ActionUtil.performActionDumbAwareWithCallbacks(anAction, event));
8899
}
89100
})
90101
{

src/main/java/software/xdev/saveactions/ui/java/IdeSupportPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private TextFieldWithBrowseButton getPath(final String configurationPath)
7878
field.getField().setEnabled(false);
7979
field.getField().setText(configurationPath);
8080
final TextFieldWithBrowseButton resultPath = new TextFieldWithBrowseButton(field.getField());
81-
resultPath.addBrowseFolderListener(null, null, null, descriptor, TEXT_FIELD_WHOLE_TEXT);
81+
resultPath.addBrowseFolderListener(null, descriptor, TEXT_FIELD_WHOLE_TEXT);
8282
return resultPath;
8383
}
8484

src/test/java/software/xdev/saveactions/core/action/ShortcutActionConstants.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.function.Consumer;
77

88
import com.intellij.openapi.actionSystem.ActionManager;
9+
import com.intellij.openapi.actionSystem.ActionUiKind;
910
import com.intellij.openapi.actionSystem.AnAction;
1011
import com.intellij.openapi.actionSystem.AnActionEvent;
1112
import com.intellij.openapi.actionSystem.DataContext;
@@ -16,26 +17,31 @@
1617

1718
public interface ShortcutActionConstants
1819
{
19-
20-
Consumer<CodeInsightTestFixture> SAVE_ACTION_SHORTCUT_MANAGER = (fixture) ->
20+
Consumer<CodeInsightTestFixture> SAVE_ACTION_SHORTCUT_MANAGER = fixture ->
2121
WriteCommandAction.writeCommandAction(fixture.getProject()).run(() -> runFixure(fixture));
2222

23-
static void runFixure(CodeInsightTestFixture fixture)
23+
static void runFixure(final CodeInsightTestFixture fixture)
2424
{
2525
// set modification timestamp ++
2626
fixture.getFile().clearCaches();
2727

28-
ActionManager actionManager = ActionManager.getInstance();
29-
AnAction action = actionManager.getAction(ShortcutAction.class.getName());
28+
final ActionManager actionManager = ActionManager.getInstance();
29+
final AnAction action = actionManager.getAction(ShortcutAction.class.getName());
3030

31-
DataContext dataContext = SimpleDataContext.builder()
31+
final DataContext dataContext = SimpleDataContext.builder()
3232
.add(PROJECT, fixture.getProject())
3333
.add(PSI_FILE, fixture.getFile())
3434
.setParent(null)
3535
.build();
3636

3737
// call plugin on document
38-
AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "save-actions", dataContext);
38+
final AnActionEvent event = AnActionEvent.createEvent(
39+
dataContext,
40+
action.getTemplatePresentation().clone(),
41+
"save-actions",
42+
ActionUiKind.NONE,
43+
null);
44+
3945
new ShortcutAction().actionPerformed(event);
4046
}
4147
}

0 commit comments

Comments
 (0)