@@ -2,10 +2,9 @@ package com.github.xepozz.mago.qualityTool
22
33import com.github.xepozz.mago.configuration.MagoProjectConfiguration
44import com.github.xepozz.mago.normalizePath
5+ import com.github.xepozz.mago.utils.DebugLogger
56import com.intellij.codeInspection.InspectionProfile
67import com.intellij.execution.configurations.ParametersList
7- import com.intellij.notification.NotificationGroupManager
8- import com.intellij.notification.NotificationType
98import com.intellij.openapi.diagnostic.Logger
109import com.intellij.openapi.module.ModuleUtilCore
1110import com.intellij.openapi.project.Project
@@ -17,7 +16,6 @@ import com.intellij.psi.PsiFile
1716import com.jetbrains.php.tools.quality.QualityToolAnnotator
1817import com.jetbrains.php.tools.quality.QualityToolAnnotatorInfo
1918import com.jetbrains.php.tools.quality.QualityToolConfiguration
20- import java.io.File
2119
2220open class MagoAnnotatorProxy : QualityToolAnnotator <MagoValidationInspection >() {
2321 companion object {
@@ -35,12 +33,13 @@ open class MagoAnnotatorProxy : QualityToolAnnotator<MagoValidationInspection>()
3533 addAll(files.map { toWorkspaceRelativePath(workspace, it) })
3634 }
3735 .plus(ParametersList .parse(settings.formatAdditionalParameters))
38- .apply { val options = this .joinToString(" " )
39- println (" format options: $options " )
40- NotificationGroupManager .getInstance()
41- .getNotificationGroup(" Mago" )
42- .createNotification(" Format options" , """ Options: $options , filePaths: ${files.joinToString(" , " ) { it }} """ , NotificationType .INFORMATION )
43- .notify(project)
36+ .apply {
37+ DebugLogger .inform(
38+ project,
39+ " Format options" ,
40+ """ Options: ${joinToString(" " )} , filePaths: ${files.joinToString(" , " ) { it }} """ ,
41+ )
42+
4443 }
4544
4645 fun findWorkspace (project : Project , filePath : String? ): VirtualFile {
@@ -62,44 +61,34 @@ open class MagoAnnotatorProxy : QualityToolAnnotator<MagoValidationInspection>()
6261 }
6362 .plus(ParametersList .parse(settings.analyzeAdditionalParameters))
6463 .apply {
65- val options = this .joinToString(" " )
66- println (" analyze options: $options " )
67- NotificationGroupManager .getInstance()
68- .getNotificationGroup(" Mago" )
69- .createNotification(" Analyze options" , """ Options: $options , filePath: $filePath """ , NotificationType .INFORMATION )
70- .notify(project)
64+ DebugLogger .inform(
65+ project,
66+ " Analyze options" ,
67+ """ Options: ${joinToString(" " )} , filePath: $filePath """ ,
68+ )
7169 }
7270
73- private fun toWorkspaceRelativePath (project : Project , absoluteFilePath : String ): String {
74- val basePath = project.basePath ? : return absoluteFilePath
75- return toRelativePath(basePath, absoluteFilePath)
76- }
7771 private fun toWorkspaceRelativePath (workspace : VirtualFile , absoluteFilePath : String ): String {
7872 return toRelativePath(workspace.path, absoluteFilePath)
7973 }
8074
8175 internal fun toRelativePath (basePath : String , absoluteFilePath : String ): String {
8276 val basePath = basePath.normalizePath()
8377 val absoluteFilePath = absoluteFilePath.normalizePath()
84- println (" project base: $basePath " )
8578
8679 val relative = FileUtil .getRelativePath(basePath, absoluteFilePath, ' /' )
8780 return ensureMagoPath(relative ? : absoluteFilePath)
8881 }
8982
90- internal fun ensureMagoPath (path : String ): String {
91- return when {
92- path.isEmpty() -> path
93- FileUtil .isAbsolute(path) || isWindowsAbsolute(path) || path.startsWith(" \\\\ ?\\ " ) -> path
94- path.startsWith(" ./" ) || path.startsWith(" .\\ " ) -> path
95- // Mago ignores relative paths unless they are explicitly prefixed.
96- else -> " .${File .separator}$path "
97- }
83+ internal fun ensureMagoPath (path : String ): String = when {
84+ path.isEmpty() -> path
85+ FileUtil .isAbsolute(path) || isWindowsAbsolute(path) || path.startsWith(' \\ ' ) -> path
86+ path.startsWith(" ./" ) || path.startsWith(" .\\ " ) -> path
87+ // Mago ignores relative paths unless they are explicitly prefixed.
88+ else -> " ./$path "
9889 }
9990
100- private fun isWindowsAbsolute (path : String ): Boolean {
101- return path.length >= 2 && path[0 ].isLetter() && path[1 ] == ' :'
102- }
91+ private fun isWindowsAbsolute (path : String ): Boolean = path.length >= 2 && path[0 ].isLetter() && path[1 ] == ' :'
10392
10493 private fun MutableList<String>.addWorkspace (workspace : VirtualFile , project : Project ) {
10594 val projectPath = updateIfRemoteMappingExists(
@@ -110,7 +99,11 @@ open class MagoAnnotatorProxy : QualityToolAnnotator<MagoValidationInspection>()
11099 add(" --workspace=$projectPath " )
111100 }
112101
113- private fun MutableList<String>.addConfig (workspace : VirtualFile , project : Project , settings : MagoProjectConfiguration ) {
102+ private fun MutableList<String>.addConfig (
103+ workspace : VirtualFile ,
104+ project : Project ,
105+ settings : MagoProjectConfiguration
106+ ) {
114107 val configurationFile = updateIfRemoteMappingExists(
115108 settings.configurationFile,
116109 project,
0 commit comments