Skip to content

Commit 26729c6

Browse files
committed
update
1 parent abf2bf5 commit 26729c6

13 files changed

+69
-33
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ 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.DataProvider
1817
import com.intellij.openapi.actionSystem.DataSink
1918
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys
2019
import com.intellij.openapi.application.invokeLater

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}

src/main/scala/bitlap/sbt/analyzer/SbtDependencyAnalyzerContributor.scala

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -280,32 +280,37 @@ final class SbtDependencyAnalyzerContributor(project: Project) extends Dependenc
280280

281281
}
282282

283-
object SbtDependencyAnalyzerContributor extends SettingsState.SettingsChangeListener:
284-
285-
final val isAvailable = new AtomicBoolean(true)
283+
object SbtDependencyAnalyzerContributor
284+
extends SettingsState.SettingsChangeListener,
285+
SbtReimportProject.ReimportProjectListener:
286+
import com.intellij.openapi.observable.properties.AtomicProperty
287+
private final val dependencyIsAvailable = new AtomicProperty[Boolean](true)
286288

287289
// if data change
288-
override def onAnalyzerConfigurationChanged(project: Project, settingsState: SettingsState): Unit = {
289-
isAvailable.set(false)
290-
SbtUtils.refreshProject(project)
291-
isAvailable.set(true)
290+
override def onConfigurationChanged(project: Project, settingsState: SettingsState): Unit = {
291+
SbtReimportProject.ReimportProjectPublisher.onReimportProject(project)
292+
}
293+
294+
override def onReimportProject(project: Project): Unit = {
295+
SbtUtils.forceRefreshProject(project)
292296
}
293297

294298
ApplicationManager.getApplication.getMessageBus.connect().subscribe(SettingsState._Topic, this)
299+
ApplicationManager.getApplication.getMessageBus.connect().subscribe(SbtReimportProject._Topic, this)
295300

296-
private final val isNotifying = new AtomicBoolean(false)
301+
private final val hasNotified = new AtomicBoolean(false)
297302

298303
private def isValidFile(project: Project, file: String): Boolean = {
299-
if (isAvailable.get()) {
304+
if (dependencyIsAvailable.get()) {
300305
val lastModified = VfsUtil.findFile(Path.of(file), true).getTimeStamp
301306
val upToDate =
302307
System.currentTimeMillis() <= lastModified + SettingsState.getSettings(project).fileCacheTimeout * 1000
303308
if (!upToDate) {
304-
isAvailable.set(false)
309+
dependencyIsAvailable.set(false)
305310
}
306-
isAvailable.get()
311+
dependencyIsAvailable.get()
307312
} else {
308-
isAvailable.get()
313+
dependencyIsAvailable.get()
309314
}
310315
}
311316

@@ -370,10 +375,10 @@ object SbtDependencyAnalyzerContributor extends SettingsState.SettingsChangeList
370375

371376
if (DependencyUtils.canIgnoreModule(module)) return Collections.emptyList()
372377

373-
if (isNotifying.get() && SbtUtils.untilProjectReady(project)) {
378+
if (hasNotified.get() && SbtUtils.untilProjectReady(project)) {
374379
// must reload project to enable it
375380
SbtShellOutputAnalysisTask.reloadTask.executeCommand(project)
376-
isNotifying.compareAndSet(true, false)
381+
hasNotified.compareAndSet(true, false)
377382
}
378383

379384
// if the analysis files already exist (.dot), use it directly.
@@ -402,7 +407,7 @@ object SbtDependencyAnalyzerContributor extends SettingsState.SettingsChangeList
402407
createRootScopeNode(scope, project)
403408
)
404409
} else {
405-
isAvailable.set(true)
410+
dependencyIsAvailable.set(true)
406411
SbtShellDependencyAnalysisTask.dependencyDotTask.executeCommand(
407412
project,
408413
moduleData,
@@ -433,7 +438,7 @@ object SbtDependencyAnalyzerContributor extends SettingsState.SettingsChangeList
433438
}
434439
} catch {
435440
case _: AnalyzerCommandNotFoundException =>
436-
if (isNotifying.compareAndSet(false, true)) {
441+
if (hasNotified.compareAndSet(false, true)) {
437442
Notifications.notifyAndCreateSdapFile(project)
438443
}
439444
break()

src/main/scala/bitlap/sbt/analyzer/SbtDependencyAnalyzerPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void apply() {
6060
}
6161
if (changed) {
6262
Notifications$.MODULE$.notifySettingsChanged(project);
63-
SettingsState.SettingsChangePublisher().onAnalyzerConfigurationChanged(this.project, settings);
63+
SettingsState.SettingsChangePublisher().onConfigurationChanged(this.project, settings);
6464
}
6565
}
6666

src/main/scala/bitlap/sbt/analyzer/SettingsState.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object SettingsState {
5050

5151
trait SettingsChangeListener:
5252

53-
def onAnalyzerConfigurationChanged(project: Project, settingsState: SettingsState): Unit
53+
def onConfigurationChanged(project: Project, settingsState: SettingsState): Unit
5454

5555
end SettingsChangeListener
5656

src/main/scala/bitlap/sbt/analyzer/action/SbtRefreshDependenciesAction.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package sbt
33
package analyzer
44
package action
55

6-
import bitlap.sbt.analyzer.util.SbtUtils
6+
import bitlap.sbt.analyzer.util.SbtReimportProject
77

88
import com.intellij.openapi.actionSystem.AnActionEvent
99

@@ -15,9 +15,7 @@ final class SbtRefreshDependenciesAction extends BaseRefreshDependenciesAction:
1515
SbtDependencyAnalyzerBundle.message("analyzer.refresh.dependencies.description")
1616

1717
override def actionPerformed(e: AnActionEvent): Unit = {
18-
SbtDependencyAnalyzerContributor.isAvailable.set(false)
19-
SbtUtils.refreshProject(e.getProject)
20-
SbtDependencyAnalyzerContributor.isAvailable.set(true)
18+
SbtReimportProject.ReimportProjectPublisher.onReimportProject(e.getProject)
2119
}
2220

2321
end SbtRefreshDependenciesAction

src/main/scala/bitlap/sbt/analyzer/action/SbtRefreshSnapshotDependenciesAction.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package bitlap.sbt.analyzer.action
22

33
import bitlap.sbt.analyzer.*
44
import bitlap.sbt.analyzer.task.*
5+
import bitlap.sbt.analyzer.util.SbtReimportProject
56
import bitlap.sbt.analyzer.util.SbtUtils
67

78
import com.intellij.openapi.actionSystem.AnActionEvent
@@ -15,10 +16,8 @@ final class SbtRefreshSnapshotDependenciesAction extends BaseRefreshDependencies
1516
SbtDependencyAnalyzerBundle.message("analyzer.refresh.snapshot.dependencies.description")
1617

1718
override def actionPerformed(e: AnActionEvent): Unit = {
18-
SbtDependencyAnalyzerContributor.isAvailable.set(false)
1919
SbtShellOutputAnalysisTask.refreshSnapshotsTask.executeCommand(e.getProject)
20-
SbtUtils.refreshProject(e.getProject)
21-
SbtDependencyAnalyzerContributor.isAvailable.set(true)
20+
SbtReimportProject.ReimportProjectPublisher.onReimportProject(e.getProject)
2221
}
2322

2423
end SbtRefreshSnapshotDependenciesAction

src/main/scala/bitlap/sbt/analyzer/parser/DotUtil.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import scala.util.control.Breaks.breakable
1313
import org.jetbrains.plugins.scala.extensions.inReadAction
1414
import org.jetbrains.plugins.scala.project.VirtualFileExt
1515

16+
import com.intellij.openapi.diagnostic.Logger
1617
import com.intellij.openapi.vfs.VfsUtil
1718

1819
import analyzer.util.Notifications
@@ -23,6 +24,8 @@ import model.ModuleContext
2324

2425
object DotUtil {
2526

27+
private val LOG = Logger.getInstance(getClass)
28+
2629
private lazy val parser = (new Parser).forEngine(ValidatorEngine.DOT).notValidating()
2730

2831
private def parseAsGraphTestOnly(file: String): MutableGraph = {
@@ -61,6 +64,7 @@ object DotUtil {
6164
}
6265
} catch {
6366
case ignore: Throwable =>
67+
LOG.error(ignore)
6468
Notifications.notifyParseFileError(file, "The file parsing failed")
6569
null
6670
}

src/main/scala/bitlap/sbt/analyzer/task/RefreshSnapshotsTask.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ final class RefreshSnapshotsTask extends SbtShellOutputAnalysisTask[Unit]:
2020
getCommandOutputLines(
2121
project,
2222
"""
23-
|set update / skip := false
23+
|set update / skip := false;
2424
|set csrConfiguration := csrConfiguration.value.withTtl(Option(scala.concurrent.duration.DurationInt(0).seconds));
25-
|update
25+
|update;
2626
|""".stripMargin
2727
)
2828
} else {
2929
getCommandOutputLines(
3030
project,
3131
"""
32-
|set update / skip := false
33-
|update
32+
|set update / skip := false;
33+
|update;
3434
|""".stripMargin
3535
)
3636
}

0 commit comments

Comments
 (0)