Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
10 changes: 8 additions & 2 deletions .github/workflows/CIBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ on:
branches: [ main ]
schedule:
- cron: '18 7 * * 6'
workflow_dispatch:
inputs:
environment:
description: 'Environment to run tests against'
type: environment
required: true

jobs:
analyze:
Expand All @@ -36,7 +42,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand Down Expand Up @@ -69,4 +75,4 @@ jobs:
run: xvfb-run ./gradlew build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@

### Fixed

## [4.1.0] - Sep 07, 2025

### Fixed

- Access is allowed with explicit read lock #898 #901
- Rework CSV file detection for FileEditorProvider #904
- Legacy configurable id calculation mode from localizable name will be used for configurable class CsvCodeStyleSettingsProvider. Please override getConfigurableId or getLanguage. #909

### Changed

- Project structure refactoring to avoid circular dependencies

## [4.0.2] - Dec 29, 2024

### Added
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

pluginName=CSV Editor
pluginId=net.seesharpsoft.intellij.plugins.csv
pluginVersion=4.0.2
pluginVersion=4.1.0

pluginSinceBuild=242

Expand Down

This file was deleted.

41 changes: 15 additions & 26 deletions src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.intellij.lang.*;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
Expand All @@ -15,7 +16,9 @@
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
import net.seesharpsoft.intellij.lang.FileParserDefinition;
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes;
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
import net.seesharpsoft.intellij.plugins.csv.psi.CsvField;
import net.seesharpsoft.intellij.plugins.csv.psi.CsvFile;
import net.seesharpsoft.intellij.plugins.csv.psi.CsvRecord;
Expand All @@ -24,10 +27,7 @@
import net.seesharpsoft.intellij.psi.PsiHelper;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -51,32 +51,21 @@ public static PsiElement createEmptyCsvField(PsiFile psiFile) {
return node.getPsi();
}

