Skip to content

Commit b7cac6a

Browse files
committed
Integration into the "Invalidate Caches..." dialog
1 parent ab7fc44 commit b7cac6a

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

third_party/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Vendor change from "JetBrains" to "Google"
66
- Build system change from Basel to Gradle
7+
- New Dart support in the "Invalidate Caches..." dialog
78
- Removal of the old Code Coverage support, all references to com.intellij.coverage.*
89
- Removal of the Dart embedded in HTML support
910
- Remove the "Scope analysis to the current package" feature from the Dart problem view
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.jetbrains.lang.dart.analyzer
2+
3+
import com.intellij.ide.caches.CachesInvalidator
4+
import com.intellij.openapi.project.ProjectManager
5+
import com.intellij.openapi.util.SystemInfoRt
6+
import com.jetbrains.lang.dart.DartBundle
7+
import java.io.File
8+
9+
/**
10+
* A CachesInvalidator for the Dart IntelliJ plugin, on the execution of this invalidator,
11+
* the `~./dartServer/` directory (or equivalent on Windows machines), is deleted.
12+
*/
13+
private class DASSCacheInvalidator : CachesInvalidator() {
14+
15+
override fun getComment(): String = DartBundle.message("analysis.server.cache.invalidate.comment")
16+
17+
override fun getDescription(): String = DartBundle.message("analysis.server.cache.invalidate.description")
18+
19+
override fun optionalCheckboxDefaultValue(): Boolean = false
20+
21+
override fun invalidateCaches() {
22+
val projects = ProjectManager.getInstance().openProjects
23+
for (project in projects) {
24+
val serverService = DartAnalysisServerService.getInstance(project)
25+
serverService.stopServer()
26+
}
27+
val dartServerCacheDirectory = getDartServerCacheDirectory()
28+
if (dartServerCacheDirectory != null && dartServerCacheDirectory.exists()) {
29+
dartServerCacheDirectory.deleteRecursively()
30+
}
31+
}
32+
33+
private fun getDartServerCacheDirectory(): File? {
34+
return if (SystemInfoRt.isWindows) {
35+
val appData = System.getenv("LOCALAPPDATA")
36+
if (appData != null) File(appData, ".dartServer") else null
37+
} else {
38+
val userHome = System.getProperty("user.home")
39+
if (userHome != null) File(userHome, ".dartServer") else null
40+
}
41+
}
42+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
<intentionAction> <className>com.jetbrains.lang.dart.assists.DartQuickAssistIntention$DartQuickAssistIntention14</className> <language/> <bundleName>messages.DartBundle</bundleName> <categoryKey>inspections.group.name</categoryKey> <descriptionDirectoryName>DartQuickAssistIntention</descriptionDirectoryName></intentionAction>
207207

208208
<projectService serviceImplementation="com.jetbrains.lang.dart.analyzer.DartAnalysisServerService"/>
209+
<cachesInvalidator implementation="com.jetbrains.lang.dart.analyzer.DASSCacheInvalidator"/>
209210

210211
<toolWindow id="Dart Analysis" anchor="bottom" icon="DartIcons.Dart_13" doNotActivateOnStart="true" canCloseContents="false"
211212
factoryClass="com.jetbrains.lang.dart.ide.errorTreeView.DartAnalysisToolWindowFactory"/>

third_party/src/main/resources/messages/DartBundle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ analysis.server.snapshot.file.does.not.exist.at.0=the Dart Analysis Server snaps
266266
dart.vm.file.is.not.executable.at.0=the Dart VM file is not executable at location: {0}
267267
analysis.server.snapshot.file.is.not.readable.at.0=the Dart Analysis Server snapshot file is not readable at location: {0}
268268
issue.occurred.with.analysis.server=an issue occurred with the analysis server
269+
analysis.server.cache.invalidate.description=Delete the local Dart analysis server cache directory
270+
analysis.server.cache.invalidate.comment=Recursively deletes .dartServer/ from the local disk
269271

270272
action.Dart.DartSortMembers.text=Sort Members in Dart File
271273
action.Dart.DartSortMembers.description=Sort members in your Dart code

0 commit comments

Comments
 (0)