generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add custom AI engine setting for inlay code complete
- Loading branch information
Jia Liu
committed
Mar 21, 2024
1 parent
268f309
commit 7de0431
Showing
8 changed files
with
175 additions
and
4 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
...main/kotlin/cc/unitmesh/devti/custom/schema/InlayCodeCompletePromptsSchemaFileProvider.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,39 @@ | ||
package cc.unitmesh.devti.custom.schema | ||
|
||
import com.intellij.openapi.application.runReadAction | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vfs.VirtualFile | ||
import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider | ||
import com.jetbrains.jsonSchema.extension.JsonSchemaProviderFactory | ||
import com.jetbrains.jsonSchema.extension.SchemaType | ||
|
||
const val INLAY_PROMPTS_FILE_NAME = "AutoDevInlayCodeCompletePromptFile.json" | ||
|
||
//todo: refactor provider to reduce duplicate code | ||
class InlayCodeCompletePromptsSchemaFileProvider(project: Project) : JsonSchemaFileProvider { | ||
override fun isAvailable(file: VirtualFile): Boolean { | ||
return runReadAction { isMyFile(file) } | ||
} | ||
|
||
private fun isMyFile(file: VirtualFile): Boolean { | ||
if (!file.isValid) { | ||
return false | ||
} | ||
|
||
return file.name == INLAY_PROMPTS_FILE_NAME | ||
} | ||
|
||
override fun getName(): String = "AutoDevInlayCodeCompletePromptFile" | ||
|
||
override fun getSchemaFile(): VirtualFile? { | ||
return JsonSchemaProviderFactory.getResourceFile(this::class.java, inlayPromptsSchemaFile) | ||
} | ||
|
||
override fun getSchemaType(): SchemaType { | ||
return SchemaType.schema | ||
} | ||
|
||
companion object { | ||
private const val inlayPromptsSchemaFile = "auto-dev-inlay-code-complete-prompt-file.json" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/cc/unitmesh/devti/custom/schema/InlayCodePromptsJsonSchemaProviderFactory.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,11 @@ | ||
package cc.unitmesh.devti.custom.schema | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider | ||
import com.jetbrains.jsonSchema.extension.JsonSchemaProviderFactory | ||
|
||
class InlayCodePromptsJsonSchemaProviderFactory: JsonSchemaProviderFactory { | ||
override fun getProviders(project: Project): MutableList<JsonSchemaFileProvider> { | ||
return mutableListOf(InlayCodeCompletePromptsSchemaFileProvider(project)) | ||
} | ||
} |
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
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