@@ -40,6 +40,7 @@ import org.domaframework.doma.intellij.extension.getContentRoot
4040import org.domaframework.doma.intellij.extension.getJavaClazz
4141import org.domaframework.doma.intellij.extension.getModule
4242import org.jetbrains.kotlin.idea.base.util.module
43+ import java.nio.file.Paths
4344
4445/* *
4546 * Get DAO method corresponding to SQL file
@@ -147,7 +148,7 @@ private fun searchDaoFile(
147148 val pathParams = module?.let { CommonPathParameterUtil .getModulePaths(it) } ? : return null
148149 val moduleBaseName =
149150 pathParams.moduleBasePaths
150- .find { baseName -> contentRootPath.contains( baseName.path) }
151+ .find { baseName -> Paths .get( contentRootPath).startsWith( Paths .get( baseName.path) ) }
151152 ?.nameWithoutExtension ? : " "
152153 // TODO: Add Support Kotlin
153154 val relativeDaoFilePaths =
@@ -218,19 +219,20 @@ fun getRelativeSqlFilePathFromDaoFilePath(
218219): String {
219220 if (module == null ) return " "
220221 val extension = daoFile.fileType.defaultExtension
222+ val daoFilePath = daoFile.path
221223 val pathParams = CommonPathParameterUtil .getModulePaths(module)
222224 val containsModuleBaseName =
223225 pathParams.moduleBasePaths
224- .find { basePath -> daoFile.path .contains(" ${basePath.path} /" ) }
226+ .find { basePath -> daoFilePath .contains(" ${basePath.path} /" ) }
225227 ?.path ? : return " "
226228 var relativeSqlFilePath =
227- daoFile.path
229+ daoFilePath
228230 .replaceFirst(containsModuleBaseName, " " )
229231 .replace(" .$extension " , " " )
230232 val sources = CommonPathParameterUtil .getSources(module, daoFile)
231233 sources
232234 .find {
233- daoFile.path
235+ daoFilePath
234236 .startsWith(containsModuleBaseName.plus(" /${it.nameWithoutExtension} /" ))
235237 }?.let { source ->
236238 val startSourceName = " /${source.nameWithoutExtension} "
0 commit comments