Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8f33dbf
Update latest IntelliJ version
AB-xdev Sep 26, 2024
76acd7d
Merge pull request #163 from xdev-software/master
AB-xdev Sep 26, 2024
8e548b7
Remove outdated doc
AB-xdev Sep 26, 2024
184b80e
Update pmdVersion to v7.6.0
xdev-renovate Sep 27, 2024
72ffbf2
Merge pull request #52 from xdev-software/renovate/pmdversion
AB-xdev Sep 27, 2024
d10f7a7
Update checkstyleVersion to v10.18.2
xdev-renovate Sep 30, 2024
af9df1e
Merge branch 'develop' into update-from-template-merged
xdev-gh-bot Sep 30, 2024
8c09158
Update dependency org.junit:junit-bom to v5.11.2
xdev-renovate Oct 5, 2024
314f874
Merge pull request #53 from xdev-software/renovate/checkstyleversion
AB-xdev Oct 7, 2024
0aec173
Merge pull request #54 from xdev-software/renovate/org.junit-junit-bo…
AB-xdev Oct 7, 2024
1967712
Update lycheeverse/lychee-action action to v2
xdev-renovate Oct 9, 2024
0e0b2ff
Merge pull request #9 from xdev-software/renovate/lycheeverse-lychee-…
AB-xdev Oct 9, 2024
4f506c6
Merge branch 'master' into update-from-template-merged
xdev-gh-bot Oct 9, 2024
596c9be
Merge branch 'develop' into update-from-template-merged
xdev-gh-bot Oct 11, 2024
e6ba916
Merge pull request #170 from xdev-software/update-from-template-merged
AB-xdev Oct 11, 2024
3759a1b
Don't run tests for sonar
AB-xdev Oct 11, 2024
2ce2950
Merge branch 'develop' into update-from-template-merged
xdev-gh-bot Oct 11, 2024
029bf2f
Don't fail on broken links
AB-xdev Oct 21, 2024
c48913a
Merge branch 'master' into update-from-template-merged
xdev-gh-bot Oct 22, 2024
6c26886
Update dependency org.junit:junit-bom to v5.11.3
xdev-renovate Oct 22, 2024
7cf4f90
Merge pull request #58 from xdev-software/renovate/org.junit-junit-bo…
AB-xdev Oct 22, 2024
009f795
Initial commit
AB-xdev Oct 24, 2024
efcd43e
Init
AB-xdev Oct 24, 2024
eeb917d
Merge remote-tracking branch 'origin/update-from-template'
AB-xdev Oct 24, 2024
dbb02f5
Merge branch 'master' into update-from-template-merged
xdev-gh-bot Oct 24, 2024
274634e
Merge branch 'develop' into update-from-template-merged
xdev-gh-bot Oct 28, 2024
d13b2de
Changes for PMD 7.7
AB-xdev Oct 28, 2024
88f8f0c
Merge branch 'master' into update-from-template-merged
xdev-gh-bot Oct 28, 2024
9e9f2a9
Tighten timeouts
AB-xdev Oct 30, 2024
93ebb1b
Merge branch 'master' into update-from-template-merged
xdev-gh-bot Oct 30, 2024
de2608e
Tighten timeouts
AB-xdev Oct 30, 2024
0a79ae6
Update pmdVersion to v7.7.0
xdev-renovate Oct 31, 2024
30ef67f
Merge pull request #60 from xdev-software/renovate/pmdversion
AB-xdev Oct 31, 2024
7776097
Update checkstyleVersion to v10.19.0
xdev-renovate Oct 31, 2024
9a53e01
Merge pull request #61 from xdev-software/renovate/checkstyleversion
AB-xdev Oct 31, 2024
ab2ae68
Update checkstyleVersion to v10.20.0
xdev-renovate Nov 1, 2024
101b5b7
Merge branch 'develop' into update-from-template-merged
xdev-gh-bot Nov 4, 2024
94567ad
Merge pull request #64 from xdev-software/renovate/checkstyleversion
AB-xdev Nov 4, 2024
3f02045
Update checkstyleVersion to v10.20.1
xdev-renovate Nov 8, 2024
de6330a
Merge branch 'develop' into update-from-template-merged
xdev-gh-bot Nov 11, 2024
fd2f809
Merge pull request #65 from xdev-software/renovate/checkstyleversion
AB-xdev Nov 11, 2024
aae61c0
Merge branch 'develop' into update-from-template-merged
xdev-gh-bot Nov 11, 2024
f436d4d
Merge pull request #181 from xdev-software/update-from-template-merged
AB-xdev Nov 11, 2024
8e07ea8
Bump version
AB-xdev Oct 11, 2024
6ff9372
Switch to 243 EAP
AB-xdev Oct 11, 2024
0daa31c
Fix deprecation of ``AnActionEvent.createFromAnAction``
AB-xdev Oct 11, 2024
2058ccc
Remove workaround for project load
AB-xdev Oct 11, 2024
75f9a67
Fix deprecation of ``ComponentWithBrowseButton.addBrowseFolderListener``
AB-xdev Oct 11, 2024
8b12a4e
Add missing clone
AB-xdev Oct 11, 2024
460605e
Update to latest EAP
AB-xdev Oct 31, 2024
c211a45
Fix override-only violation: ``AnAction.actionPerformed(AnActionEvent)``
AB-xdev Oct 31, 2024
b7da700
Merge pull request #171 from xdev-software/2024.3
AB-xdev Nov 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .config/pmd/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,12 @@
<exclude name="UseStringBufferForStringAppends"/>
</rule>

