Skip to content

Commit 8bede06

Browse files
authoredDec 15, 2022
Merge pull request #390 from SeeSharpSoft/main
Release 3.0.2
2 parents 8b92f7c + b87158e commit 8bede06

15 files changed

+125
-78
lines changed
 

‎.github/workflows/PublishStable.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ jobs:
1818
include:
1919
- ideaVersion: 2022.2.1
2020
gkVersion: 2021.1.2
21-
- ideaVersion: LATEST-EAP-SNAPSHOT
21+
- ideaVersion: 2022.3.1
2222
gkVersion: 2021.1.2
23+
# - ideaVersion: LATEST-EAP-SNAPSHOT
24+
# gkVersion: 2021.1.2
2325

2426
steps:
2527
- uses: actions/checkout@v2

‎CHANGELOG

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
3.0.2
2+
Dec 15, 2022
3+
4+
FIX: Detected bulk mode status update from DocumentBulkUpdateListener #384
5+
FIX: Argument for @NotNull parameter 'parent' of PsiHelper.getNthChildOfType must not be null #372
6+
FIX: Argument for @NotNull parameter 'element' of PsiHelper.getSiblingOfType must not be null #375
7+
FIX: Cannot invoke "Document.getText()" because "document" is null #388
8+
FIX: Cannot invoke "PsiFile.getProject()" because the return value of "CsvPsiTreeUpdater.getPsiFile()" is null #378
9+
FIX: Argument for @NotNull parameter 'replacement' of CsvPsiTreeUpdater$ReplacePsiAction.<init> must not be null #380
10+
FIX: provide project parameter for opening link
11+
FIX: Cannot invoke "Document.insertString(int, java.lang.CharSequence)" because "document" is null #386
12+
FIX: first extension sanity check
13+
114
3.0.1
215
Nov 12, 2022
316

‎build.gradle

