Skip to content

Commit 45fcf80

Browse files
committed
feat(assessment): add SccFunctionProvider for SCC command #308
Introduce a new `SccFunctionProvider` class to handle the SCC assessment command. The provider checks applicability and executes the SCC command, returning the result. Also, register the provider in the `autodev-core.xml` configuration files.
1 parent d76195a commit 45fcf80

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@
254254
<langSketchProvider implementation="cc.unitmesh.devti.sketch.ui.patch.DiffLangSketchProvider"/>
255255
<langSketchProvider implementation="cc.unitmesh.devti.sketch.ui.webview.WebpageSketchProvider"/>
256256
<langSketchProvider implementation="cc.unitmesh.devti.sketch.ui.openapi.OpenAPISketchProvider"/>
257+
258+
<toolchainFunctionProvider implementation="cc.unitmesh.devti.bridge.archview.ComponentViewFunctionProvider"/>
259+
<toolchainFunctionProvider implementation="cc.unitmesh.devti.bridge.archview.ContainerViewFunctionProvider"/>
260+
<toolchainFunctionProvider implementation="cc.unitmesh.devti.bridge.assessment.SccFunctionProvider"/>
257261
</extensions>
258262

259263
<actions>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@
257257

258258
<toolchainFunctionProvider implementation="cc.unitmesh.devti.bridge.archview.ComponentViewFunctionProvider"/>
259259
<toolchainFunctionProvider implementation="cc.unitmesh.devti.bridge.archview.ContainerViewFunctionProvider"/>
260+
<toolchainFunctionProvider implementation="cc.unitmesh.devti.bridge.assessment.SccFunctionProvider"/>
260261
</extensions>
261262

262263
<actions>

core/src/main/kotlin/cc/unitmesh/devti/bridge/BridgeCommandProvider.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ sealed interface BridgeCommandProvider {
2828
*/
2929
sealed class Assessment(override val name: String) : BridgeCommandProvider {
3030
object SCC : Assessment("scc")
31+
32+
/**
33+
* Use [cc.unitmesh.dependencies.DependenciesFunctionProvider]
34+
*/
3135
object Dependencies : Assessment("dependencies")
3236
}
3337

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package cc.unitmesh.devti.bridge.assessment
2+
3+
import cc.unitmesh.devti.bridge.Assessment
4+
import cc.unitmesh.devti.bridge.command.SccWrapper
5+
import cc.unitmesh.devti.provider.toolchain.ToolchainFunctionProvider
6+
import com.intellij.openapi.project.Project
7+
import com.intellij.openapi.project.guessProjectDir
8+
9+
class SccFunctionProvider : ToolchainFunctionProvider {
10+
override fun isApplicable(project: Project, funcName: String): Boolean = funcName == Assessment.SCC.name
11+
12+
override fun execute(
13+
project: Project,
14+
funcName: String,
15+
args: List<Any>,
16+
allVariables: Map<String, Any?>
17+
): Any {
18+
val path = if (args.isEmpty()) project.guessProjectDir()!!.path else args[0].toString()
19+
return SccWrapper().runSccSync(path)
20+
}
21+
}

0 commit comments

Comments
 (0)