make ExternalStorageConfigurationManager an interface
authorLeonid Shalupov <leonid@shalupov.com>
Mon, 10 Sep 2018 10:41:42 +0000 (13:41 +0300)
committerLeonid Shalupov <leonid@shalupov.com>
Tue, 2 Oct 2018 08:48:03 +0000 (11:48 +0300)
IDEA-CR-37150
IDEA-199211 Refactor code dependent on project model implementation

platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml
platform/projectModel-api/src/com/intellij/openapi/project/ExternalStorageConfigurationManager.java [new file with mode: 0644]
platform/projectModel-api/src/com/intellij/openapi/project/ExternalStorageConfigurationManagerImpl.kt [moved from platform/projectModel-api/src/com/intellij/openapi/project/ExternalStorageConfigurationManager.kt with 73% similarity]

index c792fb3b018a18507df7354f8a9b29f4ebe01cb2..2f6eadde7a058792b6e4f33b869a6c582e0a10ad 100644 (file)
@@ -27,7 +27,8 @@
     <projectService serviceInterface="com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager"
                     serviceImplementation="com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl"
                     order="first"/>
-    <projectService serviceImplementation="com.intellij.openapi.project.ExternalStorageConfigurationManager"/>
+    <projectService serviceInterface="com.intellij.openapi.project.ExternalStorageConfigurationManager"
+                    serviceImplementation="com.intellij.openapi.project.ExternalStorageConfigurationManagerImpl"/>
     <projectService serviceImplementation="com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsDataStorage"/>
     <projectService serviceImplementation="com.intellij.openapi.externalSystem.service.project.ExternalProjectsWorkspaceImpl"/>
     <externalProjectDataService implementation="com.intellij.openapi.externalSystem.service.project.manage.ProjectDataServiceImpl"/>
diff --git a/platform/projectModel-api/src/com/intellij/openapi/project/ExternalStorageConfigurationManager.java b/platform/projectModel-api/src/com/intellij/openapi/project/ExternalStorageConfigurationManager.java
new file mode 100644 (file)
index 0000000..866ccdb
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package com.intellij.openapi.project;
+
+import com.intellij.openapi.components.ServiceManager;
+
+public interface ExternalStorageConfigurationManager {
+  static ExternalStorageConfigurationManager getInstance(Project project) {
+    return ServiceManager.getService(project, ExternalStorageConfigurationManager.class);
+  }
+
+  boolean isEnabled();
+  void setEnabled(boolean value);
+}
similarity index 73%
rename from platform/projectModel-api/src/com/intellij/openapi/project/ExternalStorageConfigurationManager.kt
rename to platform/projectModel-api/src/com/intellij/openapi/project/ExternalStorageConfigurationManagerImpl.kt
index e2e0e816b3899b5437bf1e2cf79d32c82ed12aa5..44fe9ea253d0859143cc6ce95f7f40fe242afee4 100644 (file)
@@ -14,12 +14,7 @@ class ExternalStorageConfiguration : BaseState() {
 }
 
 @State(name = "ExternalStorageConfigurationManager")
-class ExternalStorageConfigurationManager : PersistentStateComponent<ExternalStorageConfiguration>, ModificationTracker {
-  companion object {
-    @JvmStatic
-    fun getInstance(project: Project): ExternalStorageConfigurationManager = ServiceManager.getService(project, ExternalStorageConfigurationManager::class.java)
-  }
-
+class ExternalStorageConfigurationManagerImpl : PersistentStateComponent<ExternalStorageConfiguration>, ModificationTracker, ExternalStorageConfigurationManager {
   private var state = ExternalStorageConfiguration()
 
   override fun getModificationCount(): Long = state.modificationCount
@@ -32,12 +27,12 @@ class ExternalStorageConfigurationManager : PersistentStateComponent<ExternalSto
     this.state = state
   }
 
-  fun isEnabled(): Boolean = state.enabled
+  override fun isEnabled(): Boolean = state.enabled
 
   /**
    * Internal use only. Call ExternalProjectsManagerImpl.setStoreExternally instead.
    */
-  fun setEnabled(value: Boolean) {
+  override fun setEnabled(value: Boolean) {
     state.enabled = value
   }
 }
\ No newline at end of file