Skip to content

Commit ebe10e6

Browse files
authored
Merge pull request #263 from SeeSharpSoft/master
Release 2.15.0
2 parents a413ace + 822befe commit ebe10e6

20 files changed

+86
-107
lines changed

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jdk:
33
- openjdk11
44

55
env:
6-
- IDEA_VERSION=PC-2019.3.3 GRAMMAR_KIT_VERSION=2019.3
6+
- IDEA_VERSION=PC-2020.3.3 GRAMMAR_KIT_VERSION=2019.3
77
- IDEA_VERSION=IU-LATEST-EAP-SNAPSHOT GRAMMAR_KIT_VERSION=2019.3
88

99
script: xvfb-run gradle check

Diff for: CHANGELOG

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2.15.0
2+
Mar 23, 2021
3+
4+
NEW: Default value separator #259
5+
FIX: Removal of deprecated function usage
6+
17
2.14.4
28
Feb 14, 2021
39

Diff for: README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Lightweight CSV Plugin for JetBrains IDE family
99

10-
Compatible with _IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode CLion Gogland DataGrip Rider MPS Android Studio_ - __2017.3.1 and newer__
10+
Compatible with _IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode CLion Gogland DataGrip Rider MPS Android Studio_ - __2019.3.5 and newer__
1111

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.
@@ -37,7 +37,7 @@ This enables default editor features like syntax validation, highlighting and in
3737

3838
**!!Please note!!**
3939

40-
- Starting with **CSV Plugin 2.10.0**, _new features will only be developed for IntelliJ IDE 2019.3 and higher_. I will still release patches for major/critical bugs for previous IDE versions 2017.3.1 - 2019.2.\*, but no additional features or cosmetic fixes.
40+
- Starting with **CSV Plugin 2.10.0**, _new features will only be developed for IntelliJ IDE 2019.3.5 and higher_. ~~I will still release patches for major/critical bugs for previous IDE versions 2017.3.1 - 2019.3.4\*, but no additional features or cosmetic fixes.~~
4141

4242
- 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)).
4343

@@ -132,6 +132,8 @@ The preferred editor usage can be switched between "Text Editor first", "Table E
132132

133133
The following separators are currently supported: **,** (Comma), **;** (Semicolon), **:** (Colon), **|** (Pipe) and **↹** (Tab)
134134

135+
**since 2.15.0:** The default value separator can also be a user defined character sequence.
136+
135137
_Default Value Separator_ defines which separator is used as standard for each newly created or opened CSV file.
136138
The separator character can be changed for each file individually in its editors context menu.
137139

