Skip to content

Commit

Permalink
Upgrade idea 233.x (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnu-liguobin authored Dec 10, 2023
1 parent 5619623 commit 3cd9a80
Show file tree
Hide file tree
Showing 50 changed files with 326 additions and 329 deletions.
33 changes: 14 additions & 19 deletions .github/workflows/ScalaCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,29 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

cache: 'sbt'
- name: Build
run: sbt compile

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
cache: 'sbt'
- name: Check Style
run: sbt check

test:
runs-on: ubuntu-latest
steps:
Expand All @@ -35,38 +42,26 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 17

cache: 'sbt'
- name: Test
run: sbt test

# - name: Run Test
# if: success() || failure()
# run: sbt coverage test
#
# - name: Aggregate coverage report
# run: sbt coverageAggregate
#
# - name: Upload test coverage report
# run: bash <(curl -s https://codecov.io/bash)

verification:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

cache: 'sbt'
- name: Check Binary Compatibility
run: sbt runPluginVerifier


ci:
runs-on: ubuntu-20.04
needs: [ build, test, verification]
needs: [ build, lint, test, verification]
steps:
- name: Aggregate outcomes
run: echo "build succeeded"
1 change: 1 addition & 0 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
updates.ignore = [ { groupId = "org.scalameta", artifactId = "scalafmt-core" } ]
15 changes: 8 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ lazy val logbackVersion = "1.4.14"
lazy val graphvizVersion = "0.18.1"
lazy val joorVersion = "0.9.15"
lazy val scalatestVersion = "3.2.16"
lazy val pluginVerifierVersion = "1.301"
lazy val pluginVerifierVersion = "1.305"
lazy val ktVersion = "1.9.10"

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

ThisBuild / version := pluginVersion

Expand Down Expand Up @@ -54,8 +56,7 @@ lazy val `sbt-dependency-analyzer` = (project in file("."))
pluginVerifierOptions := pluginVerifierOptions.value.copy(
version = pluginVerifierVersion, // use a specific verifier version
offline = true, // forbid the verifier from reaching the internet
failureLevels =
Set(FailureLevel.INTERNAL_API_USAGES, FailureLevel.COMPATIBILITY_PROBLEMS, FailureLevel.COMPATIBILITY_WARNINGS)
failureLevels = Set(FailureLevel.COMPATIBILITY_PROBLEMS, FailureLevel.COMPATIBILITY_WARNINGS)
),
Global / intellijAttachSources := true,
intellijPlugins ++= Seq("com.intellij.java", "com.intellij.java-i18n", "org.intellij.scala").map(_.toPlugin),
Expand All @@ -74,7 +75,7 @@ lazy val `sbt-dependency-analyzer` = (project in file("."))
"org.jooq" % "joor" % joorVersion,
"org.scalatest" %% "scalatest" % scalatestVersion % Test
),
kotlinVersion := "1.9.21",
kotlinVersion := ktVersion,
Compile / unmanagedSourceDirectories += baseDirectory.value / "src" / "main" / "kotlin",
packageLibraryMappings ++= Seq(
"org.jetbrains.kotlin" % ".*" % ".*" -> None,
Expand Down
5 changes: 0 additions & 5 deletions project/Commands.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import sbt.Command

/** @author
* 梦境迷离
* @since 2023/4/25
* @version 1.0
*/
object Commands {

val FmtSbtCommand = Command.command("fmt")(state => "scalafmtSbt" :: "scalafmtAll" :: state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class DependencyAnalyzerViewImpl(
private var dependencyScopeFilter by dependencyScopeFilterProperty
private var showDependencyWarnings by showDependencyWarningsProperty
private var showDependencyGroupId by showDependencyGroupIdProperty
private var showDependencySize by showDependencySizeProperty

private var dependencyModel by dependencyModelProperty
private var dependency by dependencyProperty
Expand Down Expand Up @@ -337,7 +336,7 @@ class DependencyAnalyzerViewImpl(
ExternalSystemBundle.message("external.system.dependency.analyzer.groupId.show")
}
val showDependencySizeAction = toggleAction(showDependencySizeProperty).apply {
templatePresentation.text = "Show Size"
templatePresentation.text = SbtDependencyExternalBundle.message("analyzer.external.showSize.name")
}
val viewOptionsButton =
popupActionGroup(showDependencyGroupIdAction, showDependencySizeAction).apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package bitlap.sbt.analyzer.jbexternal

import com.intellij.DynamicBundle
import org.jetbrains.annotations.*

class SbtDependencyExternalBundle : DynamicBundle(BUNDLE) {
companion object {
const val BUNDLE = "messages.SbtPluginExternalBundle"
private val INSTANCE = SbtDependencyExternalBundle()

@Nls
fun message(@NotNull @PropertyKey(resourceBundle = BUNDLE) key: String, @NotNull vararg params: Any): String =
INSTANCE.getMessage(key, params)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package bitlap.sbt.analyzer.jbexternal

/**
* NOTE: Kotlin code can only be referenced and cannot refer to code in src/main/scala
* The code for this package is almost copied from https://github.com/JetBrains/intellij-community
*
* @author 梦境迷离
* @version 1.0, 2023/10/7
*/
package bitlap.sbt.analyzer.jbexternal;
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ internal class ExternalProjectSelector(
}

init {
val dropDownLink = ExternalProjectDropDownLink(property, externalProjects)
.apply { border = JBUI.Borders.empty(BORDER, ICON_TEXT_GAP / 2, BORDER, BORDER) }
val label = JLabel(projectIcon)
.apply { border = JBUI.Borders.empty(BORDER, BORDER, BORDER, ICON_TEXT_GAP / 2) }
val dropDownLink = ExternalProjectDropDownLink(property, externalProjects).apply {
border = JBUI.Borders.empty(BORDER, ICON_TEXT_GAP / 2, BORDER, BORDER)
}
val label = JLabel(projectIcon).apply { border = JBUI.Borders.empty(BORDER, BORDER, BORDER, ICON_TEXT_GAP / 2) }
.apply { labelFor = dropDownLink }

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

private fun createPopup(
externalProjects: List<DependencyAnalyzerProject>,
onChange: (DependencyAnalyzerProject) -> Unit
externalProjects: List<DependencyAnalyzerProject>, onChange: (DependencyAnalyzerProject) -> Unit
): JBPopup {
val content = ExternalProjectPopupContent(externalProjects)
.apply { whenMousePressed { onChange(selectedValue) } }
return JBPopupFactory.getInstance()
.createComponentPopupBuilder(content, null)
.createPopup()
val content =
ExternalProjectPopupContent(externalProjects).apply { whenMousePressed { onChange(selectedValue) } }
return JBPopupFactory.getInstance().createComponentPopupBuilder(content, null).createPopup()
.apply { content.whenMousePressed(listener = ::closeOk) }
}

Expand All @@ -77,32 +74,22 @@ internal class ExternalProjectSelector(
isSelected: Boolean,
cellHasFocus: Boolean
): Component {
return JLabel()
.apply { if (value != null) icon = projectIcon }
.apply { if (value != null) text = value.title }
.apply { border = emptyListCellBorder(list, index) }
return JLabel().apply { if (value != null) icon = projectIcon }
.apply { if (value != null) text = value.title }.apply { border = emptyListCellBorder(list, index) }
.apply { iconTextGap = JBUI.scale(ICON_TEXT_GAP) }
.apply { background = if (isSelected) list.selectionBackground else list.background }
.apply { foreground = if (isSelected) list.selectionForeground else list.foreground }
.apply { isOpaque = true }
.apply { isEnabled = list.isEnabled }
.apply { font = list.font }
.apply { isOpaque = true }.apply { isEnabled = list.isEnabled }.apply { font = list.font }
}
}

private inner class ExternalProjectDropDownLink(
property: ObservableMutableProperty<DependencyAnalyzerProject?>,
externalProjects: List<DependencyAnalyzerProject>,
) : DropDownLink<DependencyAnalyzerProject?>(
property.get(),
{ createPopup(externalProjects, it::selectedItem.setter) }
) {
override fun popupPoint() =
super.popupPoint()
.apply { x += insets.left }
.apply { x -= JBUI.scale(BORDER) }
.apply { x -= projectIcon.iconWidth }
.apply { x -= JBUI.scale(ICON_TEXT_GAP) }
) : DropDownLink<DependencyAnalyzerProject?>(property.get(),
{ createPopup(externalProjects, it::selectedItem.setter) }) {
override fun popupPoint() = super.popupPoint().apply { x += insets.left }.apply { x -= JBUI.scale(BORDER) }
.apply { x -= projectIcon.iconWidth }.apply { x -= JBUI.scale(ICON_TEXT_GAP) }

override fun itemToString(item: DependencyAnalyzerProject?): String = when (item) {
null -> ExternalSystemBundle.message("external.system.dependency.analyzer.projects.empty")
Expand Down
68 changes: 28 additions & 40 deletions src/main/kotlin/bitlap/sbt/analyzer/jbexternal/util/ScopeUiUtil.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package bitlap.sbt.analyzer.jbexternal.util

import org.apache.commons.lang.StringUtils
import java.awt.Component
import javax.swing.*
import javax.swing.JCheckBox
import javax.swing.JLabel
import javax.swing.JList
import javax.swing.JPanel
import javax.swing.ListCellRenderer
import javax.swing.ListSelectionModel

import com.intellij.ide.nls.NlsMessages
import com.intellij.openapi.externalSystem.dependency.analyzer.DependencyAnalyzerDependency.Scope
Expand All @@ -12,10 +16,10 @@ import com.intellij.openapi.observable.properties.GraphProperty
import com.intellij.openapi.observable.properties.ObservableMutableProperty
import com.intellij.openapi.observable.properties.PropertyGraph
import com.intellij.openapi.observable.util.bind
import com.intellij.openapi.ui.popup.JBPopup
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.openapi.observable.util.whenItemSelected
import com.intellij.openapi.observable.util.whenMousePressed
import com.intellij.openapi.ui.popup.JBPopup
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.openapi.util.NlsSafe
import com.intellij.ui.ListUtil
import com.intellij.ui.components.DropDownLink
Expand All @@ -26,11 +30,12 @@ import com.intellij.util.ui.ThreeStateCheckBox
@Suppress("DEPRECATION")
internal class SearchScopeSelector(property: ObservableMutableProperty<List<ScopeItem>>) : JPanel() {
init {
val dropDownLink = SearchScopeDropDownLink(property)
.apply { border = JBUI.Borders.empty(BORDER, ICON_TEXT_GAP / 2, BORDER, BORDER) }
val label = JLabel(ExternalSystemBundle.message("external.system.dependency.analyzer.scope.label"))
.apply { border = JBUI.Borders.empty(BORDER, BORDER, BORDER, ICON_TEXT_GAP / 2) }
.apply { labelFor = dropDownLink }
val dropDownLink = SearchScopeDropDownLink(property).apply {
border = JBUI.Borders.empty(BORDER, ICON_TEXT_GAP / 2, BORDER, BORDER)
}
val label = JLabel(ExternalSystemBundle.message("external.system.dependency.analyzer.scope.label")).apply {
border = JBUI.Borders.empty(BORDER, BORDER, BORDER, ICON_TEXT_GAP / 2)
}.apply { labelFor = dropDownLink }

layout = com.intellij.ide.plugins.newui.HorizontalLayout(0)
border = JBUI.Borders.empty()
Expand Down Expand Up @@ -102,60 +107,44 @@ private class SearchScopePopupContent(scopes: List<ScopeItem>) : JBList<ScopePro
fun createPopup(scopes: List<ScopeItem>, onChange: (List<ScopeItem>) -> Unit): JBPopup {
val content = SearchScopePopupContent(scopes)
content.afterChange(onChange)
return JBPopupFactory.getInstance()
.createComponentPopupBuilder(content, null)
.createPopup()
return JBPopupFactory.getInstance().createComponentPopupBuilder(content, null).createPopup()
}
}
}

private class SearchScopePropertyRenderer : ListCellRenderer<ScopeProperty> {
override fun getListCellRendererComponent(
list: JList<out ScopeProperty>,
value: ScopeProperty,
index: Int,
isSelected: Boolean,
cellHasFocus: Boolean
list: JList<out ScopeProperty>, value: ScopeProperty, index: Int, isSelected: Boolean, cellHasFocus: Boolean
): Component {
val checkBox = when (value) {
is ScopeProperty.Any ->
ThreeStateCheckBox(ExternalSystemBundle.message("external.system.dependency.analyzer.scope.any"))
.apply { isThirdStateEnabled = false }
.apply { state = value.property.get() }
.bind(value.property)

is ScopeProperty.Just ->
JCheckBox(value.scope.title)
.apply { this@apply.isSelected = value.property.get() }
.bind(value.property)
is ScopeProperty.Any -> ThreeStateCheckBox(ExternalSystemBundle.message("external.system.dependency.analyzer.scope.any")).apply {
isThirdStateEnabled = false
}.apply { state = value.property.get() }.bind(value.property)

is ScopeProperty.Just -> JCheckBox(value.scope.title).apply { this@apply.isSelected = value.property.get() }
.bind(value.property)
}
return checkBox
.apply { border = emptyListCellBorder(list, index, if (index > 0) 1 else 0) }
return checkBox.apply { border = emptyListCellBorder(list, index, if (index > 0) 1 else 0) }
.apply { background = if (isSelected) list.selectionBackground else list.background }
.apply { foreground = if (isSelected) list.selectionForeground else list.foreground }
.apply { isOpaque = true }
.apply { isEnabled = list.isEnabled }
.apply { font = list.font }
.apply { isOpaque = true }.apply { isEnabled = list.isEnabled }.apply { font = list.font }
}
}

private class SearchScopeDropDownLink(
property: ObservableMutableProperty<List<ScopeItem>>
) : DropDownLink<List<ScopeItem>>(
property.get(),
{ SearchScopePopupContent.createPopup(property.get(), it::selectedItem.setter) }
) {
override fun popupPoint() =
super.popupPoint()
.apply { x += insets.left }
{ SearchScopePopupContent.createPopup(property.get(), it::selectedItem.setter) }) {
override fun popupPoint() = super.popupPoint().apply { x += insets.left }

override fun itemToString(item: List<ScopeItem>): @NlsSafe String {
return when {
item.all { it.isSelected } -> ExternalSystemBundle.message("external.system.dependency.analyzer.scope.any")
!item.any { it.isSelected } -> ExternalSystemBundle.message("external.system.dependency.analyzer.scope.none")
else -> {
val scopes = item.filter { it.isSelected }.map { it.scope.title }
StringUtils.abbreviate(NlsMessages.formatNarrowAndList(scopes), 30)
abbreviate(NlsMessages.formatNarrowAndList(scopes), 30)
}
}
}
Expand All @@ -169,8 +158,7 @@ private class SearchScopeDropDownLink(
}

internal class ScopeItem(
val scope: Scope,
val isSelected: Boolean
val scope: Scope, val isSelected: Boolean
) {
override fun toString() = "$isSelected: $scope"
}
Expand Down
Loading

0 comments on commit 3cd9a80

Please sign in to comment.