Skip to content

Commit 8fc19da

Browse files
authored
Merge pull request #309 from SeeSharpSoft/master
Release 2.18.0
2 parents cec5ca9 + cc70229 commit 8fc19da

File tree

13 files changed

+68
-61
lines changed

13 files changed

+68
-61
lines changed

.github/workflows/CronEAP.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: chmod +x gradlew
2424
- name: Build with Gradle
2525
env:
26-
IDEA_VERSION: PY-LATEST-EAP-SNAPSHOT
26+
IDEA_VERSION: LATEST-EAP-SNAPSHOT
2727
GRAMMAR_KIT_VERSION: 2019.3
2828
IDEA_SOURCES: false
2929
run: xvfb-run ./gradlew build

.github/workflows/PullRequest.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
include:
19-
- ideaVersion: IC-193.5233.102
19+
- ideaVersion: PY-2020.1.1
2020
gkVersion: 2019.3
21-
- ideaVersion: PY-LATEST-EAP-SNAPSHOT
21+
- ideaVersion: LATEST-EAP-SNAPSHOT
2222
gkVersion: 2019.3
2323

2424
steps:

.travis.yml

-22
This file was deleted.

CHANGELOG

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2.18.0
2+
Oct 21, 2021
3+
4+
NOTE: Minimum version requirement changed to v2020.1 and newer
5+
FIX: Show diff opens an empty window #306
6+
17
2.17.1
28
Jun 30, 2021
39

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Lightweight CSV Plugin for JetBrains IDE family
1010

11-
Compatible with _IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode CLion Gogland DataGrip Rider MPS Android Studio_ - __2019.3.2 and newer__
11+
Compatible with _IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode CLion Gogland DataGrip Rider MPS Android Studio_ - __2020.1 and newer__
1212

1313
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).
1414
This enables default editor features like syntax validation, highlighting and inspections for CSV-alike files.
@@ -38,6 +38,8 @@ This enables default editor features like syntax validation, highlighting and in
3838

3939
**!!Please note!!**
4040