Diff for: build.gradle

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,32 @@ buildscript {
1111

1212
plugins {
1313
// https://github.com/JetBrains/gradle-intellij-plugin
14-
id 'org.jetbrains.intellij' version '0.4.10'
14+
id 'org.jetbrains.intellij' version '0.7.2'
1515
id 'jacoco'
16-
id 'com.github.kt3k.coveralls' version '2.8.2'
16+
id 'com.github.kt3k.coveralls' version '2.8.4'
1717
id "com.github.ManifestClasspath" version "0.1.0-RELEASE"
1818
}
1919

20+
jacoco {
21+
toolVersion = "0.8.6"
22+
}
23+
2024
jacocoTestReport {
2125
reports {
2226
xml.enabled true
2327
}
2428
}
2529

2630
group 'net.seesharpsoft.intellij.plugins'
27-
version '2.14.4'
31+
version '2.15.0'
2832

2933
apply plugin: 'java'
3034
project.sourceCompatibility = JavaVersion.VERSION_11
3135
project.targetCompatibility = JavaVersion.VERSION_11
32-
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
36+
tasks.withType(JavaCompile) {
37+
options.encoding = 'UTF-8'
38+
options.compilerArgs << "-Xlint:deprecation"
39+
}
3340
repositories {
3441
mavenCentral()
3542
}

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvFileTypeFactory.java

-12
This file was deleted.

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvIconProvider.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
public class CsvIconProvider extends IconProvider {
1414

15-
public static final Icon FILE = IconLoader.getIcon("/media/icons/csv-icon.png");
15+
public static final Icon FILE = IconLoader.getIcon("/media/icons/csv-icon.png", CsvIconProvider.class);
1616

17-
public static final Icon HEADER = IconLoader.getIcon("/media/icons/csv-header-icon.png");
17+
public static final Icon HEADER = IconLoader.getIcon("/media/icons/csv-header-icon.png", CsvIconProvider.class);
1818

19-
public static final Icon FIELD = IconLoader.getIcon("/media/icons/csv-field-icon.png");
19+
public static final Icon FIELD = IconLoader.getIcon("/media/icons/csv-field-icon.png", CsvIconProvider.class);
2020

2121
@Nullable
2222
@Override

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvParserDefinition.java

-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ public PsiFile createFile(FileViewProvider viewProvider) {
6262
return new CsvFile(viewProvider, CsvFileType.INSTANCE);
6363
}
6464

65-
@Override
66-
public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
67-
return SpaceRequirements.MAY;
68-
}
69-
7065
@Override
7166
@NotNull
7267
public PsiElement createElement(ASTNode node) {

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPlugin.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.intellij.ide.actions.ShowSettingsUtilImpl;
44
import com.intellij.ide.plugins.IdeaPluginDescriptorImpl;
55
import com.intellij.ide.plugins.PluginManager;
6+
import com.intellij.ide.plugins.PluginManagerCore;
67
import com.intellij.notification.*;
78
import com.intellij.openapi.extensions.PluginId;
89
import com.intellij.openapi.options.ShowSettingsUtil;
@@ -20,7 +21,7 @@
2021
public class CsvPlugin implements StartupActivity {
2122

2223
protected static IdeaPluginDescriptorImpl getPluginDescriptor() {
23-
return (IdeaPluginDescriptorImpl)PluginManager.getPlugin(PluginId.getId("net.seesharpsoft.intellij.plugins.csv"));
24+
return (IdeaPluginDescriptorImpl)PluginManagerCore.getPlugin(PluginId.getId("net.seesharpsoft.intellij.plugins.csv"));
2425
}
2526

2627
protected static String getVersion() {

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
import org.jetbrains.annotations.NotNull;
2121
import org.jetbrains.annotations.Nullable;
2222

23-
import java.util.Arrays;
24-
import java.util.HashMap;
25-
import java.util.Map;
23+
import java.util.*;
2624

2725
@State(
2826
name = "CsvFileAttributes",
@@ -125,10 +123,15 @@ CsvValueSeparator autoDetectOrGetDefaultValueSeparator(Project project, VirtualF
125123

126124
private @NotNull
127125
CsvValueSeparator autoDetectSeparator(Project project, VirtualFile virtualFile) {
128-
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
126+
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
129127
final String text = document == null ? "" : document.getText();
128+
final List<CsvValueSeparator> applicableValueSeparators = new ArrayList(Arrays.asList(CsvValueSeparator.values()));
129+
final CsvValueSeparator defaultValueSeparator = CsvEditorSettings.getInstance().getDefaultValueSeparator();
130+
if (defaultValueSeparator.isCustom()) {
131+
applicableValueSeparators.add(defaultValueSeparator);
132+
}
130133
Pair<CsvValueSeparator, Integer> separatorWithCount =
131-
Arrays.stream(CsvValueSeparator.values())
134+
applicableValueSeparators.parallelStream()
132135
// count
133136
.map(separator -> {
134137
String character = separator.getCharacter();
@@ -143,7 +146,7 @@ CsvValueSeparator autoDetectSeparator(Project project, VirtualFile virtualFile)
143146

144147
CsvValueSeparator valueSeparator = separatorWithCount != null ?
145148
separatorWithCount.getFirst() :
146-
CsvEditorSettings.getInstance().getDefaultValueSeparator();
149+
defaultValueSeparator;
147150

148151
setFileSeparator(project, virtualFile, valueSeparator);
149152
return valueSeparator;

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

+17-6
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ public void annotate(@NotNull final PsiElement element, @NotNull final Annotatio
6565
textRange = TextRange.from(textRange.getStartOffset() - 1, 1);
6666
}
6767

68-
Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, textRange, message, tooltip);
68+
final Annotation annotation =
69+
new Annotation(
70+
textRange.getStartOffset(),
71+
textRange.getEndOffset(),
72+
CSV_COLUMN_INFO_SEVERITY,
73+
message,
74+
tooltip
75+
);
6976
annotation.setEnforcedTextAttributes(
7077
CsvEditorSettings.getInstance().getValueColoring() == CsvEditorSettings.ValueColoring.RAINBOW ?
7178
CsvColorSettings.getTextAttributesOfColumn(columnInfo.getColumnIndex(), holder.getCurrentAnnotationSession()) :
@@ -98,11 +105,15 @@ protected boolean handleSeparatorElement(@NotNull PsiElement element, @NotNull A
98105
}
99106
}
100107
if (textAttributes != null) {
101-
Annotation annotation = holder.createAnnotation(
102-
CSV_COLUMN_INFO_SEVERITY,
103-
element.getTextRange(),
104-
showInfoBalloon(holder.getCurrentAnnotationSession()) ? "↹" : null
105-
);
108+
final TextRange textRange = element.getTextRange();
109+
final Annotation annotation =
110+
new Annotation(
111+
textRange.getStartOffset(),
112+
textRange.getEndOffset(),
113+
CSV_COLUMN_INFO_SEVERITY,
114+
showInfoBalloon(holder.getCurrentAnnotationSession()) ? "↹" : null,
115+
null
116+
);
106117
annotation.setEnforcedTextAttributes(textAttributes);
107118
annotation.setNeedsUpdateOnTyping(false);
108119
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void saveChanges(final String content) {
144144
}
145145
ApplicationManager.getApplication().invokeLater(() -> {
146146
if (project == null || project.isDisposed() ||
147-
(!this.document.isWritable() && ReadonlyStatusHandler.getInstance(this.project).ensureFilesWritable(this.file).hasReadonlyFiles())) {
147+
(!this.document.isWritable() && ReadonlyStatusHandler.getInstance(this.project).ensureFilesWritable(Collections.singleton(this.file)).hasReadonlyFiles())) {
148148
return;
149149
}
150150
ApplicationManager.getApplication().runWriteAction(() ->

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import javax.swing.text.BadLocationException;
2121
import java.awt.*;
2222
import java.awt.event.FocusEvent;
23+
import java.awt.geom.Rectangle2D;
2324
import java.util.EventObject;
2425
import java.util.Iterator;
2526
import java.util.Set;
@@ -96,10 +97,10 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
9697
@Override
9798
public Dimension getPreferredSize() {
9899
try {
99-
final Rectangle rectangle = myTextArea.modelToView(myTextArea.getDocument().getLength());
100+
final Rectangle2D rectangle = myTextArea.modelToView2D(myTextArea.getDocument().getLength());
100101
if (rectangle != null) {
101102
return new Dimension(this.getWidth(),
102-
this.getInsets().top + rectangle.y + rectangle.height + this.getInsets().bottom);
103+
(int)(this.getInsets().top + rectangle.getY() + rectangle.getHeight() + this.getInsets().bottom));
103104
}
104105
} catch (BadLocationException e) {
105106
e.printStackTrace();

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public String getConfigurableDisplayName() {
2525

2626
@NotNull
2727
@Override
28-
public Configurable createSettingsPage(CodeStyleSettings settings, CodeStyleSettings originalSettings) {
28+
public CodeStyleConfigurable createConfigurable(CodeStyleSettings settings, CodeStyleSettings originalSettings) {
2929
return new CodeStyleAbstractConfigurable(settings, originalSettings, CsvLanguage.INSTANCE.getDisplayName()) {
3030
@Override
3131
protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) {

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettingsProvider.form

+3-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,9 @@
370370
<constraints>
371371
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
372372
</constraints>
373-
<properties/>
373+
<properties>
374+
<editable value="true"/>
375+
</properties>
374376
</component>
375377
<component id="aed54" class="javax.swing.JCheckBox" binding="cbAutoDetectSeparator">
376378
<constraints>

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettingsProvider.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ public void apply() throws ConfigurationException {
143143
csvEditorSettings.setTableDefaultColumnWidth((int) tfDefaultColumnWidth.getValue());
144144
csvEditorSettings.setTableAutoColumnWidthOnOpen(cbAdjustColumnWidthOnOpen.isSelected());
145145
csvEditorSettings.setDefaultEscapeCharacter((CsvEscapeCharacter)comboEscapeCharacter.getSelectedItem());
146-
csvEditorSettings.setDefaultValueSeparator((CsvValueSeparator)comboValueSeparator.getSelectedItem());
146+
csvEditorSettings.setDefaultValueSeparator(
147+
comboValueSeparator.getSelectedItem() instanceof CsvValueSeparator ?
148+
(CsvValueSeparator)comboValueSeparator.getSelectedItem() :
149+
CsvValueSeparator.create((String)comboValueSeparator.getSelectedItem())
150+
);
147151
csvEditorSettings.setKeepTrailingSpaces(cbKeepTrailingWhitespaces.isSelected());
148152
csvEditorSettings.setCommentIndicator(tfCommentIndicator.getText());
149153
csvEditorSettings.setValueColoring((CsvEditorSettings.ValueColoring) comboValueColoring.getSelectedItem());

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvLanguageCodeStyleSettingsProvider.java

+7-10
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,15 @@ public String getCodeSample(@NotNull SettingsType settingsType) {
7777
"5 ,Holmes HEPA Air Purifier,Carlos Soltero,汉字宋,30.94,21.78";
7878
}
7979

80-
@Override
81-
public CommonCodeStyleSettings getDefaultCommonSettings() {
82-
CommonCodeStyleSettings commonSettings = new CommonCodeStyleSettings(getLanguage());
83-
commonSettings.initIndentOptions();
84-
commonSettings.getIndentOptions().TAB_SIZE = 1;
85-
commonSettings.getIndentOptions().INDENT_SIZE = 1;
86-
commonSettings.getIndentOptions().USE_TAB_CHARACTER = true;
87-
commonSettings.getIndentOptions().SMART_TABS = false;
88-
commonSettings.getIndentOptions().KEEP_INDENTS_ON_EMPTY_LINES = true;
80+
protected void customizeDefaults(@NotNull CommonCodeStyleSettings commonSettings, @NotNull CommonCodeStyleSettings.IndentOptions indentOptions) {
81+
super.customizeDefaults(commonSettings, indentOptions);
82+
indentOptions.TAB_SIZE = 1;
83+
indentOptions.INDENT_SIZE = 1;
84+
indentOptions.USE_TAB_CHARACTER = true;
85+
indentOptions.SMART_TABS = false;
86+
indentOptions.KEEP_INDENTS_ON_EMPTY_LINES = true;
8987
commonSettings.WRAP_ON_TYPING = CommonCodeStyleSettings.WrapOnTyping.NO_WRAP.intValue;
9088
commonSettings.WRAP_LONG_LINES = false;
9189
commonSettings.RIGHT_MARGIN = Integer.MAX_VALUE;
92-
return commonSettings;
9390
}
9491
}

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileTypeFactory.java

-12
This file was deleted.

Diff for: src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileTypeFactory.java

-12
This file was deleted.

Diff for: src/main/resources/META-INF/plugin.xml

+3-12
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,20 @@
5050

5151
<change-notes><![CDATA[
5252
<pre style="font-family: sans-serif">
53-
NEW: Auto detect value separator (by count)
53+
NEW: Default value separator #259
54+
FIX: Removal of deprecated function usage
5455
</pre>
5556
]]>
5657
</change-notes>
5758

5859
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
59-
<!-- <idea-version since-build="173.2099.1" until-build="192.*" />-->
60-
<idea-version since-build="193" />
60+
<idea-version since-build="193.5233.102" />
6161

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

6666
<extensions defaultExtensionNs="com.intellij">
67-
<!-- version 173.* - 192.* -->
68-
<!-- <fileType name="FileType_CSV" implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvFileType" extensions="csv"/>-->
69-
<!-- <fileType name="FileType_TSV" implementationClass="net.seesharpsoft.intellij.plugins.tsv.TsvFileType" extensions="tsv;tab"/>-->
70-
<!-- <fileType name="FileType_PSV" implementationClass="net.seesharpsoft.intellij.plugins.psv.PsvFileType" extensions="psv"/>-->
71-
<!-- <fileTypeFactory implementation="net.seesharpsoft.intellij.plugins.csv.CsvFileTypeFactory"/>-->
72-
<!-- <fileTypeFactory implementation="net.seesharpsoft.intellij.plugins.tsv.TsvFileTypeFactory"/>-->
73-
<!-- <fileTypeFactory implementation="net.seesharpsoft.intellij.plugins.psv.PsvFileTypeFactory"/>-->
74-
75-
<!-- version 193.* -->
7667
<fileType name="CSV" language="csv" implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvFileType" extensions="csv" fieldName="INSTANCE"/>
7768
<fileType name="TSV" language="tsv" implementationClass="net.seesharpsoft.intellij.plugins.tsv.TsvFileType" extensions="tsv;tab" fieldName="INSTANCE"/>
7869
<fileType name="PSV" language="psv" implementationClass="net.seesharpsoft.intellij.plugins.psv.PsvFileType" extensions="psv" fieldName="INSTANCE"/>

0 commit comments

Comments
 (0)