Skip to content

Commit 7e2faf1

Browse files
committed
feat(core): add framework configuration provider for Spring #338
- Introduce new extension point for framework config providers - Implement SpringFrameworkConfigProvider to collect Spring config files - Update plugin configuration to include new framework config provider
1 parent 39e24f5 commit 7e2faf1

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

core/src/223/main/resources/META-INF/autodev-core.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@
203203
dynamic="true">
204204
</extensionPoint>
205205

206+
<extensionPoint qualifiedName="cc.unitmesh.frameworkConfigProvider"
207+
interface="cc.unitmesh.devti.provider.FrameworkConfigProvider"
208+
dynamic="true">
209+
</extensionPoint>
210+
206211
<!-- Bridge -->
207212
<extensionPoint qualifiedName="cc.unitmesh.componentProvider"
208213
interface="cc.unitmesh.devti.bridge.provider.ComponentViewProvider"

core/src/233/main/resources/META-INF/autodev-core.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@
205205
dynamic="true">
206206
</extensionPoint>
207207

208+
<extensionPoint qualifiedName="cc.unitmesh.frameworkConfigProvider"
209+
interface="cc.unitmesh.devti.provider.FrameworkConfigProvider"
210+
dynamic="true">
211+
</extensionPoint>
212+
208213
<!-- Bridge -->
209214
<extensionPoint qualifiedName="cc.unitmesh.componentProvider"
210215
interface="cc.unitmesh.devti.bridge.provider.ComponentViewProvider"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cc.unitmesh.devti.provider
2+
3+
import com.intellij.openapi.extensions.ExtensionPointName
4+
import com.intellij.openapi.project.Project
5+
import com.intellij.openapi.vfs.VirtualFile
6+
7+
interface FrameworkConfigProvider {
8+
suspend fun collect(project: Project): List<VirtualFile>
9+
10+
companion object {
11+
private val EP_NAME: ExtensionPointName<FrameworkConfigProvider> =
12+
ExtensionPointName("cc.unitmesh.frameworkConfigProvider")
13+
14+
suspend fun collectAll(project: Project): List<VirtualFile> {
15+
return EP_NAME.extensionList.flatMap { it.collect(project) }
16+
}
17+
}
18+
19+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package cc.unitmesh.idea.provider
2+
3+
import cc.unitmesh.devti.provider.FrameworkConfigProvider
4+
import com.intellij.openapi.module.ModuleManager
5+
import com.intellij.openapi.project.Project
6+
import com.intellij.openapi.vfs.VirtualFile
7+
import com.intellij.psi.search.FilenameIndex
8+
import com.intellij.psi.search.GlobalSearchScope
9+
10+
class SpringFrameworkConfigProvider : FrameworkConfigProvider {
11+
private val files: Array<String> = arrayOf<String>(
12+
SpringBootConfigFileConstants.APPLICATION_PROPERTIES,
13+
SpringBootConfigFileConstants.BOOTSTRAP_PROPERTIES,
14+
SpringBootConfigFileConstants.ADDITIONAL_SPRING_CONFIGURATION_METADATA_JSON,
15+
SpringBootConfigFileConstants.APPLICATION_YML,
16+
"application.yaml",
17+
"devtools.properties",
18+
"devtools.yml",
19+
"devtools.yaml"
20+
)
21+
22+
override suspend fun collect(project: Project): List<VirtualFile> {
23+
val modules = ModuleManager.getInstance(project).modules
24+
return modules.map { module ->
25+
val scope: GlobalSearchScope = module.getModuleScope(false)
26+
files.map { file ->
27+
FilenameIndex.getVirtualFilesByName(file, scope)
28+
}.flatten()
29+
}.flatten()
30+
}
31+
}
32+
33+
object SpringBootConfigFileConstants {
34+
const val APPLICATION: String = "application"
35+
const val APPLICATION_PROPERTIES: String = "application.properties"
36+
const val APPLICATION_YML: String = "application.yml"
37+
const val BOOTSTRAP: String = "bootstrap"
38+
const val BOOTSTRAP_PROPERTIES: String = "bootstrap.properties"
39+
const val SPRING_CONFIGURATION_METADATA_JSON: String = "spring-configuration-metadata.json"
40+
const val ADDITIONAL_SPRING_CONFIGURATION_METADATA_JSON: String = "additional-spring-configuration-metadata.json"
41+
}

java/src/main/resources/cc.unitmesh.idea.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@
5959

6060
<runProjectService implementation="cc.unitmesh.idea.provider.JvmRunProjectService"/>
6161
<!-- <agentObserver implementation="cc.unitmesh.idea.observer.GradleTaskAgentObserver" />-->
62+
63+
<frameworkConfigProvider implementation="cc.unitmesh.idea.provider.SpringFrameworkConfigProvider"/>
6264
</extensions>
6365
</idea-plugin>

0 commit comments

Comments
 (0)