Skip to content

Commit 24ebb46

Browse files
committed
Chore: Project structure refactoring to avoid circular dependencies
1 parent 30d7fae commit 24ebb46

Some content is hidden

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

43 files changed

+242
-208
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
import com.intellij.psi.tree.IElementType;
1717
import com.intellij.psi.util.PsiTreeUtil;
1818
import net.seesharpsoft.intellij.lang.FileParserDefinition;
19+
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
1920
import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes;
21+
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
2022
import net.seesharpsoft.intellij.plugins.csv.psi.CsvField;
2123
import net.seesharpsoft.intellij.plugins.csv.psi.CsvFile;
2224
import net.seesharpsoft.intellij.plugins.csv.psi.CsvRecord;
@@ -25,10 +27,7 @@
2527
import net.seesharpsoft.intellij.psi.PsiHelper;
2628
import org.jetbrains.annotations.NotNull;
2729

28-
import java.util.ArrayList;
29-
import java.util.HashMap;
30-
import java.util.List;
31-
import java.util.Map;
30+
import java.util.*;
3231
import java.util.function.Function;
3332
import java.util.regex.Matcher;
3433
import java.util.regex.Pattern;

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+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.intellij.psi.tree.IElementType;
55
import net.seesharpsoft.UnhandledSwitchCaseException;
66
import net.seesharpsoft.commons.util.Tokenizer;
7+
import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder;
8+
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
79
import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes;
810
import org.jetbrains.annotations.NotNull;
911
import org.jetbrains.annotations.Nullable;

src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.intellij.openapi.fileEditor.FileEditor;
55
import com.intellij.psi.PsiFile;
66
import com.intellij.util.FileContentUtilCore;
7-
import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter;
7+
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
88
import net.seesharpsoft.intellij.plugins.csv.CsvHelper;
99
import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes;
1010
import org.jetbrains.annotations.NotNull;

src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionGroup.java

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

33
import com.intellij.openapi.actionSystem.*;
44
import com.intellij.psi.PsiFile;
5-
import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter;
5+
import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter;
66
import net.seesharpsoft.intellij.plugins.csv.CsvHelper;
77
import net.seesharpsoft.intellij.plugins.csv.CsvLanguage;
88
import org.jetbrains.annotations.NotNull;

src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import com.intellij.psi.PsiFile;
77
import com.intellij.util.FileContentUtilCore;
88
import net.seesharpsoft.intellij.plugins.csv.CsvHelper;
9-
import net.seesharpsoft.intellij.plugins.csv.CsvSeparatorHolder;
10-
import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator;
9+
import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder;
10+
import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator;
1111
import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes;
1212
import org.jetbrains.annotations.NotNull;
1313

0 commit comments

Comments
 (0)