Skip to content

Commit 73cf0eb

Browse files
authored
Merge pull request #261 from SeeSharpSoft/fb_deprecated_function_cleanup
[INTERNAL] no usage of deprecated methods from idea/intellij
2 parents 42f6afe + 6ad6039 commit 73cf0eb

File tree

13 files changed

+43
-77
lines changed

13 files changed

+43
-77
lines changed

build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ plugins {
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
@@ -29,7 +33,10 @@ version '2.14.4'
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
}

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

Lines changed: 0 additions & 12 deletions
This file was deleted.

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

Lines changed: 3 additions & 3 deletions
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

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

Lines changed: 0 additions & 5 deletions
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) {

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

Lines changed: 2 additions & 1 deletion
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() {

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

Lines changed: 17 additions & 6 deletions
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
}

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

Lines changed: 1 addition & 1 deletion
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(() ->

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

Lines changed: 3 additions & 2 deletions
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();

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

Lines changed: 1 addition & 1 deletion
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) {

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

Lines changed: 7 additions & 10 deletions
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
}

0 commit comments

Comments
 (0)