Skip to content

Commit 3cd9a80

Browse files
Upgrade idea 233.x (#63)
1 parent 5619623 commit 3cd9a80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+326
-329
lines changed

.github/workflows/ScalaCI.yml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,29 @@ on:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
16-
1715
steps:
1816
- uses: actions/checkout@v3
1917
- name: Set up JDK 17
2018
uses: actions/setup-java@v1
2119
with:
2220
java-version: 17
23-
21+
cache: 'sbt'
2422
- name: Build
2523
run: sbt compile
2624

25+
lint:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v1
31+
with:
32+
java-version: 17
33+
cache: 'sbt'
2734
- name: Check Style
2835
run: sbt check
29-
36+
3037
test:
3138
runs-on: ubuntu-latest
3239
steps:
@@ -35,38 +42,26 @@ jobs:
3542
uses: actions/setup-java@v1
3643
with:
3744
java-version: 17
38-
45+
cache: 'sbt'
3946
- name: Test
4047
run: sbt test
4148

42-
# - name: Run Test
43-
# if: success() || failure()
44-
# run: sbt coverage test
45-
#
46-
# - name: Aggregate coverage report
47-
# run: sbt coverageAggregate
48-
#
49-
# - name: Upload test coverage report
50-
# run: bash <(curl -s https://codecov.io/bash)
51-
5249
verification:
53-
5450
runs-on: ubuntu-latest
55-
5651
steps:
5752
- uses: actions/checkout@v3
5853
- name: Set up JDK 17
5954
uses: actions/setup-java@v1
6055
with:
6156
java-version: 17
62-
57+
cache: 'sbt'
6358
- name: Check Binary Compatibility
6459
run: sbt runPluginVerifier
6560

6661

6762
ci:
6863
runs-on: ubuntu-20.04
69-
needs: [ build, test, verification]
64+
needs: [ build, lint, test, verification]
7065
steps:
7166
- name: Aggregate outcomes
7267
run: echo "build succeeded"

.scala-steward.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
updates.ignore = [ { groupId = "org.scalameta", artifactId = "scalafmt-core" } ]

build.sbt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ lazy val logbackVersion = "1.4.14"
66
lazy val graphvizVersion = "0.18.1"
77
lazy val joorVersion = "0.9.15"
88
lazy val scalatestVersion = "3.2.16"
9-
lazy val pluginVerifierVersion = "1.301"
9+
lazy val pluginVerifierVersion = "1.305"
10+
lazy val ktVersion = "1.9.10"
1011

11-
// https://youtrack.jetbrains.com/articles/IDEA-A-2100661425/IntelliJ-IDEA-2023.1-Latest-Builds
12-
lazy val intellijVersion = "231.9392.1"
13-
lazy val pluginVersion = s"0.3.0-RC1-$intellijVersion"
12+
// https://youtrack.jetbrains.com/articles/IDEA-A-2100661679/IntelliJ-IDEA-2023.3-Latest-Builds
13+
// NOTE: Latest-Builds 233
14+
lazy val intellijVersion = "233.11799.241"
15+
lazy val pluginVersion = s"0.3.0-$intellijVersion"
1416

1517
ThisBuild / version := pluginVersion
1618

@@ -54,8 +56,7 @@ lazy val `sbt-dependency-analyzer` = (project in file("."))
5456
pluginVerifierOptions := pluginVerifierOptions.value.copy(
5557
version = pluginVerifierVersion, // use a specific verifier version
5658
offline = true, // forbid the verifier from reaching the internet
57-
failureLevels =
58-
Set(FailureLevel.INTERNAL_API_USAGES, FailureLevel.COMPATIBILITY_PROBLEMS, FailureLevel.COMPATIBILITY_WARNINGS)
59+
failureLevels = Set(FailureLevel.COMPATIBILITY_PROBLEMS, FailureLevel.COMPATIBILITY_WARNINGS)
5960
),
6061
Global / intellijAttachSources := true,
6162
intellijPlugins ++= Seq("com.intellij.java", "com.intellij.java-i18n", "org.intellij.scala").map(_.toPlugin),
@@ -74,7 +75,7 @@ lazy val `sbt-dependency-analyzer` = (project in file("."))
7475
"org.jooq" % "joor" % joorVersion,
7576
"org.scalatest" %% "scalatest" % scalatestVersion % Test
7677
),
77-
kotlinVersion := "1.9.21",
78+
kotlinVersion := ktVersion,
7879
Compile / unmanagedSourceDirectories += baseDirectory.value / "src" / "main" / "kotlin",
7980
packageLibraryMappings ++= Seq(
8081
"org.jetbrains.kotlin" % ".*" % ".*" -> None,

project/Commands.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import sbt.Command
22

3-
/** @author
4-
* 梦境迷离
5-
* @since 2023/4/25
6-
* @version 1.0
7-
*/
83
object Commands {
94

105
val FmtSbtCommand = Command.command("fmt")(state => "scalafmtSbt" :: "scalafmtAll" :: state)

src/main/kotlin/bitlap/sbt/analyzer/jbexternal/DependencyAnalyzerViewImpl.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class DependencyAnalyzerViewImpl(
7979
private var dependencyScopeFilter by dependencyScopeFilterProperty
8080
private var showDependencyWarnings by showDependencyWarningsProperty
8181
private var showDependencyGroupId by showDependencyGroupIdProperty
82-
private var showDependencySize by showDependencySizeProperty
8382

8483
private var dependencyModel by dependencyModelProperty
8584
private var dependency by dependencyProperty
@@ -337,7 +336,7 @@ class DependencyAnalyzerViewImpl(
337336
ExternalSystemBundle.message("external.system.dependency.analyzer.groupId.show")
338337
}
339338
val showDependencySizeAction = toggleAction(showDependencySizeProperty).apply {
340-
templatePresentation.text = "Show Size"
339+
templatePresentation.text = SbtDependencyExternalBundle.message("analyzer.external.showSize.name")
341340
}
342341
val viewOptionsButton =
343342
popupActionGroup(showDependencyGroupIdAction, showDependencySizeAction).apply {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package bitlap.sbt.analyzer.jbexternal
2+
3+
import com.intellij.DynamicBundle
4+
import org.jetbrains.annotations.*
5+
6+
class SbtDependencyExternalBundle : DynamicBundle(BUNDLE) {
7+
companion object {
8+
const val BUNDLE = "messages.SbtPluginExternalBundle"
9+
private val INSTANCE = SbtDependencyExternalBundle()
10+
11+
@Nls
12+
fun message(@NotNull @PropertyKey(resourceBundle = BUNDLE) key: String, @NotNull vararg params: Any): String =
13+
INSTANCE.getMessage(key, params)
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1+
package bitlap.sbt.analyzer.jbexternal
2+
13
/**
24
* NOTE: Kotlin code can only be referenced and cannot refer to code in src/main/scala
35
* The code for this package is almost copied from https://github.com/JetBrains/intellij-community
4-
*
5-
* @author 梦境迷离
6-
* @version 1.0, 2023/10/7
76
*/
8-
package bitlap.sbt.analyzer.jbexternal;

src/main/kotlin/bitlap/sbt/analyzer/jbexternal/util/ExternalProjectUiUtil.kt

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ internal class ExternalProjectSelector(
3333
}
3434

3535
init {
36-
val dropDownLink = ExternalProjectDropDownLink(property, externalProjects)
37-
.apply { border = JBUI.Borders.empty(BORDER, ICON_TEXT_GAP / 2, BORDER, BORDER) }
38-
val label = JLabel(projectIcon)
39-
.apply { border = JBUI.Borders.empty(BORDER, BORDER, BORDER, ICON_TEXT_GAP / 2) }
36+
val dropDownLink = ExternalProjectDropDownLink(property, externalProjects).apply {
37+
border = JBUI.Borders.empty(BORDER, ICON_TEXT_GAP / 2, BORDER, BORDER)
38+
}
39+
val label = JLabel(projectIcon).apply { border = JBUI.Borders.empty(BORDER, BORDER, BORDER, ICON_TEXT_GAP / 2) }
4040
.apply { labelFor = dropDownLink }
4141

4242
layout = com.intellij.ide.plugins.newui.HorizontalLayout(0)
@@ -46,14 +46,11 @@ internal class ExternalProjectSelector(
4646
}
4747

4848
private fun createPopup(
49-
externalProjects: List<DependencyAnalyzerProject>,
50-
onChange: (DependencyAnalyzerProject) -> Unit
49+
externalProjects: List<DependencyAnalyzerProject>, onChange: (DependencyAnalyzerProject) -> Unit
5150
): JBPopup {
52-
val content = ExternalProjectPopupContent(externalProjects)
53-
.apply { whenMousePressed { onChange(selectedValue) } }
54-
return JBPopupFactory.getInstance()
55-
.createComponentPopupBuilder(content, null)
56-
.createPopup()
51+
val content =
52+
ExternalProjectPopupContent(externalProjects).apply { whenMousePressed { onChange(selectedValue) } }
53+
return JBPopupFactory.getInstance().createComponentPopupBuilder(content, null).createPopup()
5754
.apply { content.whenMousePressed(listener = ::closeOk) }
5855
}
5956

@@ -77,32 +74,22 @@ internal class ExternalProjectSelector(
7774
isSelected: Boolean,
7875
cellHasFocus: Boolean
7976
): Component {
80-
return JLabel()
81-
.apply { if (value != null) icon = projectIcon }
82-
.apply { if (value != null) text = value.title }
83-
.apply { border = emptyListCellBorder(list, index) }
77+
return JLabel().apply { if (value != null) icon = projectIcon }
78+
.apply { if (value != null) text = value.title }.apply { border = emptyListCellBorder(list, index) }
8479
.apply { iconTextGap = JBUI.scale(ICON_TEXT_GAP) }
8580
.apply { background = if (isSelected) list.selectionBackground else list.background }
8681
.apply { foreground = if (isSelected) list.selectionForeground else list.foreground }
87-
.apply { isOpaque = true }
88-
.apply { isEnabled = list.isEnabled }
89-
.apply { font = list.font }
82+
.apply { isOpaque = true }.apply { isEnabled = list.isEnabled }.apply { font = list.font }
9083
}
9184
}
9285

9386
private inner class ExternalProjectDropDownLink(
9487
property: ObservableMutableProperty<DependencyAnalyzerProject?>,
9588
externalProjects: List<DependencyAnalyzerProject>,
96-
) : DropDownLink<DependencyAnalyzerProject?>(
97-
property.get(),
98-
{ createPopup(externalProjects, it::selectedItem.setter) }
99-
) {
100-
override fun popupPoint() =
101-
super.popupPoint()
102-
.apply { x += insets.left }
103-
.apply { x -= JBUI.scale(BORDER) }
104-
.apply { x -= projectIcon.iconWidth }
105-
.apply { x -= JBUI.scale(ICON_TEXT_GAP) }
89+
) : DropDownLink<DependencyAnalyzerProject?>(property.get(),
90+
{ createPopup(externalProjects, it::selectedItem.setter) }) {
91+
override fun popupPoint() = super.popupPoint().apply { x += insets.left }.apply { x -= JBUI.scale(BORDER) }
92+
.apply { x -= projectIcon.iconWidth }.apply { x -= JBUI.scale(ICON_TEXT_GAP) }
10693

10794
override fun itemToString(item: DependencyAnalyzerProject?): String = when (item) {
10895
null -> ExternalSystemBundle.message("external.system.dependency.analyzer.projects.empty")

src/main/kotlin/bitlap/sbt/analyzer/jbexternal/util/ScopeUiUtil.kt

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
22
package bitlap.sbt.analyzer.jbexternal.util
33

4-
import org.apache.commons.lang.StringUtils
54
import java.awt.Component
6-
import javax.swing.*
5+
import javax.swing.JCheckBox
6+
import javax.swing.JLabel
7+
import javax.swing.JList
8+
import javax.swing.JPanel
9+
import javax.swing.ListCellRenderer
10+
import javax.swing.ListSelectionModel
711

812
import com.intellij.ide.nls.NlsMessages
913
import com.intellij.openapi.externalSystem.dependency.analyzer.DependencyAnalyzerDependency.Scope
@@ -12,10 +16,10 @@ import com.intellij.openapi.observable.properties.GraphProperty
1216
import com.intellij.openapi.observable.properties.ObservableMutableProperty
1317
import com.intellij.openapi.observable.properties.PropertyGraph
1418
import com.intellij.openapi.observable.util.bind
15-
import com.intellij.openapi.ui.popup.JBPopup
16-
import com.intellij.openapi.ui.popup.JBPopupFactory
1719
import com.intellij.openapi.observable.util.whenItemSelected
1820
import com.intellij.openapi.observable.util.whenMousePressed
21+
import com.intellij.openapi.ui.popup.JBPopup
22+
import com.intellij.openapi.ui.popup.JBPopupFactory
1923
import com.intellij.openapi.util.NlsSafe
2024
import com.intellij.ui.ListUtil
2125
import com.intellij.ui.components.DropDownLink
@@ -26,11 +30,12 @@ import com.intellij.util.ui.ThreeStateCheckBox
2630
@Suppress("DEPRECATION")
2731
internal class SearchScopeSelector(property: ObservableMutableProperty<List<ScopeItem>>) : JPanel() {
2832
init {
29-
val dropDownLink = SearchScopeDropDownLink(property)
30-
.apply { border = JBUI.Borders.empty(BORDER, ICON_TEXT_GAP / 2, BORDER, BORDER) }
31-
val label = JLabel(ExternalSystemBundle.message("external.system.dependency.analyzer.scope.label"))
32-
.apply { border = JBUI.Borders.empty(BORDER, BORDER, BORDER, ICON_TEXT_GAP / 2) }
33-
.apply { labelFor = dropDownLink }
33+
val dropDownLink = SearchScopeDropDownLink(property).apply {
34+
border = JBUI.Borders.empty(BORDER, ICON_TEXT_GAP / 2, BORDER, BORDER)
35+
}
36+
val label = JLabel(ExternalSystemBundle.message("external.system.dependency.analyzer.scope.label")).apply {
37+
border = JBUI.Borders.empty(BORDER, BORDER, BORDER, ICON_TEXT_GAP / 2)
38+
}.apply { labelFor = dropDownLink }
3439

3540
layout = com.intellij.ide.plugins.newui.HorizontalLayout(0)
3641
border = JBUI.Borders.empty()
@@ -102,60 +107,44 @@ private class SearchScopePopupContent(scopes: List<ScopeItem>) : JBList<ScopePro
102107
fun createPopup(scopes: List<ScopeItem>, onChange: (List<ScopeItem>) -> Unit): JBPopup {
103108
val content = SearchScopePopupContent(scopes)
104109
content.afterChange(onChange)
105-
return JBPopupFactory.getInstance()
106-
.createComponentPopupBuilder(content, null)
107-
.createPopup()
110+
return JBPopupFactory.getInstance().createComponentPopupBuilder(content, null).createPopup()
108111
}
109112
}
110113
}
111114

112115
private class SearchScopePropertyRenderer : ListCellRenderer<ScopeProperty> {
113116
override fun getListCellRendererComponent(
114-
list: JList<out ScopeProperty>,
115-
value: ScopeProperty,
116-
index: Int,
117-
isSelected: Boolean,
118-
cellHasFocus: Boolean
117+
list: JList<out ScopeProperty>, value: ScopeProperty, index: Int, isSelected: Boolean, cellHasFocus: Boolean
119118
): Component {
120119
val checkBox = when (value) {
121-
is ScopeProperty.Any ->
122-
ThreeStateCheckBox(ExternalSystemBundle.message("external.system.dependency.analyzer.scope.any"))
123-
.apply { isThirdStateEnabled = false }
124-
.apply { state = value.property.get() }
125-
.bind(value.property)
126-
127-
is ScopeProperty.Just ->
128-
JCheckBox(value.scope.title)
129-
.apply { this@apply.isSelected = value.property.get() }
130-
.bind(value.property)
120+
is ScopeProperty.Any -> ThreeStateCheckBox(ExternalSystemBundle.message("external.system.dependency.analyzer.scope.any")).apply {
121+
isThirdStateEnabled = false
122+
}.apply { state = value.property.get() }.bind(value.property)
123+
124+
is ScopeProperty.Just -> JCheckBox(value.scope.title).apply { this@apply.isSelected = value.property.get() }
125+
.bind(value.property)
131126
}
132-
return checkBox
133-
.apply { border = emptyListCellBorder(list, index, if (index > 0) 1 else 0) }
127+
return checkBox.apply { border = emptyListCellBorder(list, index, if (index > 0) 1 else 0) }
134128
.apply { background = if (isSelected) list.selectionBackground else list.background }
135129
.apply { foreground = if (isSelected) list.selectionForeground else list.foreground }
136-
.apply { isOpaque = true }
137-
.apply { isEnabled = list.isEnabled }
138-
.apply { font = list.font }
130+
.apply { isOpaque = true }.apply { isEnabled = list.isEnabled }.apply { font = list.font }
139131
}
140132
}
141133

142134
private class SearchScopeDropDownLink(
143135
property: ObservableMutableProperty<List<ScopeItem>>
144136
) : DropDownLink<List<ScopeItem>>(
145137
property.get(),
146-
{ SearchScopePopupContent.createPopup(property.get(), it::selectedItem.setter) }
147-
) {
148-
override fun popupPoint() =
149-
super.popupPoint()
150-
.apply { x += insets.left }
138+
{ SearchScopePopupContent.createPopup(property.get(), it::selectedItem.setter) }) {
139+
override fun popupPoint() = super.popupPoint().apply { x += insets.left }
151140

152141
override fun itemToString(item: List<ScopeItem>): @NlsSafe String {
153142
return when {
154143
item.all { it.isSelected } -> ExternalSystemBundle.message("external.system.dependency.analyzer.scope.any")
155144
!item.any { it.isSelected } -> ExternalSystemBundle.message("external.system.dependency.analyzer.scope.none")
156145
else -> {
157146
val scopes = item.filter { it.isSelected }.map { it.scope.title }
158-
StringUtils.abbreviate(NlsMessages.formatNarrowAndList(scopes), 30)
147+
abbreviate(NlsMessages.formatNarrowAndList(scopes), 30)
159148
}
160149
}
161150
}
@@ -169,8 +158,7 @@ private class SearchScopeDropDownLink(
169158
}
170159

171160
internal class ScopeItem(
172-
val scope: Scope,
173-
val isSelected: Boolean
161+
val scope: Scope, val isSelected: Boolean
174162
) {
175163
override fun toString() = "$isSelected: $scope"
176164
}

0 commit comments

Comments
 (0)