41+
- Starting with **CSV Plugin 2.18.0**, _minimum IntelliJ IDE v2020.1 is required_. Previous versions can be downloaded and installed manually from the following locations: [GitHub Releases](https://github.com/SeeSharpSoft/intellij-csv-validator/releases), [Plugin Repository](https://plugins.jetbrains.com/plugin/10037-csv-plugin/versions) (see also section [Installation](https://github.com/SeeSharpSoft/intellij-csv-validator#installation)).
42+
4143
- Starting with **CSV Plugin 2.14.0**, _Java 11 (55) or higher is required_. Previous versions can be downloaded and installed manually from the following locations: [GitHub Releases](https://github.com/SeeSharpSoft/intellij-csv-validator/releases), [Plugin Repository](https://plugins.jetbrains.com/plugin/10037-csv-plugin/versions) (see also section [Installation](https://github.com/SeeSharpSoft/intellij-csv-validator#installation)).
4244

4345
- Starting with **CSV Plugin 2.11.0**, _Java 9 (53) or higher is required_. Previous versions can be downloaded and installed manually from the following locations: [GitHub Releases](https://github.com/SeeSharpSoft/intellij-csv-validator/releases), [Plugin Repository](https://plugins.jetbrains.com/plugin/10037-csv-plugin/versions) (see also section [Installation](https://github.com/SeeSharpSoft/intellij-csv-validator#installation)).

build.gradle

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
buildscript {
22
repositories {
33
mavenCentral()
4-
maven { url 'http://dl.bintray.com/jetbrains/intellij-plugin-service' }
54
maven { url 'https://jitpack.io' }
65
}
76
dependencies {
8-
classpath 'com.github.hurricup:gradle-grammar-kit-plugin:2018.1.1'
7+
classpath 'com.github.hurricup:gradle-grammar-kit-plugin:2021.1.3'
98
}
109
}
1110

1211
plugins {
1312
// https://github.com/JetBrains/gradle-intellij-plugin
14-
id 'org.jetbrains.intellij' version '0.7.2'
13+
id 'org.jetbrains.intellij' version '1.2.0'
1514
id 'jacoco'
1615
id 'com.github.kt3k.coveralls' version '2.8.4'
1716
id "com.github.ManifestClasspath" version "0.1.0-RELEASE"
@@ -28,7 +27,7 @@ jacocoTestReport {
2827
}
2928

3029
group 'net.seesharpsoft.intellij.plugins'
31-
version '2.17.1'
30+
version '2.18.0'
3231

3332
apply plugin: 'java'
3433
project.sourceCompatibility = JavaVersion.VERSION_11
@@ -79,11 +78,10 @@ idea {
7978
apply plugin: 'org.jetbrains.intellij'
8079
intellij {
8180
// IDE version - https://www.jetbrains.com/intellij-repository/releases
82-
version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-193.5233.102')
81+
version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-2020.1.1')
8382
pluginName = 'CSV Plugin'
84-
instrumentCode = true
8583
updateSinceUntilBuild = false
86-
downloadSources = System.getenv().getOrDefault('IDEA_SOURCES', 'true')
84+
downloadSources = Boolean.parseBoolean(System.getenv().getOrDefault('IDEA_SOURCES', "true"))
8785
}
8886
publishPlugin {
8987
token = System.getenv().getOrDefault('JI_TOKEN', '')

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java

+15-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.intellij.lang.annotation.*;
44
import com.intellij.openapi.editor.markup.TextAttributes;
55
import com.intellij.openapi.util.Key;
6-
import com.intellij.openapi.util.TextRange;
76
import com.intellij.openapi.vcs.ui.FontUtil;
87
import com.intellij.psi.PsiElement;
98
import com.intellij.psi.tree.IElementType;
@@ -60,18 +59,17 @@ public void annotate(@NotNull final PsiElement element, @NotNull final Annotatio
6059
)
6160
);
6261
}
63-
TextRange textRange = columnInfo.getRowInfo(element).getTextRange();
64-
if (textRange.getStartOffset() - csvFile.getTextLength() == 0 && textRange.getStartOffset() > 0) {
65-
textRange = TextRange.from(textRange.getStartOffset() - 1, 1);
66-
}
6762

68-
final Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, textRange, message, tooltip);
69-
annotation.setEnforcedTextAttributes(
70-
CsvEditorSettings.getInstance().getValueColoring() == CsvEditorSettings.ValueColoring.RAINBOW ?
71-
CsvColorSettings.getTextAttributesOfColumn(columnInfo.getColumnIndex(), holder.getCurrentAnnotationSession()) :
72-
null
73-
);
74-
annotation.setNeedsUpdateOnTyping(false);
63+
holder.newAnnotation(CSV_COLUMN_INFO_SEVERITY, message)
64+
.range(element)
65+
.tooltip(tooltip)
66+
.enforcedTextAttributes(
67+
CsvEditorSettings.getInstance().getValueColoring() == CsvEditorSettings.ValueColoring.RAINBOW ?
68+
CsvColorSettings.getTextAttributesOfColumn(columnInfo.getColumnIndex(), holder.getCurrentAnnotationSession()) :
69+
null
70+
)
71+
.needsUpdateOnTyping(false)
72+
.create();
7573
}
7674
}
7775

@@ -98,10 +96,11 @@ protected boolean handleSeparatorElement(@NotNull PsiElement element, @NotNull A
9896
}
9997
}
10098
if (textAttributes != null) {
101-
final TextRange textRange = element.getTextRange();
102-
final Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, textRange, showInfoBalloon(holder.getCurrentAnnotationSession()) ? "↹" : null);
103-
annotation.setEnforcedTextAttributes(textAttributes);
104-
annotation.setNeedsUpdateOnTyping(false);
99+
holder.newAnnotation(CSV_COLUMN_INFO_SEVERITY, showInfoBalloon(holder.getCurrentAnnotationSession()) ? "↹" : null)
100+
.range(element)
101+
.enforcedTextAttributes(textAttributes)
102+
.needsUpdateOnTyping(false)
103+
.create();
105104
}
106105
return true;
107106
}

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorProvider.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.seesharpsoft.intellij.plugins.csv.editor;
22

3+
import com.intellij.diff.editor.DiffVirtualFile;
34
import com.intellij.openapi.editor.EditorSettings;
45
import com.intellij.openapi.fileEditor.*;
56
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
@@ -16,6 +17,10 @@ public class CsvFileEditorProvider implements AsyncFileEditorProvider, DumbAware
1617

1718
public static final String EDITOR_TYPE_ID = "csv-text-editor";
1819

