Skip to content

Commit 1f263c2

Browse files
Support IDEA 243.x (#137)
* migrate getData to uiDataSnapshot: platform * support idea 243.x
1 parent d47af96 commit 1f263c2

22 files changed

+216
-147
lines changed

.github/workflows/ScalaCI.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,60 @@ jobs:
1313
build:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- name: Set up JDK 17
18-
uses: actions/setup-java@v1
18+
uses: actions/setup-java@v4
1919
with:
20+
distribution: temurin
2021
java-version: 17
21-
cache: 'sbt'
22+
cache: sbt
23+
- uses: sbt/setup-sbt@v1
24+
- uses: coursier/cache-action@v6
2225
- name: Build
2326
run: sbt compile
2427

2528
lint:
2629
runs-on: ubuntu-latest
2730
steps:
28-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@v4
2932
- name: Set up JDK 17
30-
uses: actions/setup-java@v1
33+
uses: actions/setup-java@v4
3134
with:
35+
distribution: temurin
3236
java-version: 17
33-
cache: 'sbt'
37+
cache: sbt
38+
- uses: sbt/setup-sbt@v1
39+
- uses: coursier/cache-action@v6
3440
- name: Check Style
3541
run: sbt check
3642

3743
test:
3844
runs-on: ubuntu-latest
3945
steps:
40-
- uses: actions/checkout@v3
46+
- uses: actions/checkout@v4
4147
- name: Setup JDK
42-
uses: actions/setup-java@v1
48+
uses: actions/setup-java@v4
4349
with:
50+
distribution: temurin
4451
java-version: 17
45-
cache: 'sbt'
52+
cache: sbt
53+
- uses: sbt/setup-sbt@v1
54+
- uses: coursier/cache-action@v6
4655
- name: Test
4756
run: sbt test
4857

4958
verification:
5059
runs-on: ubuntu-latest
5160
steps:
52-
- uses: actions/checkout@v3
61+
- uses: actions/checkout@v4
5362
- name: Set up JDK 17
54-
uses: actions/setup-java@v1
63+
uses: actions/setup-java@v4
5564
with:
65+
distribution: temurin
5666
java-version: 17
57-
cache: 'sbt'
67+
cache: sbt
68+
- uses: sbt/setup-sbt@v1
69+
- uses: coursier/cache-action@v6
5870
- name: Check Binary Compatibility
5971
run: sbt runPluginVerifier
6072

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ lazy val ktVersion = "1.9.10"
1111

1212
// https://youtrack.jetbrains.com/articles/IDEA-A-2100661679/IntelliJ-IDEA-2023.3-Latest-Builds
1313
// NOTE: Latest-Builds 233
14-
lazy val intellijVersion = "242.21829.142"
15-
lazy val pluginVersion = s"0.5.0-$intellijVersion"
14+
lazy val intellijVersion = "243.24978.46"
15+
lazy val pluginVersion = s"0.6.0-$intellijVersion"
1616

1717
ThisBuild / version := pluginVersion
1818

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

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

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

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import bitlap.sbt.analyzer.jbexternal.util.getDisplayText
1414
import com.intellij.icons.AllIcons
1515
import com.intellij.openapi.Disposable
1616
import com.intellij.openapi.actionSystem.CommonDataKeys
17+
import com.intellij.openapi.actionSystem.DataSink
1718
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys
1819
import com.intellij.openapi.application.invokeLater
1920
import com.intellij.openapi.application.runInEdt
2021
import com.intellij.openapi.module.Module
2122
import com.intellij.openapi.diagnostic.logger
2223
import com.intellij.openapi.externalSystem.autoimport.ExternalSystemProjectNotificationAware.Companion.isNotificationVisibleProperty
23-
import com.intellij.openapi.externalSystem.autoimport.ProjectRefreshAction
2424
import com.intellij.openapi.externalSystem.dependency.analyzer.DependencyAnalyzerDependency
2525
import com.intellij.openapi.externalSystem.dependency.analyzer.DependencyAnalyzerExtension
2626
import com.intellij.openapi.externalSystem.dependency.analyzer.DependencyAnalyzerProject
@@ -53,7 +53,7 @@ import com.intellij.openapi.externalSystem.dependency.analyzer.DependencyAnalyze
5353
*/
5454
class DependencyAnalyzerViewImpl(
5555
private val project: Project, private val systemId: ProjectSystemId, private val parentDisposable: Disposable
56-
) : DependencyAnalyzerView , DataProvider {
56+
) : DependencyAnalyzerView {
5757

5858
private val iconsProvider = ExternalSystemIconProvider.getExtension(systemId)
5959
private val contributor =
@@ -142,22 +142,19 @@ class DependencyAnalyzerViewImpl(
142142
return externalProjects.find(predicate)
143143
}
144144

145-
override fun getAnalyzerData(dataId: String): Any? {
146-
return when (dataId) {
147-
DependencyAnalyzerView.VIEW.name -> this
148-
CommonDataKeys.PROJECT.name -> project
149-
ExternalSystemDataKeys.EXTERNAL_SYSTEM_ID.name -> systemId
150-
PlatformCoreDataKeys.MODULE.name -> externalProject?.module
151-
else -> null
152-
}
153-
}
154-
155145
private fun updateViewModel() {
156146
executeLoadingTaskOnEdt {
157147
updateExternalProjectsModel()
158148
}
159149
}
160150

151+
override fun uiDataSnapshot(sink: DataSink) {
152+
sink[DependencyAnalyzerView.VIEW] = this
153+
sink[CommonDataKeys.PROJECT] = project
154+
sink[ExternalSystemDataKeys.EXTERNAL_SYSTEM_ID] = systemId
155+
sink[PlatformCoreDataKeys.MODULE] = externalProject?.module
156+
}
157+
161158
private fun Iterable<Dependency>.filterDependencies(): List<Dependency> {
162159
val dependencyDataFilter = dependencyDataFilter
163160
val dependencyScopeFilter = dependencyScopeFilter.filter { it.isSelected }.map { it.scope }
@@ -347,19 +344,27 @@ class DependencyAnalyzerViewImpl(
347344
}.asActionButton(ACTION_PLACE).bindEnabled(!dependencyLoadingProperty)
348345
val reloadNotificationProperty = isNotificationVisibleProperty(project, systemId)
349346
val projectReloadSeparator = separator().bindVisible(reloadNotificationProperty)
350-
val projectReloadAction = action { ProjectRefreshAction.Manager.refreshProject(project) }.apply {
347+
val projectReloadAction = action { ProjectUtil.refreshProject(project) }.apply {
351348
templatePresentation.icon = AllIcons.Actions.BuildLoadChanges
352349
}.asActionButton(ACTION_PLACE).bindVisible(reloadNotificationProperty)
353350

354351
val dependencyTitle = label(ExternalSystemBundle.message("external.system.dependency.analyzer.resolved.title"))
355-
val dependencyList = DependencyList(
356-
dependencyListModel, showDependencyGroupIdProperty, showDependencySizeProperty, this
357-
).bindEmptyText(dependencyEmptyTextProperty).bindDependency(dependencyProperty)
358-
.bindEnabled(!dependencyLoadingProperty)
359-
val dependencyTree = DependencyTree(
360-
dependencyTreeModel, showDependencyGroupIdProperty, showDependencySizeProperty, this
361-
).bindEmptyText(dependencyEmptyTextProperty).bindDependency(dependencyProperty)
362-
.bindEnabled(!dependencyLoadingProperty)
352+
val dependencyList =
353+
object : DependencyList(dependencyListModel, showDependencyGroupIdProperty, showDependencySizeProperty) {
354+
override fun uiDataSnapshot(sink: DataSink) {
355+
super.uiDataSnapshot(sink)
356+
DataSink.uiDataSnapshot(sink, this@DependencyAnalyzerViewImpl)
357+
}
358+
}.bindEmptyText(dependencyEmptyTextProperty).bindDependency(dependencyProperty)
359+
.bindEnabled(!dependencyLoadingProperty)
360+
val dependencyTree =
361+
object : DependencyTree(dependencyTreeModel, showDependencyGroupIdProperty, showDependencySizeProperty) {
362+
override fun uiDataSnapshot(sink: DataSink) {
363+
super.uiDataSnapshot(sink)
364+
DataSink.uiDataSnapshot(sink, this@DependencyAnalyzerViewImpl)
365+
}
366+
}.bindEmptyText(dependencyEmptyTextProperty).bindDependency(dependencyProperty)
367+
.bindEnabled(!dependencyLoadingProperty)
363368
val dependencyPanel = cardPanel<Boolean> {
364369
ScrollPaneFactory.createScrollPane(if (it) dependencyTree else dependencyList, true)
365370
}.bind(showDependencyTreeProperty)
@@ -378,9 +383,13 @@ class DependencyAnalyzerViewImpl(
378383
.bindEnabled(showDependencyTreeProperty and !dependencyLoadingProperty)
379384

380385
val usagesTitle = label(usagesTitleProperty)
381-
val usagesTree = UsagesTree(
382-
usagesTreeModel, showDependencyGroupIdProperty, showDependencySizeProperty, this
383-
).apply { emptyText.text = "" }.bindEnabled(!dependencyLoadingProperty)
386+
val usagesTree =
387+
object : UsagesTree(usagesTreeModel, showDependencyGroupIdProperty, showDependencySizeProperty) {
388+
override fun uiDataSnapshot(sink: DataSink) {
389+
super.uiDataSnapshot(sink)
390+
DataSink.uiDataSnapshot(sink, this@DependencyAnalyzerViewImpl)
391+
}
392+
}.apply { emptyText.text = "" }.bindEnabled(!dependencyLoadingProperty)
384393
val expandUsagesTreeButton =
385394
expandTreeAction(usagesTree).asActionButton(ACTION_PLACE).bindEnabled(!dependencyLoadingProperty)
386395
val collapseUsagesTreeButton =

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

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import javax.swing.tree.DefaultMutableTreeNode
88
import javax.swing.tree.TreeModel
99

1010
import bitlap.sbt.analyzer.jbexternal.SbtDAArtifact
11-
import bitlap.sbt.analyzer.jbexternal.DataProvider
1211

1312
import com.intellij.icons.AllIcons
13+
import com.intellij.openapi.actionSystem.DataSink
14+
import com.intellij.openapi.actionSystem.UiDataProvider
1415
import com.intellij.openapi.application.invokeLater
1516
import com.intellij.openapi.externalSystem.dependency.analyzer.DependencyAnalyzerView
1617
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle
@@ -86,8 +87,8 @@ private fun SimpleColoredComponent.customizeCellRenderer(
8687
}
8788

8889
internal abstract class AbstractDependencyList(
89-
model: ListModel<DependencyGroup>, private val dataProvider: DataProvider
90-
) : JBList<DependencyGroup>(model), DataProvider {
90+
model: ListModel<DependencyGroup>
91+
) : JBList<DependencyGroup>(model), UiDataProvider {
9192

9293
private val dependencyProperty = AtomicProperty<Dependency?>(null)
9394
private val dependencyGroupProperty = AtomicProperty<DependencyGroup?>(null)
@@ -96,12 +97,9 @@ internal abstract class AbstractDependencyList(
9697
dependencyProperty.bind(property)
9798
}
9899

99-
override fun getAnalyzerData(dataId: String): Any? {
100-
return when (dataId) {
101-
DependencyAnalyzerView.DEPENDENCY.name -> dependencyProperty.get()
102-
DependencyAnalyzerView.DEPENDENCIES.name -> dependencyGroupProperty.get()
103-
else -> dataProvider.getAnalyzerData(dataId)
104-
}
100+
override fun uiDataSnapshot(sink: DataSink) {
101+
sink[DependencyAnalyzerView.DEPENDENCY] = dependencyProperty.get()
102+
sink[DependencyAnalyzerView.DEPENDENCIES] = dependencyGroupProperty.get()?.variances
105103
}
106104

107105
init {
@@ -113,8 +111,8 @@ internal abstract class AbstractDependencyList(
113111
}
114112

115113
internal abstract class AbstractDependencyTree(
116-
model: TreeModel, private val dataProvider: DataProvider
117-
) : SimpleTree(model), DataProvider {
114+
model: TreeModel
115+
) : SimpleTree(model), UiDataProvider {
118116

119117
private val dependencyProperty = AtomicProperty<Dependency?>(null)
120118
private val dependencyGroupProperty = AtomicProperty<DependencyGroup?>(null)
@@ -123,12 +121,9 @@ internal abstract class AbstractDependencyTree(
123121
dependencyProperty.bind(property)
124122
}
125123

126-
override fun getAnalyzerData(dataId: String): Any? {
127-
return when (dataId) {
128-
DependencyAnalyzerView.DEPENDENCY.name -> dependencyProperty.get()
129-
DependencyAnalyzerView.DEPENDENCIES.name -> dependencyGroupProperty.get()
130-
else -> dataProvider.getAnalyzerData(dataId)
131-
}
124+
override fun uiDataSnapshot(sink: DataSink) {
125+
sink[DependencyAnalyzerView.DEPENDENCY] = dependencyProperty.get()
126+
sink[DependencyAnalyzerView.DEPENDENCIES] = dependencyGroupProperty.get()?.variances
132127
}
133128

134129
init {
@@ -140,12 +135,11 @@ internal abstract class AbstractDependencyTree(
140135
}
141136
}
142137

143-
internal class DependencyList(
138+
internal open class DependencyList(
144139
model: ListModel<DependencyGroup>,
145140
showGroupIdProperty: ObservableProperty<Boolean>,
146141
showSizeProperty: ObservableProperty<Boolean>,
147-
dataProvider: DataProvider
148-
) : AbstractDependencyList(model, dataProvider) {
142+
) : AbstractDependencyList(model) {
149143
init {
150144
ListUiUtil.Selection.installSelectionOnRightClick(this)
151145
PopupHandler.installPopupMenu(
@@ -155,12 +149,11 @@ internal class DependencyList(
155149
}
156150
}
157151

158-
internal class DependencyTree(
152+
internal open class DependencyTree(
159153
model: TreeModel,
160154
showGroupIdProperty: ObservableProperty<Boolean>,
161155
showSizeProperty: ObservableProperty<Boolean>,
162-
dataProvider: DataProvider
163-
) : AbstractDependencyTree(model, dataProvider) {
156+
) : AbstractDependencyTree(model) {
164157
init {
165158
PopupHandler.installPopupMenu(
166159
this, "ExternalSystem.DependencyAnalyzer.DependencyTreeGroup", DependencyAnalyzerView.ACTION_PLACE
@@ -169,12 +162,11 @@ internal class DependencyTree(
169162
}
170163
}
171164

172-
internal class UsagesTree(
165+
internal open class UsagesTree(
173166
model: TreeModel,
174167
showGroupIdProperty: ObservableProperty<Boolean>,
175168
showSizeProperty: ObservableProperty<Boolean>,
176-
dataProvider: DataProvider
177-
) : AbstractDependencyTree(model, dataProvider) {
169+
) : AbstractDependencyTree(model) {
178170
init {
179171
PopupHandler.installPopupMenu(
180172
this, "ExternalSystem.DependencyAnalyzer.UsagesTreeGroup", DependencyAnalyzerView.ACTION_PLACE
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package bitlap.sbt.analyzer.jbexternal.util
2+
3+
import com.intellij.openapi.externalSystem.autoimport.ExternalSystemProjectNotificationAware
4+
import com.intellij.openapi.externalSystem.autoimport.ExternalSystemProjectTracker
5+
import com.intellij.openapi.externalSystem.service.project.trusted.ExternalSystemTrustedProjectDialog
6+
import com.intellij.openapi.project.Project
7+
8+
@Suppress("DEPRECATION")
9+
object ProjectUtil {
10+
fun refreshProject(project: Project) {
11+
val projectNotificationAware = ExternalSystemProjectNotificationAware.getInstance(project)
12+
val systemIds = projectNotificationAware.getSystemIds()
13+
if (ExternalSystemTrustedProjectDialog.confirmLoadingUntrustedProject(project, systemIds)) {
14+
val projectTracker = ExternalSystemProjectTracker.getInstance(project)
15+
projectTracker.scheduleProjectRefresh()
16+
}
17+
}
18+
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<idea-plugin>
33
<id>org.bitlap.sbtDependencyAnalyzer</id>
44
<name>Sbt Dependency Analyzer</name>
5-
<version>0.5.0-242.21829.142</version>
5+
<version>0.6.0-243.24978.46</version>
66
<vendor url="https://github.com/bitlap/intellij-sbt-dependency-analyzer" email="[email protected]">Bitlap
77
</vendor>
88
<!-- please see https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html for description -->
99
<!-- old version support, see branch idea231.x -->
10-
<idea-version since-build="242.0"/>
10+
<idea-version since-build="243.0"/>
1111

1212
<depends>com.intellij.modules.platform</depends>
1313
<depends>com.intellij.modules.lang</depends>
@@ -136,6 +136,12 @@
136136

137137
<![CDATA[
138138
139+
<h1>0.6.0-243.24978.46</h1>
140+
<ul>
141+
<li>Upgrade Dependency.</li>
142+
</ul>
143+
<!-- @@ -->
144+
139145
<h1>0.5.0-242.21829.142</h1>
140146
<ul>
141147
<li>Improve code and API compatibility.</li>

src/main/resources/messages/SbtDependencyAnalyzerBundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ analyzer.notification.addSdap.text=The "{0}" has been added or updated, \
1212
and it has also been ignored by the ".git/info/exclude" file in the git environment, \
1313
please wait a moment, go to see more.
1414
analyzer.notification.setting.changed.title=Sbt Dependency Analyzer settings have been changed
15+
analyzer.notification.reimport.title=Sbt Dependency Analyzer is refreshing the project
1516
analyzer.notification.updated.failure.title=Failed to load!
1617
analyzer.notification.updated.failure.text=Open in browser↗
1718
analyzer.notification.updated.title={0} plugin updated to v{1}

src/main/resources/messages/SbtDependencyAnalyzerBundle_zh.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ analyzer.notification.addSdap.text=已添加或更新文件 “{0}”,\
1212
并且在git环境中也已经被“.git/info/exclude”文件忽略了,\
1313
请稍等片刻,前往查看更多
1414
analyzer.notification.setting.changed.title=Sbt Dependency Analyzer 配置已被更改
15+
analyzer.notification.reimport.title=Sbt Dependency Analyzer 正在刷新项目
1516
analyzer.notification.updated.failure.title=加载失败!
1617
analyzer.notification.updated.failure.text=在浏览器中打开↗
1718
analyzer.notification.updated.title={0} 插件已更新为 v{1}

0 commit comments

Comments
 (0)