Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/CIBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/CoverallsReport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/CronEAP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions .github/workflows/PublishStable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/PullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).

Expand Down
11 changes: 5 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -35,8 +34,7 @@ repositories {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
}

sourceSets {
Expand Down Expand Up @@ -74,8 +72,9 @@ dependencies {
zipSigner()

jetbrainsRuntime()
javaCompiler("21")

testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.JUnit5)
}

testImplementation("org.mockito:mockito-core:5.14.1")
Expand Down Expand Up @@ -129,11 +128,11 @@ tasks {
}

processResources {
duplicatesStrategy = DuplicatesStrategy.WARN
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

processTestResources {
duplicatesStrategy = DuplicatesStrategy.WARN
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

test {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -109,26 +107,25 @@ public <T extends CsvTableEditorState> 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();
Expand Down Expand Up @@ -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;
Expand All @@ -193,7 +184,7 @@ public <T> void putUserData(@NotNull Key<T> 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
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -141,7 +138,7 @@ protected List<Block> 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() : (
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,13 +10,11 @@

public class CsvFormattingInfo {

private final SpacingBuilder mySpacingBuilder;
private final CsvCodeStyleSettings csvCodeStyleSettings;
private final PsiFile csvFile;
private CsvColumnInfoMap<PsiElement> 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);
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public FormattingModel createModel(FormattingContext formattingContext) {
ASTNode root = element.getNode();
CsvFormattingInfo formattingInfo = new CsvFormattingInfo(
settings,
CsvFormatHelper.createSpaceBuilder(settings),
element.getContainingFile()
);

Expand Down
Loading