Skip to content

Commit 7eadba6

Browse files
authored
Merge pull request #917 from SeeSharpSoft/rel_410
Release 4.1.0
2 parents 91f9049 + f228375 commit 7eadba6

File tree

51 files changed

+499
-511
lines changed

Some content is hidden

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

51 files changed

+499
-511
lines changed

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
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package net.seesharpsoft.intellij.plugins.csv;
2+
3+
import com.intellij.DynamicBundle;
4+
import com.intellij.ide.plugins.IdeaPluginDescriptor;
5+
import com.intellij.ide.plugins.PluginManagerCore;
6+
import com.intellij.openapi.extensions.PluginId;
7+
8+
import java.util.ResourceBundle;
9+
10+
public final class CsvPluginManager {
11+
private static ResourceBundle _resourceBundle;
12+
13+
public static ResourceBundle getResourceBundle() {
14+
if (_resourceBundle == null) {
15+
_resourceBundle = DynamicBundle.getPluginBundle(getPluginDescriptor());
16+
}
17+
return _resourceBundle;
18+
}
19+
20+
public static String getLocalizedText(String token) {
21+
return getResourceBundle().getString(token);
22+
}
23+
24+
public static IdeaPluginDescriptor getPluginDescriptor() {
25+
return PluginManagerCore.getPlugin(PluginId.getId("net.seesharpsoft.intellij.plugins.csv"));
26+
}
27+
28+
public static String getVersion() {
29+
return getPluginDescriptor().getVersion();
30+
}
31+
32+
public static String getChangeNotes() {
33+
return getPluginDescriptor().getChangeNotes();
34+
}
35+
36+
private CsvPluginManager() {
37+
// static
38+
}
39+
}

0 commit comments

Comments
 (0)