13 | * markdown.render.shell=/usr/local/bin/node render.js 14 | * markdown.render.work.dir=/fake_path/yapi-markdown-render 15 | * markdown.render.timeout=3000 16 | *
17 | *
18 | * see https://github.com/easyyapi/yapi-markdown-render
19 | */
20 | @Singleton
21 | class ConfigurableShellFileMarkdownRender : ShellFileMarkdownRender() {
22 |
23 | @Inject
24 | private lateinit var configReader: ConfigReader
25 |
26 | override fun getRenderShell(): String? {
27 | return configReader.first("markdown.render.shell")
28 | }
29 |
30 | override fun getWorkDir(): String? {
31 | return configReader.first("markdown.render.work.dir")
32 | }
33 |
34 | override fun getTimeOut(): Long? {
35 | return configReader.first("markdown.render.timeout")?.toLong()
36 | }
37 | }
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/render/MarkdownRender.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.render
2 |
3 | import com.google.inject.ImplementedBy
4 |
5 | @ImplementedBy(AdaptiveMarkdownRender::class)
6 | interface MarkdownRender {
7 |
8 | fun render(markdown: String): String?
9 |
10 | }
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/GroovyRuleParser.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.rule
2 |
3 | /**
4 | * see @{link org.codehaus.groovy.jsr223.GroovyScriptEngineFactory}
5 | *
6 | */
7 | class GroovyRuleParser : StandardJdkRuleParser() {
8 | override fun scriptType(): String {
9 | return "groovy"
10 | }
11 |
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/JsRuleParser.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.rule
2 |
3 | /**
4 | * see @{link jdk.nashorn.api.scripting.NashornScriptEngineFactory}
5 | *
6 | */
7 | class JsRuleParser : StandardJdkRuleParser() {
8 | override fun scriptType(): String {
9 | return "JavaScript"
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/RuleComputorKit.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.rule
2 |
3 | import com.itangcent.intellij.config.rule.RuleContext
4 | import com.itangcent.intellij.config.rule.RuleParser
5 | import com.itangcent.intellij.jvm.element.ExplicitElement
6 |
7 |
8 | fun RuleParser.contextOf(context: ExplicitElement<*>): RuleContext {
9 | return this.contextOf(context, context.psi())
10 | }
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/UnsupportedScriptException.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.rule
2 |
3 | class UnsupportedScriptException : RuntimeException {
4 |
5 | private val type: String
6 |
7 | constructor(type: String) : super("$type was unsupported") {
8 | this.type = type
9 | }
10 |
11 | fun getType(): String {
12 | return type
13 | }
14 | }
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/DefaultSettingBinder.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.settings
2 |
3 | import com.google.inject.Inject
4 | import com.google.inject.Singleton
5 |
6 | @Singleton
7 | class DefaultSettingBinder : SettingBinder {
8 |
9 | @Inject
10 | private lateinit var xmlSettingBinder: XmlSettingBinder
11 |
12 | private val cachedSettingBinder by lazy {
13 | xmlSettingBinder.lazy()
14 | }
15 |
16 | override fun read(): Settings {
17 | return cachedSettingBinder.read()
18 | }
19 |
20 | override fun save(t: Settings?) {
21 | xmlSettingBinder.save(t)
22 | cachedSettingBinder.save(t)
23 | }
24 |
25 | override fun tryRead(): Settings? {
26 | return cachedSettingBinder.tryRead()
27 | }
28 | }
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/HttpClientType.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.settings
2 |
3 | /**
4 | * @author tangcent
5 | * @date 2024/04/28
6 | */
7 | enum class HttpClientType(
8 | val value: String
9 | ) {
10 | APACHE("Apache"),
11 | OKHTTP("Okhttp");
12 | }
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/MarkdownFormatType.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.settings
2 |
3 | enum class MarkdownFormatType(var desc: String) {
4 | SIMPLE("simple columns, include name、type、desc"),
5 | ULTIMATE("more columns than simple, include name、type、required、default、desc")
6 | }
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/PostmanExportMode.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.settings
2 |
3 |
4 | /**
5 | * Used to indicate whether to create new collection or update existed collection when
6 | * export api to postman.
7 | *
8 | * @author tangcent
9 | */
10 | enum class PostmanExportMode(var desc: String) {
11 | COPY("always create new collection"),
12 | UPDATE("try update existed collection")
13 | }
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/PostmanJson5FormatType.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.settings
2 |
3 | /**
4 | * types:
5 | * api-request: 1
6 | * api-response: X
7 | * example-request: 4
8 | * example-response: 8
9 | */
10 | enum class PostmanJson5FormatType(val desc: String, private val types: Int) {
11 | NONE("not use json5 anywhere", 0),
12 | REQUEST_ONLY("for request only", 1 or 4),
13 | RESPONSE_ONLY("for response only", 8),
14 | EXAMPLE_ONLY("for example only", 4 or 8),
15 | ALL("always use json5", 1 or 4 or 8);
16 |
17 | fun needUseJson5(type: Int): Boolean {
18 | return (this.types and type) != 0
19 | }
20 | }
--------------------------------------------------------------------------------
/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/SettingBinder.kt:
--------------------------------------------------------------------------------
1 | package com.itangcent.idea.plugin.settings
2 |
3 | import com.google.inject.ImplementedBy
4 | import com.itangcent.intellij.file.BeanBinder
5 | import com.itangcent.intellij.file.CachedBeanBinder
6 |
7 | @ImplementedBy(DefaultSettingBinder::class)
8 | interface SettingBinder : BeanBinder> defaultApi(@RequestBody List