generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
companion/src/main/kotlin/cc/unitmesh/comp/actions/TalkWithApiAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cc.unitmesh.comp.actions | ||
|
||
import cc.unitmesh.devti.AutoDevBundle | ||
import cc.unitmesh.devti.intentions.AbstractChatIntention | ||
import com.intellij.ide.highlighter.JavaFileType | ||
import com.intellij.openapi.editor.Editor | ||
import com.intellij.openapi.progress.ProgressIndicator | ||
import com.intellij.openapi.progress.ProgressManager | ||
import com.intellij.openapi.progress.Task | ||
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiFile | ||
import com.intellij.psi.PsiManager | ||
import com.intellij.psi.search.FileTypeIndex | ||
import com.intellij.psi.search.GlobalSearchScope | ||
|
||
class TalkWithApiAction : AbstractChatIntention() { | ||
override fun getText(): String = AutoDevBundle.message("intentions.companion.api.name") | ||
override fun getFamilyName(): String = AutoDevBundle.message("intentions.companion.api.family.name") | ||
|
||
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) { | ||
val task: Task.Backgroundable = object : Task.Backgroundable(project, "Collect context") { | ||
override fun run(indicator: ProgressIndicator) { | ||
// search all Controller file from project stub | ||
val psiManager = PsiManager.getInstance(project) | ||
val virtualFiles = FileTypeIndex.getFiles(JavaFileType.INSTANCE, GlobalSearchScope.projectScope(project)) | ||
val psiFiles = virtualFiles.mapNotNull { psiManager.findFile(it) } | ||
val controllerFiles = psiFiles.filter { it.name.endsWith("Controller.java") } | ||
|
||
// todo: convert by chapi | ||
} | ||
} | ||
|
||
ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, BackgroundableProcessIndicator(task)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters