Skip to content

Commit

Permalink
feat(core): add CodeStructVariableProvider for code struct generation #…
Browse files Browse the repository at this point in the history
…14

- Added CodeStructVariableProvider interface to resolve variables needed for code struct generation.
- Updated auto-test.md to use targetTestFileName instead of targetClassName.
  • Loading branch information
phodal committed Jun 14, 2024
1 parent e554169 commit 9a6c573
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.phodal.shirecore.provider

import com.intellij.lang.Language
import com.intellij.lang.LanguageExtension

/**
* Resolve variables for code struct generation.
* This is used to provide the variables that are used in the code struct generation.
*
* - currentClass
* - relatedClasses
* - similarTestCase
* - imports
* - isNewFile
* - targetTestFileName
*/
interface CodeStructVariableProvider {
companion object {
private val languageExtension: LanguageExtension<CodeStructVariableProvider> =
LanguageExtension("com.phodal.shireCodeStructVariableProvider")

fun provide(language: Language): CodeStructVariableProvider? {
return languageExtension.forLanguage(language)
}
}
}
7 changes: 7 additions & 0 deletions core/src/main/resources/com.phodal.shirecore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
implements="com.phodal.shirecore.provider.ToolchainProvider"/>
</extensionPoint>

<!-- Toolchain Provider -->
<extensionPoint qualifiedName="com.phodal.shireCodeStructVariableProvider"
beanClass="com.intellij.lang.LanguageExtensionPoint" dynamic="true">
<with attribute="implementationClass"
implements="com.phodal.shirecore.provider.CodeStructVariableProvider"/>
</extensionPoint>

<!-- Code Editor -->
<extensionPoint qualifiedName="com.phodal.shireCodeModifier"
beanClass="com.intellij.lang.LanguageExtensionPoint" dynamic="true">
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/auto-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ nav_order: 1
#if($context.isNewFile)
Should include package and imports. Start method test code with Markdown code block here:
#else
Should include package and imports. Start ${context.targetClassName} test code with Markdown code block here:
Should include package and imports. Start ${context.targetTestFileName} test code with Markdown code block here:
#end

0 comments on commit 9a6c573

Please sign in to comment.