Skip to content

Commit 21e84fc

Browse files
authored
Merge pull request #918 from SeeSharpSoft/main
Release 4.1.0
2 parents 8229eee + 8419201 commit 21e84fc

File tree

62 files changed

+632
-526
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+632
-526
lines changed

.github/workflows/CIBuild.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ on:
1616
branches: [ main ]
1717
schedule:
1818
- cron: '18 7 * * 6'
19+
workflow_dispatch:
20+
inputs:
21+
environment:
22+
description: 'Environment to run tests against'
23+
type: environment
24+
required: true
1925

2026
jobs:
2127
analyze:
@@ -36,7 +42,7 @@ jobs:
3642

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

7177
- name: Perform CodeQL Analysis
72-
uses: github/codeql-action/analyze@v2
78+
uses: github/codeql-action/analyze@v3

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010

1111
### Fixed
1212

13+
## [4.1.0] - Sep 07, 2025
14+
15+
### Fixed
16+
17+
- Access is allowed with explicit read lock #898 #901
18+
- Rework CSV file detection for FileEditorProvider #904
19+
- Legacy configurable id calculation mode from localizable name will be used for configurable class CsvCodeStyleSettingsProvider. Please override getConfigurableId or getLanguage. #909
20+
21+
### Changed
22+
23+
- Project structure refactoring to avoid circular dependencies
24+
1325
## [4.0.2] - Dec 29, 2024
1426

1527
### Added

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
pluginName=CSV Editor
66
pluginId=net.seesharpsoft.intellij.plugins.csv
7-
pluginVersion=4.0.2
7+
pluginVersion=4.1.0
88

99
pluginSinceBuild=242
1010

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvEscapeCharacter.java

Lines changed: 0 additions & 114 deletions
This file was deleted.

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.intellij.lang.*;
44
import com.intellij.lexer.Lexer;
5+
import com.intellij.openapi.fileTypes.FileType;
56
import com.intellij.openapi.fileTypes.FileTypeRegistry;
67
import com.intellij.openapi.project.Project;
78
import com.intellij.openapi.vfs.VirtualFile;
@@ -15,7 +16,9 @@
1516
import com.intellij.psi.tree.IElementType;
1617
import com.intellij.psi.util.PsiTreeUtil;
1718
import net.seesharpsoft.intellij.lang.FileParserDefinition;
19+
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
1820
import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes;
21+
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
1922
import net.seesharpsoft.intellij.plugins.csv.psi.CsvField;
2023
import net.seesharpsoft.intellij.plugins.csv.psi.CsvFile;
2124
import net.seesharpsoft.intellij.plugins.csv.psi.CsvRecord;
@@ -24,10 +27,7 @@
2427
import net.seesharpsoft.intellij.psi.PsiHelper;
2528
import org.jetbrains.annotations.NotNull;
2629

27-
import java.util.ArrayList;
28-
import java.util.HashMap;
29-
import java.util.List;
30-
import java.util.Map;
30+
import java.util.*;
3131
import java.util.function.Function;
3232
import java.util.regex.Matcher;
3333
import java.util.regex.Pattern;
@@ -51,32 +51,21 @@ public static PsiElement createEmptyCsvField(PsiFile psiFile) {
5151
return node.getPsi();
5252
}
5353