<rule ref="category/java/performance.xml/TooFewBranchesForSwitch">
<properties>
<!-- If you have one case only please use a if -->
<property name="minimumNumberCaseForASwitch" value="2"/>
</properties>
</rule>

<rule ref="category/java/security.xml"/>
</ruleset>
5 changes: 4 additions & 1 deletion .github/workflows/broken-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ permissions:
jobs:
link-checker:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4

- run: mv .github/.lycheeignore .lycheeignore

- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1
uses: lycheeverse/lychee-action@v2
with:
fail: false # Don't fail on broken links, create an issue instead

- name: Find already existing issue
id: find-issue
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30

strategy:
matrix:
Expand Down Expand Up @@ -76,6 +77,7 @@ jobs:
checkstyle:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
timeout-minutes: 15

strategy:
matrix:
Expand All @@ -98,6 +100,7 @@ jobs:
pmd:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
timeout-minutes: 15

strategy:
matrix:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ permissions:
pull-requests: write

jobs:
check_code: # Validates the code
check_code:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -45,6 +46,7 @@ jobs:
prepare_release:
runs-on: ubuntu-latest
needs: [check_code]
timeout-minutes: 10
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
Expand Down Expand Up @@ -99,6 +101,7 @@ jobs:
publish:
runs-on: ubuntu-latest
needs: [prepare_release]
timeout-minutes: 60
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -132,6 +135,7 @@ jobs:
after_release:
runs-on: ubuntu-latest
needs: [publish]
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
token-check:
runs-on: ubuntu-latest
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) }}
timeout-minutes: 5
outputs:
hasToken: ${{ steps.check-token.outputs.has }}
steps:
Expand All @@ -40,6 +41,7 @@ jobs:
runs-on: ubuntu-latest
needs: token-check
if: ${{ needs.token-check.outputs.hasToken }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -67,7 +69,7 @@ jobs:

- name: Build
run: |
./gradlew build sonarqube --info \
./gradlew build sonarqube -x test --info \
-Dsonar.projectKey=${{ env.SONARCLOUD_ORG }}_${{ github.event.repository.name }} \
-Dsonar.organization=${{ env.SONARCLOUD_ORG }} \
-Dsonar.host.url=${{ env.SONARCLOUD_HOST }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ permissions:
jobs:
labels:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/update-from-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ permissions:
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
update_branch_merged_commit: ${{ steps.manage-branches.outputs.update_branch_merged_commit }}
create_update_branch_merged_pr: ${{ steps.manage-branches.outputs.create_update_branch_merged_pr }}
Expand Down Expand Up @@ -180,6 +181,7 @@ jobs:
needs: [update]
if: needs.update.outputs.create_update_branch_merged_pr == 1
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ plugins {
}

ext {
checkstyleVersion = '10.18.1'
pmdVersion = '7.5.0'
checkstyleVersion = '10.20.1'
pmdVersion = '7.7.0'
}

def properties(String key) {
Expand Down Expand Up @@ -58,7 +58,7 @@ dependencies {
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
pmd "net.sourceforge.pmd:pmd-ant:${pmdVersion}",
"net.sourceforge.pmd:pmd-java:${pmdVersion}"
testImplementation platform('org.junit:junit-bom:5.11.1'),
testImplementation platform('org.junit:junit-bom:5.11.3'),
'org.junit.jupiter:junit-jupiter',
'org.junit.jupiter:junit-jupiter-engine',
'org.assertj:assertj-core:3.26.3'
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pluginGroup=software.xdev.saveactions
pluginName=Save Actions X
# SemVer format -> https://semver.org
pluginVersion=1.3.2-SNAPSHOT
pluginVersion=1.4.0-SNAPSHOT
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType=IC
platformVersion=2024.2.2
platformSinceBuild=242
platformVersion=243.21565.23
platformSinceBuild=243
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformBundledPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformBundledPlugins=com.intellij.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
Expand Down Expand Up @@ -43,12 +41,6 @@ public void beforeAllDocumentsSaving()
LOGGER.debug(
"[+] Start SaveActionsDocumentManagerListener#beforeAllDocumentsSaving, " + this.project.getName());

if(REQUIRES_PROJECT_LOAD_IGNORE_WORKAROUND && isInvokedFromProjectLoadBefore243())
{
LOGGER.debug("Ignoring due to PROJECT_LOAD_IGNORE_WORKAROUND");
return;
}

final List<Document> unsavedDocuments = Arrays.asList(FileDocumentManager.getInstance().getUnsavedDocuments());
if(!unsavedDocuments.isEmpty())
{
Expand Down Expand Up @@ -83,38 +75,4 @@ private synchronized void initPsiDocManager()
this.psiDocumentManager = PsiDocumentManager.getInstance(this.project);
}
}

// region PROJECT_LOAD_IGNORE_WORKAROUND
// https://github.com/xdev-software/intellij-plugin-save-actions/issues/145
private static final boolean REQUIRES_PROJECT_LOAD_IGNORE_WORKAROUND =
determineIfRequiresProjectLoadIgnoreWorkaround();

@SuppressWarnings("checkstyle:MagicNumber")
static boolean determineIfRequiresProjectLoadIgnoreWorkaround()
{
try
{
// Problem was fixed in 2024.3
return ApplicationInfo.getInstance().getBuild().getBaselineVersion() < 243;
}
catch(final Exception ex)
{
LOGGER.warn("Failed to determine IDE version", ex);
return false;
}
}

@SuppressWarnings("checkstyle:MagicNumber")
static boolean isInvokedFromProjectLoadBefore243()
{
// The invoking method ProjectSettingsTracker$submitSettingsFilesRefresh is usually at index 17 and 18
return Stream.of(Thread.currentThread().getStackTrace())
.map(StackTraceElement::getClassName)
.skip(16)
.limit(5)
.anyMatch(s -> s.startsWith(
"com.intellij.openapi.externalSystem.autoimport.ProjectSettingsTracker$submitSettingsFilesRefresh"));
}

// endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
* The psi files are ide wide, that means they are shared between projects (and editor windows), so we need to check if
* the file is physically in that project before reformatting, or else the file is formatted twice and intellij will ask
* to confirm unlocking of non-project file in the other project, see {@link Engine} for more details.
*
* @since 2.4.0
*/
abstract class AbstractSaveActionsService implements SaveActionsService
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* <p/>
*
* @see AbstractSaveActionsService
* @since 2.4.0
*/
public final class SaveActionsDefaultService extends AbstractSaveActionsService
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* <p/>
*
* @see AbstractSaveActionsService
* @since 2.4.0
*/
public final class SaveActionsJavaService extends AbstractSaveActionsService
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.ui.HotSwapUI;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionUiKind;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.compiler.CompilerManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
Expand Down Expand Up @@ -83,8 +86,16 @@ public enum BuildProcessor implements Processor
.add(EDITOR, FileEditorManager.getInstance(project).getSelectedTextEditor())
.setParent(null)
.build();
AnActionEvent event = AnActionEvent.createFromAnAction(anAction, null, UNKNOWN, dataContext);
anAction.actionPerformed(event);
AnActionEvent event = AnActionEvent.createEvent(
dataContext,
anAction.getTemplatePresentation().clone(),
UNKNOWN,
ActionUiKind.NONE,
null);

// Run Action on EDT thread
ApplicationManager.getApplication().invokeLater(() ->
ActionUtil.performActionDumbAwareWithCallbacks(anAction, event));
}
})
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private TextFieldWithBrowseButton getPath(final String configurationPath)
field.getField().setEnabled(false);
field.getField().setText(configurationPath);
final TextFieldWithBrowseButton resultPath = new TextFieldWithBrowseButton(field.getField());
resultPath.addBrowseFolderListener(null, null, null, descriptor, TEXT_FIELD_WHOLE_TEXT);
resultPath.addBrowseFolderListener(null, descriptor, TEXT_FIELD_WHOLE_TEXT);
return resultPath;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.function.Consumer;