20+
public static boolean acceptCsvFile(@NotNull Project project, @NotNull VirtualFile file) {
21+
return CsvHelper.isCsvFile(project, file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file) && !(file instanceof DiffVirtualFile);
22+
}
23+
1924
@Override
2025
public String getEditorTypeId() {
2126
return EDITOR_TYPE_ID;
@@ -36,7 +41,7 @@ public FileEditorPolicy getPolicy() {
3641

3742
@Override
3843
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
39-
return CsvHelper.isCsvFile(project, file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file);
44+
return CsvFileEditorProvider.acceptCsvFile(project, file);
4045
}
4146

4247
protected void applySettings(EditorSettings editorSettings, CsvEditorSettings csvEditorSettings) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void setEditable(boolean editable) {
102102
}
103103

104104
public boolean isEditable() {
105-
return this.tableIsEditable && !this.hasErrors() && !hasComments();
105+
return this.tableIsEditable && !this.hasErrors() && !hasComments() && file.isWritable();
106106
}
107107

108108
public CsvColumnInfoMap<PsiElement> getColumnInfoMap() {

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import com.intellij.openapi.project.DumbAware;
88
import com.intellij.openapi.project.Project;
99
import com.intellij.openapi.vfs.VirtualFile;
10-
import com.intellij.psi.SingleRootFileViewProvider;
11-
import net.seesharpsoft.intellij.plugins.csv.CsvHelper;
10+
import net.seesharpsoft.intellij.plugins.csv.editor.CsvFileEditorProvider;
1211
import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings;
1312
import net.seesharpsoft.intellij.plugins.csv.editor.table.swing.CsvTableEditorSwing;
1413
import org.jdom.Element;
@@ -39,8 +38,7 @@ public FileEditorPolicy getPolicy() {
3938
@Override
4039
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
4140
return CsvEditorSettings.getInstance().getEditorPrio() != CsvEditorSettings.EditorPrio.TEXT_ONLY &&
42-
CsvHelper.isCsvFile(project, file) &&
43-
!SingleRootFileViewProvider.isTooLargeForIntelligence(file);
41+
CsvFileEditorProvider.acceptCsvFile(project, file);
4442
}
4543

4644
@NotNull

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ private void initializedUIComponents() {
145145
tblEditor.setDefaultEditor(String.class, cellEditor);
146146
tblEditor.setDefaultEditor(Object.class, cellEditor);
147147
tblEditor.registerKeyboardAction(this.tableEditorActions.undo,
148-
KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);
148+
KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_FOCUSED);
149149
tblEditor.registerKeyboardAction(this.tableEditorActions.redo,
150-
KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK), JComponent.WHEN_FOCUSED);
150+
KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK), JComponent.WHEN_FOCUSED);
151151
tblEditor.registerKeyboardAction(this.tableEditorActions.redo,
152-
KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);
152+
KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_FOCUSED);
153153

154154
setFontSize(getGlobalFontSize());
155155
baseFontHeight = getFontHeight();

src/main/resources/META-INF/plugin.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@
5050

5151
<change-notes><![CDATA[
5252
<pre style="font-family: sans-serif">
53-
FIX: Plugin not showing column at caret Ctr+F1 #300
54-
FIX: Past few versions of this plugin don't show colors #298
53+
NOTE: Minimum version requirement changed to v2020.1 and newer
54+
FIX: Show diff opens an empty window #306
5555
</pre>
5656
]]>
5757
</change-notes>
5858

5959
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
60-
<idea-version since-build="193.5233.102" />
60+
<idea-version since-build="201" />
6161

6262
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
6363
on how to target different products -->

src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java

+21
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package net.seesharpsoft.intellij.plugins.csv.editor;
22

3+
import com.intellij.diff.editor.DiffVirtualFile;
4+
import com.intellij.diff.impl.DiffRequestProcessor;
35
import com.intellij.openapi.editor.EditorSettings;
46
import com.intellij.openapi.fileEditor.*;
57
import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager;
68
import com.intellij.openapi.fileEditor.impl.text.TextEditorState;
9+
import com.intellij.openapi.project.Project;
10+
import com.intellij.openapi.vcs.changes.PreviewDiffVirtualFile;
11+
import com.intellij.testFramework.LightVirtualFile;
712
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
813
import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings;
914
import org.jdom.Element;
15+
import org.jetbrains.annotations.NotNull;
1016

1117
public class CsvFileEditorTest extends BasePlatformTestCase {
1218

@@ -93,4 +99,19 @@ public void testCsvEditorStateReadsAndWritesStates() {
9399
disposeTextEditor(textEditor);
94100
}
95101

102+
private static class DiffVirtualFileDummy extends DiffVirtualFile {
103+
public DiffVirtualFileDummy(@NotNull String name) {
104+
super(name);
105+
}
106+
107+
@Override
108+
public DiffRequestProcessor createProcessor(@NotNull Project project) {
109+
return null;
110+
}
111+
}
112+
113+
public void testAcceptCsvFile() {
114+
assertTrue(CsvFileEditorProvider.acceptCsvFile(myFixture.getProject(), new LightVirtualFile(myFixture.getFile().getName())));
115+
assertFalse(CsvFileEditorProvider.acceptCsvFile(myFixture.getProject(), new DiffVirtualFileDummy(myFixture.getFile().getName())));
116+
}
96117
}

0 commit comments

Comments
 (0)