Skip to content

Commit 6b07457

Browse files
committed
fix(web-api): format web API endpoints output with code block
- Wrap web API endpoints output in a code block for better readability. - Add timeout to future.get() in DependenciesFunctionProvider. - Use runReadAction for thread-safe file search in ProjectFileUtil. - Remove unused HorizontalLayout import in DiffLangSketch.
1 parent f7646f0 commit 6b07457

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/patch/DiffLangSketch.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import com.intellij.openapi.vcs.changes.patch.MatchPatchPaths
2424
import com.intellij.openapi.vfs.VirtualFile
2525
import com.intellij.psi.PsiDocumentManager
2626
import com.intellij.testFramework.LightVirtualFile
27-
import com.intellij.ui.components.panels.HorizontalLayout
2827
import com.intellij.ui.components.panels.VerticalLayout
2928
import com.intellij.util.containers.MultiMap
3029
import com.intellij.util.ui.JBUI

core/src/main/kotlin/cc/unitmesh/devti/util/ProjectFileUtil.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package cc.unitmesh.devti.util
33

44
import com.intellij.openapi.application.ApplicationManager
5+
import com.intellij.openapi.application.runReadAction
56
import com.intellij.openapi.fileTypes.FileTypeManager
67
import com.intellij.openapi.progress.ProgressManager
78
import com.intellij.openapi.progress.Task
@@ -35,7 +36,9 @@ fun Project.findFile(filename: String): VirtualFile? {
3536

3637
val task = object : Task.Backgroundable(this, "Searching for file", false) {
3738
override fun run(indicator: com.intellij.openapi.progress.ProgressIndicator) {
38-
val file = FilenameIndex.getVirtualFilesByName(filename, ProjectScope.getProjectScope(this@findFile)).firstOrNull()
39+
val file = runReadAction {
40+
FilenameIndex.getVirtualFilesByName(filename, ProjectScope.getProjectScope(this@findFile)).firstOrNull()
41+
}
3942
future.complete(file)
4043
}
4144
}

exts/ext-dependencies/src/233/main/kotlin/cc/unitmesh/dependencies/DependenciesFunctionProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ class DependenciesFunctionProvider : ToolchainFunctionProvider {
5050
ProgressManager.getInstance()
5151
.runProcessWithProgressAsynchronously(task, BackgroundableProcessIndicator(task))
5252

53-
return future.get()
53+
return future.get(30, java.util.concurrent.TimeUnit.SECONDS)
5454
}
5555
}

exts/ext-endpoints/src/233/main/kotlin/cc/unitmesh/endpoints/bridge/WebApiViewFunctionProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ class WebApiViewFunctionProvider : ToolchainFunctionProvider {
3434

3535
val map = collectUrls(project, endpointsProviderList)
3636
val result =
37-
"""Here is current project web api endpoints, ${map.size}:""" + map.joinToString("\n") { url ->
37+
"""Here is current project web ${map.size} api endpoints: ```\n""" + map.joinToString("\n") { url ->
3838
url.method.joinToString("\n") {
3939
"$it - ${url.urlPath.toStringWithStars()}" + " (${
4040
UrlMappingElement.getContainingFileName(
4141
url
4242
)
4343
})"
44-
}
44+
} + "\n```"
4545
}
4646

4747
future.complete(result)

0 commit comments

Comments
 (0)