diff --git a/third_party/CHANGELOG.md b/third_party/CHANGELOG.md
index 651da7597..a77b09cce 100644
--- a/third_party/CHANGELOG.md
+++ b/third_party/CHANGELOG.md
@@ -2,6 +2,8 @@
### Added
+- Support in the "Invalidate Caches..." dialog to remove ~/.dartServer cache
+
### Removed
- "Scope analysis to the current package" feature from the Dart problem view
@@ -10,8 +12,8 @@
### Changed
- - Vendor change from "JetBrains" to "Google"
- - Build system change from Basel to Gradle
+- Vendor change from "JetBrains" to "Google"
+- Build system change from Basel to Gradle
## 251.27812.12
diff --git a/third_party/src/main/java/com/jetbrains/lang/dart/analyzer/DASSCacheInvalidator.kt b/third_party/src/main/java/com/jetbrains/lang/dart/analyzer/DASSCacheInvalidator.kt
new file mode 100644
index 000000000..f2d22a568
--- /dev/null
+++ b/third_party/src/main/java/com/jetbrains/lang/dart/analyzer/DASSCacheInvalidator.kt
@@ -0,0 +1,42 @@
+package com.jetbrains.lang.dart.analyzer
+
+import com.intellij.ide.caches.CachesInvalidator
+import com.intellij.openapi.project.ProjectManager
+import com.intellij.openapi.util.SystemInfoRt
+import com.jetbrains.lang.dart.DartBundle
+import java.io.File
+
+/**
+ * A CachesInvalidator for the Dart IntelliJ plugin, on the execution of this invalidator,
+ * the `~./dartServer/` directory (or equivalent on Windows machines), is deleted.
+ */
+private class DASSCacheInvalidator : CachesInvalidator() {
+
+ override fun getComment(): String = DartBundle.message("analysis.server.cache.invalidate.comment")
+
+ override fun getDescription(): String = DartBundle.message("analysis.server.cache.invalidate.description")
+
+ override fun optionalCheckboxDefaultValue(): Boolean = false
+
+ override fun invalidateCaches() {
+ val projects = ProjectManager.getInstance().openProjects
+ for (project in projects) {
+ val serverService = DartAnalysisServerService.getInstance(project)
+ serverService.stopServer()
+ }
+ val dartServerCacheDirectory = getDartServerCacheDirectory()
+ if (dartServerCacheDirectory != null && dartServerCacheDirectory.exists()) {
+ dartServerCacheDirectory.deleteRecursively()
+ }
+ }
+
+ private fun getDartServerCacheDirectory(): File? {
+ return if (SystemInfoRt.isWindows) {
+ val appData = System.getenv("LOCALAPPDATA")
+ if (appData != null) File(appData, ".dartServer") else null
+ } else {
+ val userHome = System.getProperty("user.home")
+ if (userHome != null) File(userHome, ".dartServer") else null
+ }
+ }
+}
diff --git a/third_party/src/main/resources/META-INF/plugin.xml b/third_party/src/main/resources/META-INF/plugin.xml
index 9f12bf062..a787be7fa 100644
--- a/third_party/src/main/resources/META-INF/plugin.xml
+++ b/third_party/src/main/resources/META-INF/plugin.xml
@@ -206,6 +206,7 @@
com.jetbrains.lang.dart.assists.DartQuickAssistIntention$DartQuickAssistIntention14 messages.DartBundle inspections.group.name DartQuickAssistIntention
+
diff --git a/third_party/src/main/resources/messages/DartBundle.properties b/third_party/src/main/resources/messages/DartBundle.properties
index f7284cbd1..0c1fe1212 100644
--- a/third_party/src/main/resources/messages/DartBundle.properties
+++ b/third_party/src/main/resources/messages/DartBundle.properties
@@ -266,6 +266,8 @@ analysis.server.snapshot.file.does.not.exist.at.0=the Dart Analysis Server snaps
dart.vm.file.is.not.executable.at.0=the Dart VM file is not executable at location: {0}
analysis.server.snapshot.file.is.not.readable.at.0=the Dart Analysis Server snapshot file is not readable at location: {0}
issue.occurred.with.analysis.server=an issue occurred with the analysis server
+analysis.server.cache.invalidate.description=Delete the local Dart analysis server cache directory
+analysis.server.cache.invalidate.comment=Recursively deletes .dartServer/ from the local disk
action.Dart.DartSortMembers.text=Sort Members in Dart File
action.Dart.DartSortMembers.description=Sort members in your Dart code