Skip to content

Commit 3c9751d

Browse files
committed
fix issues & naming
1 parent b76c8bf commit 3c9751d

File tree

9 files changed

+67
-53
lines changed

9 files changed

+67
-53
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Compatible with _IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode
1212
This plugin introduces CSV (_Comma-Separated Values_) as a language to Jetbrains IDE with a syntax definition, structured language elements and associated file types (.csv/.tsv/.psv).
1313
This enables default editor features like syntax validation, highlighting and inspections for CSV-alike files.
1414

15-
![CSV Plugin Example](./docs/example.png)
15+
![CSV Table Editor Example](./docs/example.png)
1616

1717
## Features
1818

@@ -346,7 +346,7 @@ The plugin provides six types of intentions:
346346

347347
Install it from the Jetbrains plugin repository within your IDE (**recommended**):
348348

349-
- _File > Settings > Plugins > Browse repositories... > Search 'CSV Plugin' > Category 'Editor'_
349+
- _File > Settings > Plugins > Browse repositories... > Search 'CSV' > Category 'Editor'_
350350

351351
You can also download the JAR package from the [Jetbrains plugin repository](https://plugins.jetbrains.com/plugin/10037-csv-plugin) or from [GitHub Releases](https://github.com/SeeSharpSoft/intellij-csv-validator/releases) and add it manually to your plugins:
352352

@@ -356,7 +356,7 @@ You can also download the JAR package from the [Jetbrains plugin repository](htt
356356

357357
#### CSV Table Editor doesn't seem to work
358358

359-
Please ensure in the Settings that the corresponding files types (csv, tab/tsv, psv) are properly mapped (_File > Settings > Editor > File Types_).
359+
Please ensure in the settings that the corresponding files types (csv, tab/tsv, psv) are properly mapped (_File > Settings > Editor > File Types_).
360360

361361
#### CSV Table Editor causes the IDE to stop working properly
362362

@@ -368,9 +368,11 @@ In some cases the error log doesn't seem to point this out in a noticeable manne
368368

369369
Please read the [official instructions](https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under) on how to switch to a newer JRE, or [manually install](https://github.com/SeeSharpSoft/intellij-csv-validator#installation) a [prior CSV plugin version](https://github.com/SeeSharpSoft/intellij-csv-validator/releases/tag/2.10.0).
370370

371-
#### Features of the CSV Plugin are not available
371+
#### Features of the CSV Table Editor are not available
372372

373-
If another plugin for CSV files like [Rainbow CSV](https://plugins.jetbrains.com/plugin/12896-rainbow-csv) is enabled, this plugin might not be taken into account for parsing and presenting CSV file content.
373+
If another plugin for CSV files like [Rainbow CSV](https://plugins.jetbrains.com/plugin/12896-rainbow-csv) is enabled, this plugin might not be taken into account for parsing and presenting CSV file content.
374+
375+
Therefore, please ensure in the settings the proper mapping of corresponding files types (_File > Settings > Editor > File Types_).
374376

375377
## Contribution
376378

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# https://www.jetbrains.com/intellij-repository/releases
33
# https://www.jetbrains.com/intellij-repository/snapshots
44

5-
name='CSV Plugin'
5+
name='CSV Table Editor'
66
java.system.class.loader=com.intellij.util.lang.PathClassLoader

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ protected boolean submit(IdeaLoggingEvent event, String additionalInfo, Project
6363
}
6464
GithubAccount githubAccount = githubAuthManager.getSingleOrDefaultAccount(project);
6565
assert githubAccount != null;
66-
GithubApiRequestExecutor.WithTokenAuth githubExecutor = GithubApiRequestExecutorManager.getInstance().getExecutor(githubAccount, project);
66+
// the cast shouldn't be needed due to inheritance, but Java complains for some reason in 2022.1
67+
GithubApiRequestExecutor githubExecutor = GithubApiRequestExecutor.class.cast(GithubApiRequestExecutorManager.getInstance().getExecutor(githubAccount, project));
6768

6869
Task submitTask = new Task.Backgroundable(project, getReportActionText()) {
6970
@Override
@@ -83,7 +84,7 @@ public void run(@NotNull ProgressIndicator indicator) {
8384

8485
private void submitToGithub(IdeaLoggingEvent event,
8586
String additionalInfo,
86-
GithubApiRequestExecutor.WithTokenAuth githubExecutor,
87+
GithubApiRequestExecutor githubExecutor,
8788
Consumer<? super SubmittedReportInfo> consumer,
8889
ProgressIndicator progressIndicator) {
8990
try {
@@ -128,7 +129,7 @@ protected GithubApiRequest createNewIssue(String title, String content) throws I
128129
Collections.emptyList());
129130
}
130131

131-
protected String searchExistingIssues(GithubApiRequestExecutor.WithTokenAuth githubExecutor, String needle, ProgressIndicator progressIndicator) throws IOException {
132+
protected String searchExistingIssues(GithubApiRequestExecutor githubExecutor, String needle, ProgressIndicator progressIndicator) throws IOException {
132133
GithubApiRequest<GithubResponsePage<GithubSearchedIssue>> existingIssueRequest =
133134
GithubApiRequests.Search.Issues.get(
134135
GithubServerPath.DEFAULT_SERVER,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private static void openLink(Project project, String link) {
4242
}
4343

4444
public static void doAsyncProjectMaintenance(@NotNull Project project) {
45-
ProgressManager.getInstance().run(new Task.Backgroundable(project, "CSV plugin validation") {
45+
ProgressManager.getInstance().run(new Task.Backgroundable(project, "CSV Table Editor validation") {
4646
public void run(@NotNull ProgressIndicator progressIndicator) {
4747
// initialize progress indication
4848
progressIndicator.setIndeterminate(false);
@@ -72,11 +72,11 @@ public void runActivity(@NotNull Project project) {
7272

7373
NotificationGroup notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup("net.seesharpsoft.intellij.plugins.csv");
7474
Notification notification = notificationGroup.createNotification(
75-
"CSV Plugin " + getVersion() + " - Change Notes",
75+
"CSV Table Editor " + getVersion() + " - Change Notes",
7676
getChangeNotes() +
7777
"<p>You can always <b>customize plugin settings</b> to your likings (shortcuts below)!</p>" +
7878
"<br>" +
79-
"<p>Visit the <b>CSV Plugin homepage</b> to read more about the available features & settings, " +
79+
"<p>Visit the <b>CSV Table Editor homepage</b> to read more about the available features & settings, " +
8080
"submit issues & feature request, " +
8181
"or show your support by rating this plugin. <b>Thanks!</b></p>"
8282
,
@@ -92,7 +92,7 @@ public void runActivity(@NotNull Project project) {
9292
notification.addAction(NotificationAction.create("Formatting", (anActionEvent, notification1) -> {
9393
openLink(project, "#preferences.sourceCode.CSV/TSV/PSV");
9494
}));
95-
notification.addAction(NotificationAction.create("Open CSV Plugin homepage", (anActionEvent, notification1) -> {
95+
notification.addAction(NotificationAction.create("Open CSV Table Editor homepage", (anActionEvent, notification1) -> {
9696
openLink(project, "https://github.com/SeeSharpSoft/intellij-csv-validator");
9797
}));
9898

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwing.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<properties>
105105
<horizontalTextPosition value="10"/>
106106
<iconTextGap value="2"/>
107-
<text value="CSV plugin"/>
107+
<text value="CSV Table Editor"/>
108108
</properties>
109109
</component>
110110
</children>

src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvPsiTreeUpdater.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,13 @@ private List<Pair<TextRange, String>> collectRangesToDelete(List<Integer> indice
223223
}
224224

225225
public void addRow(@NotNull PsiElement anchor, boolean before) {
226-
while (anchor != null && !(anchor instanceof CsvRecord)) {
227-
anchor = anchor.getParent();
226+
PsiElement record = anchor;
227+
while (record != null && !(record instanceof CsvRecord)) {
228+
record = record.getParent();
228229
}
229-
assert anchor instanceof CsvRecord;
230-
doAction(new AddSiblingPsiAction(anchor, createRecord(), before));
231-
doAddLineBreak(anchor, before);
230+
assert record instanceof CsvRecord;
231+
doAction(new AddSiblingPsiAction(record, createRecord(), before));
232+
doAddLineBreak(record, before);
232233
}
233234

234235
public void deleteRow(@NotNull PsiElement row) {
@@ -277,9 +278,9 @@ public void replaceComment(@NotNull PsiElement toReplace, @Nullable String textA
277278
doAction(new ReplacePsiAction(toReplace, createComment(text)));
278279
}
279280

280-
public void replaceField(@NotNull PsiElement toReplace, @Nullable String text, boolean enquoteCommentIndicator) {
281+
public void replaceField(@NotNull PsiElement toReplace, @Nullable String textArg, boolean enquoteCommentIndicator) {
281282
assert toReplace instanceof CsvField;
282-
if (text == null) text = "";
283+
String text = textArg == null ? "" : textArg;
283284
// do not replace if not necessary
284285
if (toReplace.getText().equals(text)) return;
285286

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package net.seesharpsoft.intellij.plugins.csv.actions;
2+
3+
import com.intellij.openapi.actionSystem.AnAction;
4+
import com.intellij.openapi.actionSystem.Presentation;
5+
import com.intellij.openapi.actionSystem.ex.ActionUtil;
6+
import com.intellij.testFramework.TestActionEvent;
7+
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
8+
import com.intellij.testFramework.fixtures.CodeInsightTestFixture;
9+
import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes;
10+
import org.jetbrains.annotations.NotNull;
11+
12+
public class CsvActionTestBase extends BasePlatformTestCase {
13+
14+
@Override
15+
protected String getTestDataPath() {
16+
return "./src/test/resources/actions";
17+
}
18+
19+
@Override
20+
protected void tearDown() throws Exception {
21+
CsvFileAttributes.getInstance(this.getProject()).reset();
22+
super.tearDown();
23+
}
24+
25+
@NotNull
26+
public Presentation testActionGroup(@NotNull AnAction action, CodeInsightTestFixture myFixture) {
27+
// TODO this function is used instead of myFixture.testAction, due to an error with respect to missing component in datacontext
28+
// return myFixture.testAction(action);
29+
TestActionEvent e = new TestActionEvent(action);
30+
if (ActionUtil.lastUpdateAndCheckDumb(action, e, true)) {
31+
action.update(e);
32+
}
33+
return e.getPresentation();
34+
}
35+
36+
}

src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionTest.java

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

33
import com.intellij.openapi.actionSystem.Presentation;
4-
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
54
import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter;
65
import net.seesharpsoft.intellij.plugins.csv.CsvHelper;
7-
import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes;
86

9-
public class CsvChangeEscapeCharacterActionTest extends BasePlatformTestCase {
10-
11-
@Override
12-
protected String getTestDataPath() {
13-
return "./src/test/resources/actions";
14-
}
15-
16-
@Override
17-
protected void tearDown() throws Exception {
18-
CsvFileAttributes.getInstance(this.getProject()).reset();
19-
super.tearDown();
20-
}
7+
public class CsvChangeEscapeCharacterActionTest extends CsvActionTestBase {
218

229
public void testActionGroupVisibilityForCsv() {
2310
myFixture.configureByFiles("CommaSeparated.csv");
2411

25-
Presentation presentation = myFixture.testAction(new CsvChangeEscapeCharacterActionGroup());
12+
Presentation presentation = testActionGroup(new CsvChangeEscapeCharacterActionGroup(), myFixture);
2613
assertTrue(presentation.isVisible());
2714
assertTrue(presentation.isEnabled());
2815
}
2916

3017
public void testActionGroupVisibilityForTsv() {
3118
myFixture.configureByFiles("TabSeparated.tsv");
3219

33-
Presentation presentation = myFixture.testAction(new CsvChangeEscapeCharacterActionGroup());
20+
Presentation presentation = testActionGroup(new CsvChangeEscapeCharacterActionGroup(), myFixture);
3421
assertTrue(presentation.isVisible());
3522
assertTrue(presentation.isEnabled());
3623
}

src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java

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

33
import com.intellij.openapi.actionSystem.Presentation;
4-
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
54
import net.seesharpsoft.intellij.plugins.csv.CsvHelper;
65
import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator;
7-
import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes;
86

9-
public class CsvChangeSeparatorActionTest extends BasePlatformTestCase {
10-
11-
@Override
12-
protected String getTestDataPath() {
13-
return "./src/test/resources/actions";
14-
}
15-
16-
@Override
17-
protected void tearDown() throws Exception {
18-
CsvFileAttributes.getInstance(this.getProject()).reset();
19-
super.tearDown();
20-
}
7+
public class CsvChangeSeparatorActionTest extends CsvActionTestBase {
218

229
public void testActionGroupVisibilityForCsv() {
2310
myFixture.configureByFiles("CommaSeparated.csv");
2411

25-
Presentation presentation = myFixture.testAction(new CsvChangeSeparatorActionGroup());
12+
Presentation presentation = testActionGroup(new CsvChangeSeparatorActionGroup(), myFixture);
2613
assertTrue(presentation.isVisible());
2714
assertTrue(presentation.isEnabled());
2815
}
2916

3017
public void testActionGroupVisibilityForTsv() {
3118
myFixture.configureByFiles("TabSeparated.tsv");
3219

33-
Presentation presentation = myFixture.testAction(new CsvChangeSeparatorActionGroup());
20+
Presentation presentation = testActionGroup(new CsvChangeSeparatorActionGroup(), myFixture);
3421
assertFalse(presentation.isVisible());
3522
assertFalse(presentation.isEnabled());
3623
}

0 commit comments

Comments
 (0)