-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Copy link
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Currently, the source and resource directory names are hardcoded as /src/main and /resources. Because some projects may use different directory structures, use ModuleRootManager to dynamically obtain the correct directory names based on the project’s configuration.
ex)
val module = sqlFile.module
val moduleName = module?.name?.substringAfter(project.name.plus("."))?.split(".")?.first() ?: ""
val modulemanager = module?.let { ModuleRootManager.getInstance(module)}
val subStringPath = module?.name?.plus(project.basePath?:"") ?:""
modulemanager?.contentEntries?.firstOrNull()?.let { entry ->
entry.sourceFolders.map { folder ->
val file = folder.file
val pathName = file?.path?.substringAfter(subStringPath) ?: ""
val sourceFileName = pathName.substringAfter("${project.basePath ?: ""}/")
.substringBefore("/${file?.name ?: ""}")
}
entry.file?.path?.substringAfter(moduleName)
}This code snippet extracts the /src/main segment that sits between the module name and each source-directory path. Inside the map { } block, the variable file represents each individual source directory.
entry.file?.path?.substringAfter(moduleName)Sub-issues
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request