import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionUiKind;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
Expand All @@ -16,26 +17,31 @@

public interface ShortcutActionConstants
{

Consumer<CodeInsightTestFixture> SAVE_ACTION_SHORTCUT_MANAGER = (fixture) ->
Consumer<CodeInsightTestFixture> SAVE_ACTION_SHORTCUT_MANAGER = fixture ->
WriteCommandAction.writeCommandAction(fixture.getProject()).run(() -> runFixure(fixture));

static void runFixure(CodeInsightTestFixture fixture)
static void runFixure(final CodeInsightTestFixture fixture)
{
// set modification timestamp ++
fixture.getFile().clearCaches();

ActionManager actionManager = ActionManager.getInstance();
AnAction action = actionManager.getAction(ShortcutAction.class.getName());
final ActionManager actionManager = ActionManager.getInstance();
final AnAction action = actionManager.getAction(ShortcutAction.class.getName());

DataContext dataContext = SimpleDataContext.builder()
final DataContext dataContext = SimpleDataContext.builder()
.add(PROJECT, fixture.getProject())
.add(PSI_FILE, fixture.getFile())
.setParent(null)
.build();

// call plugin on document
AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "save-actions", dataContext);
final AnActionEvent event = AnActionEvent.createEvent(
dataContext,
action.getTemplatePresentation().clone(),
"save-actions",
ActionUiKind.NONE,
null);

new ShortcutAction().actionPerformed(event);
}
}