Skip to content

Commit a8ac29d

Browse files
committed
feat(knowledge): add support for additional HTTP methods
Extend `API_METHODS` to include HEAD, OPTIONS, and TRACE. Improve documentation for `KnowledgeFunctionProvider` with detailed usage examples and analysis modes.
1 parent 061729c commit a8ac29d

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

core/src/main/kotlin/cc/unitmesh/devti/bridge/knowledge/KnowledgeFunctionProvider.kt

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,41 @@ import com.intellij.openapi.project.Project
1212
import com.intellij.psi.PsiElement
1313
import com.intellij.psi.PsiManager
1414

15-
val API_METHODS: List<String> = listOf("GET", "POST", "PUT", "DELETE", "PATCH")
15+
val API_METHODS: List<String> = listOf("GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE")
1616

1717
/**
18-
* ```devin
19-
* 从 API 调用链来进行分析
20-
* /knowledge:GET#/api/blog
21-
* 从 Controller 到 Repository 的调用链
22-
* /knowledge:BlogController#getBlogBySlug
18+
* The `KnowledgeFunctionProvider` class is a specialized toolchain function provider designed to analyze API call chains and code structure relationships within a project.
19+
* It supports two primary modes of analysis:
20+
*
21+
* 1. **API Endpoint Analysis**: This mode tracks the call chain by HTTP method and path, allowing for the identification of how API endpoints are processed through the system.
22+
* 2. **Code Structure Analysis**: This mode tracks relationships between classes and methods, enabling the exploration of how different parts of the codebase interact.
23+
*
24+
* The class is particularly useful for understanding the flow of data and control within a project, especially in scenarios where API calls traverse multiple layers of the application, such as from a Controller to a Repository.
25+
*
26+
* ### Usage Examples:
27+
* - **API Endpoint Analysis**: `/knowledge:GET#/api/blog`
28+
* This example traces the call chain for a GET request to the `/api/blog` endpoint.
29+
* - **Code Structure Analysis**: `/knowledge:BlogController#getBlogBySlug`
30+
* This example traces the call chain from the `getBlogBySlug` method in the `BlogController` class.
31+
*
32+
* ### Example Output:
33+
* The output of the `execute` method is a string that includes the related code snippets, their paths, and the language of the code. For example:
2334
* ```
35+
* Here is /knowledge:GET#/api/blog related code: ```Kotlin
36+
* // src/main/kotlin/com/example/BlogController.kt
37+
* @GetMapping("/api/blog")
38+
* fun getBlogBySlug(@PathVariable slug: String): Blog {
39+
* return blogService.getBlogBySlug(slug)
40+
* }
41+
* ```
42+
*
2443
*/
2544
class KnowledgeFunctionProvider : ToolchainFunctionProvider {
2645
override fun funcNames(): List<String> = listOf(KnowledgeTransfer.Knowledge.name)
2746

2847
override fun isApplicable(project: Project, funcName: String): Boolean =
2948
funcName == KnowledgeTransfer.Knowledge.name
3049

31-
32-
/**
33-
* 1. try use KnowledgeWebApiProvider
34-
*
35-
* 2. try use RipGrep Search by APIs
36-
*
37-
*/
3850
override fun execute(
3951
project: Project,
4052
prop: String,

0 commit comments

Comments
 (0)