Use companion objects to store constants
authorVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Tue, 19 Dec 2017 08:50:17 +0000 (11:50 +0300)
committerVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Tue, 19 Dec 2017 08:50:17 +0000 (11:50 +0300)
plugins/stats-collector/src/com/intellij/stats/completion/LookupActionsListener.kt
plugins/stats-collector/src/com/intellij/stats/logger/LogFileManager.kt
plugins/stats-collector/src/com/intellij/stats/network/service/SimpleRequestService.kt
plugins/stats-collector/src/com/intellij/stats/sender/SenderComponent.kt
plugins/stats-collector/src/com/intellij/stats/storage/UniqueFilesProvider.kt

index dc68f05803db13ecd8583a70c2e9f6b68e9b10a2..e6df104eca9b80f670c218b9eca8f98e9d60ac13 100644 (file)
@@ -22,7 +22,10 @@ import com.intellij.openapi.diagnostic.ControlFlowException
 import com.intellij.openapi.diagnostic.Logger
 
 class LookupActionsListener : AnActionListener.Adapter() {
-    private val LOG = Logger.getInstance(LookupActionsListener::class.java)
+    private companion object {
+        val LOG = Logger.getInstance(LookupActionsListener::class.java)
+    }
+
     private val down = ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN)
     private val up = ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_MOVE_CARET_UP)
     private val backspace = ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_BACKSPACE)
index af1bded45764725a1a12e1a1b30e3a1af12a5a75..222f82c059733ee02bb6ee4b45f157004979eed3 100644 (file)
@@ -20,8 +20,10 @@ import com.intellij.stats.storage.FilePathProvider
 import java.io.File
 
 class LogFileManager(private val filePathProvider: FilePathProvider) {
+    private companion object {
+        val MAX_SIZE_BYTE = 250 * 1024
+    }
 
-    private val MAX_SIZE_BYTE = 250 * 1024
     private val storage = LineStorage()
 
     fun println(message: String) {
index eba4e8368f495b905949b87b8ed85af993ce8f3c..0907941eb8a0090a36c52b9a25524949c5302ef2 100644 (file)
@@ -31,7 +31,9 @@ import java.io.IOException
 import java.util.zip.GZIPOutputStream
 
 class SimpleRequestService: RequestService() {
-    private val LOG = logger<SimpleRequestService>()
+    private companion object {
+        val LOG = logger<SimpleRequestService>()
+    }
 
     override fun post(url: String, params: Map<String, String>): ResponseData? {
         val form = Form.form()
index 0de6e9db7ef3cf4a21f254edae48989f06766114..00ee3b2057a33a8afacc426e07f3ae759352f6e5 100644 (file)
@@ -28,8 +28,10 @@ class SenderComponent(
         private val sender: StatisticSender,
         private val statusHelper: WebServiceStatus
 ) : ApplicationComponent {
+    private companion object {
+        val LOG = logger<SenderComponent>()
+    }
 
-    private val LOG = logger<SenderComponent>()
     private val disposable = Disposer.newDisposable()
     private val alarm = Alarm(Alarm.ThreadToUse.POOLED_THREAD, disposable)
     private val sendInterval = 5 * Time.MINUTE
index 16ca4dc38483aede98ef40a48834056e1c2d6b43..958d506f43ca8356361804b7c02242e6c6d4b998 100644 (file)
@@ -31,8 +31,9 @@ import java.nio.file.Files
 open class UniqueFilesProvider(private val baseFileName: String,
                                private val rootDirectoryPath: String,
                                private val logsDirectoryName: String) : FilePathProvider() {
-
-    private val MAX_ALLOWED_SEND_SIZE = 2 * 1024 * 1024
+    private companion object {
+        val MAX_ALLOWED_SEND_SIZE = 2 * 1024 * 1024
+    }
 
     override fun cleanupOldFiles() {
         val files = getDataFiles()