Skip to content

Commit 10d561b

Browse files
committed
refactor: clean up code
1 parent 680a9f2 commit 10d561b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

.idea/inspectionProfiles/Project.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/github/lppedd/cc/configuration/CCMainConfigurableGui.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void revalidate() {
158158
defaultTokensFilePickerPanel.revalidateComponent();
159159
}
160160

161-
@SuppressWarnings("ConstantExpression")
161+
@SuppressWarnings({"ConstantExpression", "InstanceVariableUsedBeforeInitialized"})
162162
private void finishUpComponents(
163163
@NotNull final Project project,
164164
@NotNull final Disposable disposable) {
@@ -230,6 +230,7 @@ private void finishUpComponents(
230230
defaultsPanel.add(JBUI.Borders.emptyTop(7).wrap(defaultTokensPanel), gc);
231231
}
232232

233+
@SuppressWarnings("ConstantExpression")
233234
@Nullable
234235
private HyperlinkLabel buildTranslatorLabel() {
235236
final var name = CCBundle.getWithDefault("cc.translation.translator.name", "");
@@ -249,8 +250,6 @@ private HyperlinkLabel buildTranslatorLabel() {
249250
} else {
250251
if (new UrlValidator(new String[] {"http", "https"}, NO_FRAGMENTS).isValid(url)) {
251252
final var hyperlink = "<hyperlink>" + name + "</hyperlink>";
252-
253-
// noinspection UnstableApiUsage
254253
label.setTextWithHyperlink(CCBundle.get("cc.translation.text") + " " + hyperlink);
255254
label.setHyperlinkTarget(url);
256255
} else {

src/main/kotlin/com/github/lppedd/cc/whatsnew/InternalWhatsNewProvider.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.github.lppedd.cc.whatsnew
33
import com.github.lppedd.cc.CC
44
import com.github.lppedd.cc.api.WhatsNewPage
55
import com.github.lppedd.cc.api.WhatsNewProvider
6-
import com.intellij.ide.plugins.IdeaPluginDescriptor
76
import com.intellij.ide.plugins.PluginManagerCore
87
import com.intellij.ide.util.PropertiesComponent
98
import com.intellij.openapi.extensions.PluginDescriptor
@@ -45,7 +44,7 @@ internal class InternalWhatsNewProvider : WhatsNewProvider {
4544

4645
override fun shouldDisplayAtStartup(): Boolean {
4746
val properties = PropertiesComponent.getInstance()
48-
val installedVersion = getPlugin()?.version ?: return false
47+
val installedVersion = getPluginVersion() ?: return false
4948
val registeredVersion = properties.getValue(PROPERTY_VERSION, "0.0.0")
5049

5150
if (PluginVersion(installedVersion) > PluginVersion(registeredVersion)) {
@@ -63,8 +62,10 @@ internal class InternalWhatsNewProvider : WhatsNewProvider {
6362
override fun getPages(): List<WhatsNewPage> =
6463
whatsNewPages
6564

66-
private fun getPlugin(): IdeaPluginDescriptor? =
67-
PluginManagerCore.getPlugin(PluginId.getId(CC.PluginId))
65+
private fun getPluginVersion(): String? {
66+
val plugin = PluginManagerCore.getPlugin(PluginId.getId(CC.PluginId))
67+
return plugin?.version
68+
}
6869

6970
private class PluginVersion(version: String) : Comparable<PluginVersion> {
7071
private val parts = version.split(".").map(String::toInt)

0 commit comments

Comments
 (0)