54-
public static boolean isCsvFile(String extension) {
55-
if (extension == null) {
56-
return false;
57-
}
58-
Language language = LanguageUtil.getFileTypeLanguage(
59-
FileTypeRegistry.getInstance().getFileTypeByExtension(extension)
60-
);
54+
public static boolean isCsvFile(FileType fileType) {
55+
Language language = LanguageUtil.getFileTypeLanguage(fileType);
6156
return language != null && language.isKindOf(CsvLanguage.INSTANCE);
6257
}
6358

64-
public static boolean isCsvFile(Project project, VirtualFile file) {
65-
if (file == null) {
66-
return false;
67-
}
68-
if (project == null) {
69-
return isCsvFile(file.getExtension());
70-
}
71-
final Language language = LanguageUtil.getLanguageForPsi(project, file);
72-
return language != null && language.isKindOf(CsvLanguage.INSTANCE);
59+
public static boolean isCsvFile(String extension) {
60+
return extension != null && isCsvFile(FileTypeRegistry.getInstance().getFileTypeByExtension(extension));
61+
}
62+
63+
public static boolean isCsvFile(VirtualFile file) {
64+
return file != null && isCsvFile(file.getFileType());
7365
}
7466

7567
public static boolean isCsvFile(PsiFile file) {
76-
if (file == null) {
77-
return false;
78-
}
79-
return isCsvFile(file.getProject(), getVirtualFile(file));
68+
return file != null && isCsvFile(getVirtualFile(file));
8069
}
8170

8271
public static boolean isCommentElement(PsiElement element) {
@@ -290,7 +279,7 @@ public static String unquoteCsvValue(String content, CsvEscapeCharacter escapeCh
290279
if (trimmedContent.length() > 1 && trimmedContent.startsWith("\"") && trimmedContent.endsWith("\"")) {
291280
result = trimmedContent.substring(1, trimmedContent.length() - 1);
292281
if (escapeCharacter != null) {
293-
result = result.replaceAll("(?:" + escapeCharacter.getRegexPattern() + ")\"", "\"");
282+
result = result.replaceAll("(?:" + escapeCharacter.getStringPattern() + ")\"", "\"");
294283
}
295284
}
296285
return result;
@@ -310,7 +299,7 @@ public static String quoteCsvField(String content,
310299
}
311300
if (quotingEnforced || isQuotingRequired(content, valueSeparator)) {
312301
String result = content;
313-
result = result.replaceAll("\"", escapeCharacter.getRegexPattern() + "\"");
302+
result = result.replaceAll("\"", escapeCharacter.getStringPattern() + "\"");
314303
return "\"" + result + "\"";
315304
}
316305
return content;

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexer.flex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package net.seesharpsoft.intellij.plugins.csv;
22

33
import com.intellij.psi.tree.IElementType;
4+
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
5+
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
46
import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes;
5-
import com.intellij.psi.TokenType;
67
import com.intellij.lexer.FlexLexer;
7-
import net.seesharpsoft.intellij.plugins.csv.CsvSeparatorHolder;
8+
import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder;
89

910
%%
1011

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerAdapter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package net.seesharpsoft.intellij.plugins.csv;
22

33
import com.intellij.lexer.FlexAdapter;
4+
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
5+
import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder;
6+
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
47

58
public class CsvLexerAdapter extends FlexAdapter implements CsvSeparatorHolder {
69

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import com.intellij.openapi.project.Project;
55
import com.intellij.openapi.vfs.VirtualFile;
66
import com.intellij.psi.PsiFile;
7+
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
8+
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
79
import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings;
810
import org.jetbrains.annotations.NotNull;
911

10-
import static net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings.COMMENT_INDICATOR_DEFAULT;
11-
1212
public class CsvLexerFactory {
1313
protected static CsvLexerFactory INSTANCE = new CsvLexerFactory();
1414

@@ -20,7 +20,7 @@ protected Lexer createLexer(@NotNull CsvValueSeparator separator, @NotNull CsvEs
2020
final String commentIndicator = CsvEditorSettings.getInstance().getCommentIndicator();
2121
if (separator.requiresCustomLexer() ||
2222
escapeCharacter.isCustom() ||
23-
(!commentIndicator.isEmpty() && !commentIndicator.equals(COMMENT_INDICATOR_DEFAULT))) {
23+
(!commentIndicator.isEmpty() && !commentIndicator.equals(CsvEditorSettings.COMMENT_INDICATOR_DEFAULT))) {
2424
return new CsvSharpLexer(new CsvSharpLexer.Configuration(
2525
separator.getCharacter(),
2626
"\n",

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPlugin.java

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
package net.seesharpsoft.intellij.plugins.csv;
22

3-
import com.intellij.DynamicBundle;
43
import com.intellij.ide.BrowserUtil;
54
import com.intellij.ide.actions.ShowSettingsUtilImpl;
6-
import com.intellij.ide.plugins.IdeaPluginDescriptor;
7-
import com.intellij.ide.plugins.PluginManagerCore;
85
import com.intellij.notification.*;
9-
import com.intellij.openapi.extensions.PluginId;
106
import com.intellij.openapi.progress.ProgressIndicator;
117
import com.intellij.openapi.progress.ProgressManager;
128
import com.intellij.openapi.progress.Task;
@@ -21,24 +17,8 @@
2117
import org.jetbrains.annotations.NotNull;
2218
import org.jetbrains.annotations.Nullable;
2319

24-
import java.util.ResourceBundle;
25-
2620
public class CsvPlugin implements ProjectActivity, DumbAware {
2721

28-
private static ResourceBundle _resourceBundle;
29-
30-
protected static IdeaPluginDescriptor getPluginDescriptor() {
31-
return PluginManagerCore.getPlugin(PluginId.getId("net.seesharpsoft.intellij.plugins.csv"));
32-
}
33-
34-
protected static String getVersion() {
35-
return getPluginDescriptor().getVersion();
36-
}
37-
38-
protected static String getChangeNotes() {
39-
return getPluginDescriptor().getChangeNotes();
40-
}
41-
4222
private static void openLink(Project project, String link) {
4323
if (project.isDisposed()) return;
4424

@@ -79,13 +59,13 @@ public void run(@NotNull ProgressIndicator progressIndicator) {
7959
doAsyncProjectMaintenance(project);
8060

8161
NotificationGroup notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup("net.seesharpsoft.intellij.plugins.csv");
82-
if (notificationGroup == null || CsvEditorSettings.getInstance().checkCurrentPluginVersion(getVersion())) {
62+
if (notificationGroup == null || CsvEditorSettings.getInstance().checkCurrentPluginVersion(CsvPluginManager.getVersion())) {
8363
return continuation;
8464
}
8565

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

11393
return continuation;
11494
}
115-
116-
public static ResourceBundle getResourceBundle() {
117-
if (_resourceBundle == null) {
118-
_resourceBundle = DynamicBundle.getPluginBundle(getPluginDescriptor());
119-
}
120-
return _resourceBundle;
121-
}
122-
123-
public static String getLocalizedText(String token) {
124-
return getResourceBundle().getString(token);
125-
}
126-
127-
12895
}

0 commit comments

Comments
 (0)