diff --git a/.github/workflows/CIBuild.yml b/.github/workflows/CIBuild.yml index 5c104918..7d3b5e2d 100644 --- a/.github/workflows/CIBuild.yml +++ b/.github/workflows/CIBuild.yml @@ -56,10 +56,10 @@ jobs: # and modify them (or add more) to build your code if your project # uses a compiled language - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: - java-version: '17' + java-version: '21' distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/.github/workflows/CoverallsReport.yml b/.github/workflows/CoverallsReport.yml index 40a1b0fc..1af330a4 100644 --- a/.github/workflows/CoverallsReport.yml +++ b/.github/workflows/CoverallsReport.yml @@ -14,16 +14,16 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: - java-version: '17' + java-version: '21' distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle env: - IDEA_VERSION: 2024.1 + IDEA_VERSION: 2024.2.1 run: xvfb-run ./gradlew test - name: Coveralls uses: coverallsapp/github-action@v2.3.0 diff --git a/.github/workflows/CronEAP.yml b/.github/workflows/CronEAP.yml index c600f92f..c15eead0 100644 --- a/.github/workflows/CronEAP.yml +++ b/.github/workflows/CronEAP.yml @@ -14,16 +14,16 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: - java-version: '17' + java-version: '21' distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle env: IDEA_PLATFORM: IC - IDEA_VERSION: 2024.1 + IDEA_VERSION: 2024.2.1 IDEA_SOURCES: false run: xvfb-run ./gradlew verifyPlugin diff --git a/.github/workflows/PublishStable.yml b/.github/workflows/PublishStable.yml index 297e5846..177db23a 100644 --- a/.github/workflows/PublishStable.yml +++ b/.github/workflows/PublishStable.yml @@ -16,14 +16,14 @@ jobs: fail-fast: false matrix: include: - - ideaVersion: 2024.1 + - ideaVersion: 2024.2.1 steps: - uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: - java-version: '17' + java-version: '21' distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/.github/workflows/PullRequest.yml b/.github/workflows/PullRequest.yml index 2a2442bf..f22257ef 100644 --- a/.github/workflows/PullRequest.yml +++ b/.github/workflows/PullRequest.yml @@ -16,17 +16,17 @@ jobs: fail-fast: false matrix: include: - - ideaVersion: 2024.1.1 + - ideaVersion: 2024.2.1 ideaPlatform: IC - ideaVersion: 2024.2.1 ideaPlatform: PY steps: - uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: - java-version: '17' + java-version: '21' distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/README.md b/README.md index 53f9dbeb..4dba2b05 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ This enables default editor features like syntax validation, highlighting and in Release 4.* is focusing on text-editor features. Text-editor is the default editor (again). -It requires IntelliJ platform version 2024.1 or newer. +**IntelliJ platform version 2024.2 or newer required.** Previous versions (incl README) can still be accessed and installed manually (see section [Installation](https://github.com/SeeSharpSoft/intellij-csv-validator#installation)). diff --git a/build.gradle.kts b/build.gradle.kts index ace5c9f4..e574e1ee 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,3 @@ -import org.gradle.internal.impldep.org.testng.reporters.XMLUtils import org.jetbrains.changelog.Changelog import org.jetbrains.intellij.platform.gradle.TestFrameworkType import org.jetbrains.intellij.platform.gradle.extensions.intellijPlatform @@ -35,8 +34,7 @@ repositories { } java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 } sourceSets { @@ -74,8 +72,9 @@ dependencies { zipSigner() jetbrainsRuntime() + javaCompiler("21") + testFramework(TestFrameworkType.Platform) - testFramework(TestFrameworkType.JUnit5) } testImplementation("org.mockito:mockito-core:5.14.1") @@ -129,11 +128,11 @@ tasks { } processResources { - duplicatesStrategy = DuplicatesStrategy.WARN + duplicatesStrategy = DuplicatesStrategy.EXCLUDE } processTestResources { - duplicatesStrategy = DuplicatesStrategy.WARN + duplicatesStrategy = DuplicatesStrategy.EXCLUDE } test { diff --git a/gradle.properties b/gradle.properties index 9e830036..1a60b793 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,11 +6,11 @@ pluginName=CSV Editor pluginId=net.seesharpsoft.intellij.plugins.csv pluginVersion=4.0.0 -pluginSinceBuild=241 +pluginSinceBuild=242 platform = IC # LATEST-EAP-SNAPSHOT -platformVersion = 2024.1.1 +platformVersion = 2024.2.1 platformBundledPlugins=Git4Idea,org.jetbrains.plugins.github diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvGithubIssueSubmitter.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvGithubIssueSubmitter.java index dee4ce1b..8e40ec8d 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvGithubIssueSubmitter.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvGithubIssueSubmitter.java @@ -92,7 +92,7 @@ protected boolean submit(IdeaLoggingEvent event, String additionalInfo, Project String token = GHCompatibilityUtil.getOrRequestToken(account, project); if (token == null) return false; - GithubApiRequestExecutor githubExecutor = GithubApiRequestExecutor.Factory.getInstance().create(token); + GithubApiRequestExecutor githubExecutor = GithubApiRequestExecutor.Factory.getInstance().create(account.getServer(), token); Task submitTask = new Task.Backgroundable(project, getReportActionText()) { @Override diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java index a48eae69..61a9f71b 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java @@ -1,6 +1,5 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table; -import com.intellij.codeHighlighting.BackgroundEditorHighlighter; import com.intellij.ide.structureView.StructureViewBuilder; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; @@ -9,7 +8,6 @@ import com.intellij.openapi.fileEditor.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.TraceableDisposable; import com.intellij.openapi.util.UserDataHolder; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.openapi.vfs.VirtualFile; @@ -60,7 +58,7 @@ public CsvTableEditor(@NotNull Project projectArg, @NotNull VirtualFile fileArg) } @NotNull - public abstract CsvTableActions getActions(); + public abstract CsvTableActions getActions(); protected abstract boolean isInCellEditMode(); @@ -109,26 +107,25 @@ public T getTableEditorState() { } @Override + @NotNull public FileEditorState getState(@NotNull FileEditorStateLevel level) { return getTableEditorState(); } @Override public void setState(@NotNull FileEditorState fileEditorState) { - CsvTableEditorState tableEditorState = fileEditorState instanceof CsvTableEditorState ? (CsvTableEditorState) fileEditorState : new CsvTableEditorState(); - this.storedState = tableEditorState; + this.storedState = fileEditorState instanceof CsvTableEditorState ? (CsvTableEditorState) fileEditorState : new CsvTableEditorState(); applyEditorState(getTableEditorState()); } @Override public boolean isModified() { -// return this.dataManagement != null && initialState != null && !this.dataManagement.equalsCurrentState(initialState); return false; } @Override public boolean isValid() { - if (this.isDisposed() || file == null || !file.isValid()) { + if (this.isDisposed() || !file.isValid()) { return false; } CsvFile csvFile = this.getCsvFile(); @@ -161,12 +158,6 @@ public void removePropertyChangeListener(@NotNull PropertyChangeListener propert this.changeSupport.removePropertyChangeListener(propertyChangeListener); } - @Nullable - @Override - public BackgroundEditorHighlighter getBackgroundHighlighter() { - return null; - } - @Override public void dispose() { if (this.isDisposed()) return; @@ -193,7 +184,7 @@ public void putUserData(@NotNull Key key, @Nullable T t) { @Nullable public StructureViewBuilder getStructureViewBuilder() { - return isValid() ? StructureViewBuilder.PROVIDER.getStructureViewBuilder(file.getFileType(), file, this.project) : null; + return isValid() ? StructureViewBuilder.getProvider().getStructureViewBuilder(file.getFileType(), file, this.project) : null; } @Nullable @@ -218,7 +209,7 @@ public PsiFile getPsiFile() { @Nullable public final CsvFile getCsvFile() { - if (project == null || project.isDisposed()) { + if (project.isDisposed()) { return null; } if (this.psiFile == null || !this.psiFile.isValid()) { diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatHelper.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatHelper.java index 2bbbb026..865ff383 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatHelper.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatHelper.java @@ -1,12 +1,8 @@ package net.seesharpsoft.intellij.plugins.csv.formatter; -import com.intellij.formatting.SpacingBuilder; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; -import com.intellij.psi.codeStyle.CodeStyleSettings; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; -import net.seesharpsoft.intellij.plugins.csv.CsvLanguage; -import net.seesharpsoft.intellij.plugins.csv.psi.CsvElementType; import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes; import net.seesharpsoft.intellij.plugins.csv.settings.CsvCodeStyleSettings; import org.jetbrains.annotations.Nullable; @@ -176,29 +172,6 @@ public static int getTextLength(PsiElement psiElement, CsvCodeStyleSettings csvC return CsvFormatHelper.getTextLength(psiElement.getText().strip(), csvCodeStyleSettings); } - public static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) { - CsvCodeStyleSettings csvCodeStyleSettings = settings.getCustomSettings(CsvCodeStyleSettings.class); - SpacingBuilder builder = new SpacingBuilder(settings, CsvLanguage.INSTANCE); - if (csvCodeStyleSettings.TRIM_LEADING_WHITE_SPACES || csvCodeStyleSettings.TABULARIZE) { - builder - .after(CsvTypes.COMMA).spaceIf(csvCodeStyleSettings.SPACE_AFTER_SEPARATOR) - .after(CsvTypes.CRLF).spaces(0) - .after(CsvElementType.DOCUMENT_START).spaces(0); - } else if (csvCodeStyleSettings.SPACE_AFTER_SEPARATOR) { - builder.after(CsvTypes.COMMA).spaces(1); - } - - if (csvCodeStyleSettings.TRIM_TRAILING_WHITE_SPACES || csvCodeStyleSettings.TABULARIZE) { - builder - .before(CsvTypes.COMMA).spaceIf(csvCodeStyleSettings.SPACE_BEFORE_SEPARATOR) - .before(CsvTypes.CRLF).spaces(0); - } else if (csvCodeStyleSettings.SPACE_BEFORE_SEPARATOR) { - builder.before(CsvTypes.COMMA).spaces(1); - } - - return builder; - } - public static boolean isFieldNode(@Nullable ASTNode node) { return node != null && node.getElementType() == CsvTypes.FIELD; } diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingBlock.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingBlock.java index 62c1286e..dcbafec7 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingBlock.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingBlock.java @@ -50,17 +50,14 @@ private boolean requiresTabularization(ASTNode node1, ASTNode node2) { || (CsvFormatHelper.isQuoteNode(node1) && !CsvFormatHelper.isSeparatorNode(node2)) || (CsvFormatHelper.isRecordNode(node2) && (settings.WHITE_SPACES_OUTSIDE_QUOTES || !CsvFormatHelper.isQuotedField(node2.getFirstChildNode()))); } - // case !settings.LEADING_WHITE_SPACES return (!CsvFormatHelper.isQuoteNode(node1) && CsvFormatHelper.isSeparatorNode(node2)) || (!CsvFormatHelper.isSeparatorNode(node1) && CsvFormatHelper.isQuoteNode(node2)); } - private int getDefaultSpacing(@Nullable Block child1, @NotNull Block child2) { - Spacing defaultSpacing = myFormattingInfo.getSpacingBuilder().getSpacing(this, child1, child2); - if (defaultSpacing instanceof SpacingImpl spacing) { - return spacing.getMinSpaces(); - } - return 0; + private int getDefaultSpacing(@Nullable ASTNode node1, @NotNull ASTNode node2) { + CsvCodeStyleSettings settings = myFormattingInfo.getCsvCodeStyleSettings(); + return (CsvFormatHelper.isSeparatorNode(node1) && settings.SPACE_AFTER_SEPARATOR || + CsvFormatHelper.isSeparatorNode(node2) && settings.SPACE_BEFORE_SEPARATOR) ? 1 : 0; } protected int getRequiredTabularizationSpacing(PsiElement psiElement) { @@ -141,7 +138,7 @@ protected List buildChildren() { public Spacing getSpacing(@Nullable Block child1, @NotNull Block child2) { ASTNode childNode1 = child1 == null ? null : ((CsvFormattingBlock)child1).myNode; ASTNode childNode2 = ((CsvFormattingBlock)child2).myNode; - int spacing = this.getDefaultSpacing(child1, child2); + int spacing = this.getDefaultSpacing(childNode1, childNode2); if (this.requiresTabularization(childNode1, childNode2)) { PsiElement targetPsiElement = CsvFormatHelper.isFieldNode(childNode1) ? childNode1.getPsi() : ( CsvFormatHelper.isRecordNode(childNode2) ? childNode2.getFirstChildNode().getPsi() : ( diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingInfo.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingInfo.java index 7a9446e3..e98b8d0f 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingInfo.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingInfo.java @@ -1,6 +1,5 @@ package net.seesharpsoft.intellij.plugins.csv.formatter; -import com.intellij.formatting.SpacingBuilder; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; @@ -11,13 +10,11 @@ public class CsvFormattingInfo { - private final SpacingBuilder mySpacingBuilder; private final CsvCodeStyleSettings csvCodeStyleSettings; private final PsiFile csvFile; private CsvColumnInfoMap csvColumnInfoMap; - public CsvFormattingInfo(CodeStyleSettings codeStyleSettings, SpacingBuilder spacingBuilder, PsiFile csvFile) { - this.mySpacingBuilder = spacingBuilder; + public CsvFormattingInfo(CodeStyleSettings codeStyleSettings, PsiFile csvFile) { this.csvFile = csvFile; this.csvCodeStyleSettings = codeStyleSettings.getCustomSettings(CsvCodeStyleSettings.class); } @@ -26,10 +23,6 @@ private int getTextMaxLength(CsvField field) { return CsvFormatHelper.getTextLength(field.getText().strip(), this.csvCodeStyleSettings); } - public SpacingBuilder getSpacingBuilder() { - return mySpacingBuilder; - } - public CsvCodeStyleSettings getCsvCodeStyleSettings() { return csvCodeStyleSettings; } diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingModelBuilder.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingModelBuilder.java index 2d633166..c4850776 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingModelBuilder.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormattingModelBuilder.java @@ -27,7 +27,6 @@ public FormattingModel createModel(FormattingContext formattingContext) { ASTNode root = element.getNode(); CsvFormattingInfo formattingInfo = new CsvFormattingInfo( settings, - CsvFormatHelper.createSpaceBuilder(settings), element.getContainingFile() );