File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
src/main/kotlin/org/domaframework/doma/intellij/common Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -46,14 +46,6 @@ fun isJavaOrKotlinFileType(daoFile: PsiFile): Boolean {
4646 }
4747}
4848
49- fun isJavaOrKotlinFileType (file : VirtualFile ): Boolean {
50- val fileType = file.fileType
51- return when (fileType.name) {
52- " JAVA" , " Kotlin" , " CLASS" -> true
53- else -> false
54- }
55- }
56-
5749/*
5850 * Determine whether the open file is an SQL template file extension
5951 */
@@ -92,9 +84,18 @@ fun searchDaoFile(
9284 return null
9385 }
9486
95- val subProject =
96- originFilePath.substring(projectRootPath.length, originFilePath.indexOf(SRC_MAIN_PATH ))
97- return contentRoot
98- .findFileByRelativePath(subProject)
99- ?.findFileByRelativePath(relativeDaoFilePath)
87+ // TODO Dynamically build the source directory path and retrieve subproject info
88+ // by inspecting file metadata instead of using string manipulation.
89+ val index = originFilePath.indexOf(SRC_MAIN_PATH )
90+ val projectRootPathBefore = projectRootPath.substringBefore(SRC_MAIN_PATH )
91+ if (index < 0 || projectRootPathBefore.length < index) return null
92+ val subProjectName =
93+ originFilePath.substring(projectRootPathBefore.length, index)
94+
95+ val daoFile =
96+ contentRoot
97+ .findFileByRelativePath(subProjectName)
98+ ?.findFileByRelativePath(relativeDaoFilePath)
99+
100+ return daoFile
100101}
You can’t perform that action at this time.
0 commit comments