public static boolean isCsvFile(String extension) {
if (extension == null) {
return false;
}
Language language = LanguageUtil.getFileTypeLanguage(
FileTypeRegistry.getInstance().getFileTypeByExtension(extension)
);
public static boolean isCsvFile(FileType fileType) {
Language language = LanguageUtil.getFileTypeLanguage(fileType);
return language != null && language.isKindOf(CsvLanguage.INSTANCE);
}

public static boolean isCsvFile(Project project, VirtualFile file) {
if (file == null) {
return false;
}
if (project == null) {
return isCsvFile(file.getExtension());
}
final Language language = LanguageUtil.getLanguageForPsi(project, file);
return language != null && language.isKindOf(CsvLanguage.INSTANCE);
public static boolean isCsvFile(String extension) {
return extension != null && isCsvFile(FileTypeRegistry.getInstance().getFileTypeByExtension(extension));
}

public static boolean isCsvFile(VirtualFile file) {
return file != null && isCsvFile(file.getFileType());
}

public static boolean isCsvFile(PsiFile file) {
if (file == null) {
return false;
}
return isCsvFile(file.getProject(), getVirtualFile(file));
return file != null && isCsvFile(getVirtualFile(file));
}

public static boolean isCommentElement(PsiElement element) {
Expand Down Expand Up @@ -290,7 +279,7 @@ public static String unquoteCsvValue(String content, CsvEscapeCharacter escapeCh
if (trimmedContent.length() > 1 && trimmedContent.startsWith("\"") && trimmedContent.endsWith("\"")) {
result = trimmedContent.substring(1, trimmedContent.length() - 1);
if (escapeCharacter != null) {
result = result.replaceAll("(?:" + escapeCharacter.getRegexPattern() + ")\"", "\"");
result = result.replaceAll("(?:" + escapeCharacter.getStringPattern() + ")\"", "\"");
}
}
return result;
Expand All @@ -310,7 +299,7 @@ public static String quoteCsvField(String content,
}
if (quotingEnforced || isQuotingRequired(content, valueSeparator)) {
String result = content;
result = result.replaceAll("\"", escapeCharacter.getRegexPattern() + "\"");
result = result.replaceAll("\"", escapeCharacter.getStringPattern() + "\"");
return "\"" + result + "\"";
}
return content;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package net.seesharpsoft.intellij.plugins.csv;

import com.intellij.psi.tree.IElementType;
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes;
import com.intellij.psi.TokenType;
import com.intellij.lexer.FlexLexer;
import net.seesharpsoft.intellij.plugins.csv.CsvSeparatorHolder;
import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder;

%%

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package net.seesharpsoft.intellij.plugins.csv;

import com.intellij.lexer.FlexAdapter;
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder;
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;

public class CsvLexerAdapter extends FlexAdapter implements CsvSeparatorHolder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings;
import org.jetbrains.annotations.NotNull;

import static net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings.COMMENT_INDICATOR_DEFAULT;

public class CsvLexerFactory {
protected static CsvLexerFactory INSTANCE = new CsvLexerFactory();

Expand All @@ -20,7 +20,7 @@ protected Lexer createLexer(@NotNull CsvValueSeparator separator, @NotNull CsvEs
final String commentIndicator = CsvEditorSettings.getInstance().getCommentIndicator();
if (separator.requiresCustomLexer() ||
escapeCharacter.isCustom() ||
(!commentIndicator.isEmpty() && !commentIndicator.equals(COMMENT_INDICATOR_DEFAULT))) {
(!commentIndicator.isEmpty() && !commentIndicator.equals(CsvEditorSettings.COMMENT_INDICATOR_DEFAULT))) {
return new CsvSharpLexer(new CsvSharpLexer.Configuration(
separator.getCharacter(),
"\n",
Expand Down
39 changes: 3 additions & 36 deletions src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPlugin.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package net.seesharpsoft.intellij.plugins.csv;

import com.intellij.DynamicBundle;
import com.intellij.ide.BrowserUtil;
import com.intellij.ide.actions.ShowSettingsUtilImpl;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.notification.*;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
Expand All @@ -21,24 +17,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ResourceBundle;

public class CsvPlugin implements ProjectActivity, DumbAware {

private static ResourceBundle _resourceBundle;

protected static IdeaPluginDescriptor getPluginDescriptor() {
return PluginManagerCore.getPlugin(PluginId.getId("net.seesharpsoft.intellij.plugins.csv"));
}

protected static String getVersion() {
return getPluginDescriptor().getVersion();
}

protected static String getChangeNotes() {
return getPluginDescriptor().getChangeNotes();
}

private static void openLink(Project project, String link) {
if (project.isDisposed()) return;

Expand Down Expand Up @@ -79,13 +59,13 @@ public void run(@NotNull ProgressIndicator progressIndicator) {
doAsyncProjectMaintenance(project);

NotificationGroup notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup("net.seesharpsoft.intellij.plugins.csv");
if (notificationGroup == null || CsvEditorSettings.getInstance().checkCurrentPluginVersion(getVersion())) {
if (notificationGroup == null || CsvEditorSettings.getInstance().checkCurrentPluginVersion(CsvPluginManager.getVersion())) {
return continuation;
}

Notification notification = notificationGroup.createNotification(
"CSV Editor " + getVersion() + " - Change Notes",
getChangeNotes() +
"CSV Editor " + CsvPluginManager.getVersion() + " - Change Notes",
CsvPluginManager.getChangeNotes() +
"<p>You can always <b>customize plugin settings</b> to your likings (shortcuts below)!</p>" +
"<br>" +
"<p>Visit the <b>CSV Editor homepage</b> to read more about the available features & settings, " +
Expand All @@ -112,17 +92,4 @@ public void run(@NotNull ProgressIndicator progressIndicator) {

return continuation;
}

public static ResourceBundle getResourceBundle() {
if (_resourceBundle == null) {
_resourceBundle = DynamicBundle.getPluginBundle(getPluginDescriptor());
}
return _resourceBundle;
}

public static String getLocalizedText(String token) {
return getResourceBundle().getString(token);
}


}
Loading