+14-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
// https://github.com/JetBrains/gradle-intellij-plugin
3-
id 'org.jetbrains.intellij' version '1.9.0'
3+
id 'org.jetbrains.intellij' version '1.10.1'
44
id 'jacoco'
55
id 'com.github.kt3k.coveralls' version '2.8.4'
66
id 'com.github.ManifestClasspath' version '0.1.0-RELEASE'
@@ -57,8 +57,8 @@ sourceSets {
5757
apply plugin: 'idea'
5858
idea {
5959
project {
60-
jdkName = JavaVersion.VERSION_11
61-
languageLevel = JavaVersion.VERSION_11
60+
jdkName = JavaVersion.VERSION_17
61+
languageLevel = JavaVersion.VERSION_17
6262
vcs = 'Git'
6363
}
6464
module {
@@ -73,7 +73,7 @@ var final EAP_BUILD = '223'
7373
var idea_version = System.getenv().getOrDefault('IDEA_VERSION', '2022.2.1')
7474
var build_version = idea_version == EAP_VERSION ? EAP_BUILD : idea_version.substring(2, 4) + idea_version.charAt(5) // extract e.g. '221' from '2022.1.1'
7575

76-
version '3.0.1-' + build_version
76+
version '3.0.2-' + build_version
7777

7878
apply plugin: 'org.jetbrains.intellij'
7979
intellij {
@@ -107,15 +107,17 @@ Feedback is welcome!
107107
PS: The previous versions are still available on the project page.
108108
109109
110-
Update 3.0.1
111-
112-
FIX: cannot init component state (componentName=CsvFileAttributes) #359
113-
FIX: cannot invoke "add(Object)" because "this.myUncommittedActions" is null #361
114-
FIX: cannot invoke "createNotification(...)" because "notificationGroup" is null #362
115-
FIX: cannot invoke "getManager()" because the return value of "getPsiFile()" is null #363
116-
FIX: image in plugin description
117-
FIX: plugin update restart
110+
Update 3.0.2
118111
112+
FIX: Detected bulk mode status update from DocumentBulkUpdateListener #384
113+
FIX: Argument for @NotNull parameter 'parent' of PsiHelper.getNthChildOfType must not be null #372
114+
FIX: Argument for @NotNull parameter 'element' of PsiHelper.getSiblingOfType must not be null #375
115+
FIX: Cannot invoke "Document.getText()" because "document" is null #388
116+
FIX: Cannot invoke "PsiFile.getProject()" because the return value of "CsvPsiTreeUpdater.getPsiFile()" is null #378
117+
FIX: Argument for @NotNull parameter 'replacement' of CsvPsiTreeUpdater\$ReplacePsiAction.<init> must not be null #380
118+
FIX: provide project parameter for opening link
119+
FIX: Cannot invoke "Document.insertString(int, java.lang.CharSequence)" because "document" is null #386
120+
FIX: first extension sanity check
119121
120122
</pre>"""
121123
}
@@ -164,10 +166,3 @@ tasks.named("generateLexer").configure {
164166
compileJava {
165167
dependsOn generateLexer
166168
}
167-
168-
// TODO https://youtrack.jetbrains.com/issue/IDEA-298989 - remove after gradle plugin v1.9.1 or v1.10.0 released
169-
setupDependencies {
170-
doLast {
171-
fileTree("$buildDir/instrumented/instrumentCode") { include("**/*TableEditorSwing.class") }.files.forEach { delete(it) }
172-
}
173-
}

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static boolean isCsvFile(String extension) {
7575
}
7676

7777
public static boolean isCsvFile(Project project, VirtualFile file) {
78-
if (project == null || file == null) {
78+
if (project == null || file == null || !isCsvFile(file.getExtension())) {
7979
return false;
8080
}
8181
final Language language = LanguageUtil.getLanguageForPsi(project, file);
@@ -312,10 +312,6 @@ public static String quoteCsvField(String content,
312312
}
313313
if (quotingEnforced || isQuotingRequired(content, valueSeparator)) {
314314
String result = content;
315-
// if (escapeCharacter != CsvEscapeCharacter.QUOTE) {
316-
// result = result.replaceAll(escapeCharacter.getRegexPattern(),
317-
// escapeCharacter.getRegexPattern() + escapeCharacter.getRegexPattern());
318-
// }
319315
result = result.replaceAll("\"", escapeCharacter.getRegexPattern() + "\"");
320316
return "\"" + result + "\"";
321317
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private static void openLink(Project project, String link) {
3737
if (link.startsWith("#")) {
3838
((ShowSettingsUtilImpl) ShowSettingsUtil.getInstance()).showSettingsDialog(project, link.substring(1), null);
3939
} else {
40-
BrowserUtil.browse(link);
40+
BrowserUtil.browse(link, project);
4141
}
4242
}
4343

‎src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelBase.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ public void setValue(String value, int rowIndex, int columnIndex) {
157157
}
158158

159159
private int getColumnCount(int rowIndex) {
160-
return getColumnCount(PsiHelper.getNthChildOfType(getPsiTreeUpdater().getPsiFile(), rowIndex, CsvRecord.class));
160+
PsiFile psiFile = getPsiFile();
161+
if (psiFile == null) return 0;
162+
return getColumnCount(PsiHelper.getNthChildOfType(psiFile, rowIndex, CsvRecord.class));
161163
}
162164

163165
private int getColumnCount(PsiElement record) {

‎src/main/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvValidationInspection.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ public String getFamilyName() {
121121
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
122122
PsiElement element = descriptor.getPsiElement();
123123
Document document = PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile());
124-
List<Integer> quotePositions = new ArrayList<>();
124+
if (document == null) return;
125125

126+
List<Integer> quotePositions = new ArrayList<>();
126127
int quotePosition = CsvIntentionHelper.getOpeningQuotePosition(element);
127128
if (quotePosition != -1) {
128129
quotePositions.add(quotePosition);
@@ -147,6 +148,8 @@ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descri
147148
try {
148149
PsiElement element = descriptor.getPsiElement();
149150
Document document = PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile());
151+
if (document == null) return;
152+
150153
CsvValueSeparator separator = CsvHelper.getValueSeparator(element.getContainingFile());
151154
String text = document.getText();
152155
document.setText(text.substring(0, element.getTextOffset()) + separator.getCharacter() + text.substring(element.getTextOffset()));
@@ -166,6 +169,8 @@ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descri
166169
try {
167170
PsiElement element = descriptor.getPsiElement();
168171
Document document = PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile());
172+
if (document == null) return;
173+
169174
document.setText(document.getText() + "\"");
170175
} catch (IncorrectOperationException e) {
171176
LOG.error(e);

‎src/main/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionHelper.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public static Collection<PsiElement> getAllElements(PsiFile file) {
4747

4848
public static void quoteAll(@NotNull Project project, @NotNull PsiFile psiFile) {
4949
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
50-
List<Integer> quotePositions = new ArrayList<>();
50+
if (document == null) return;
5151

52+
List<Integer> quotePositions = new ArrayList<>();
5253
PsiTreeUtil.processElements(psiFile, CsvField.class, field -> {
5354
if (PsiHelper.getElementType(field.getFirstChild()) != CsvTypes.QUOTE) {
5455
quotePositions.add(field.getTextRange().getStartOffset());
@@ -63,6 +64,8 @@ public static void quoteAll(@NotNull Project project, @NotNull PsiFile psiFile)
6364

6465
public static void quoteValue(@NotNull Project project, @NotNull final PsiElement field) {
6566
Document document = PsiDocumentManager.getInstance(project).getDocument(field.getContainingFile());
67+
if (document == null) return;
68+
6669
List<Integer> quotePositions = new ArrayList<>();
6770
if (PsiHelper.getElementType(field.getFirstChild()) != CsvTypes.QUOTE) {
6871
quotePositions.add(field.getTextRange().getStartOffset());
@@ -75,9 +78,9 @@ public static void quoteValue(@NotNull Project project, @NotNull final PsiElemen
7578

7679
public static void unquoteAll(@NotNull Project project, @NotNull PsiFile psiFile) {
7780
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
81+
if (document == null) return;
7882

7983
final List<PsiElement> quotePositions = new ArrayList<>();
80-
8184
PsiTreeUtil.processElements(psiFile, CsvField.class, field -> {
8285
if (getChildren(field).stream().noneMatch(element -> PsiHelper.getElementType(element) == CsvTypes.ESCAPED_TEXT)) {
8386
Pair<PsiElement, PsiElement> positions = getQuotePositions(field);
@@ -115,7 +118,7 @@ private static Pair<PsiElement, PsiElement> getQuotePositions(PsiElement element
115118
return null;
116119
}
117120

118-
public static void addQuotes(final Document document, List<Integer> quotePositions) {
121+
public static void addQuotes(@NotNull final Document document, List<Integer> quotePositions) {
119122
int offset = 0;
120123
String quote = "\"";
121124
quotePositions.sort(Integer::compareTo);

‎src/main/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvShiftColumnIntentionAction.java

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ protected static void changeLeftAndRightColumnOrder(@NotNull Project project,
2424
CsvColumnInfo<PsiElement> leftColumnInfo,
2525
CsvColumnInfo<PsiElement> rightColumnInfo) {
2626
Document document = PsiDocumentManager.getInstance(project).getDocument(csvFile);
27+
if (document == null) return;
28+
2729
document.setText(
2830
changeLeftAndRightColumnOrder(document.getText(), CsvHelper.getValueSeparator(csvFile), leftColumnInfo, rightColumnInfo)
2931
);

0 commit comments

Comments
 (0)