Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release v1.9.5.0.183.0 #193

Merged
merged 6 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion IDEA_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,12 @@
* feat: support new rule `api.open` [(#179)](https://github.com/tangcent/easy-yapi/pull/179)

* feat: support switch notice at `Setting` [(#180)](https://github.com/tangcent/easy-yapi/pull/180)


* opti: support new rule `postman.prerequest`&`postman.test` [(#283)](https://github.com/tangcent/easy-api/pull/283)

* opti: support new rule tool `config` [(#284)](https://github.com/tangcent/easy-api/pull/284)

* fix: preserving the order of field in `YapiFormatter` [(#189)](https://github.com/tangcent/easy-yapi/pull/189)

* opti: input new token if the old one be deleted. [(#192)](https://github.com/tangcent/easy-yapi/pull/192)

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group 'com.itangcent'
version '1.9.4.0.183.0'
version '1.9.5.0.183.0'
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.daemon=true
org.gradle.workers.max=8
idea_version=2017.3.5
plugin_name=EasyYapi
plugin_version=1.9.4.0.183.0
plugin_version=1.9.5.0.183.0

descriptionFile=parts/pluginDescription.html
changesFile=parts/pluginChanges.html
23 changes: 12 additions & 11 deletions idea-plugin/parts/pluginChanges.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<a href="https://github.com/tangcent/easy-yapi/releases/tag/v1.9.4.0">v1.9.4.0.183.0(2020-05-06)</a>
<a href="https://github.com/tangcent/easy-yapi/releases/tag/v1.9.5.0">v1.9.5.0.183.0(2020-05-13)</a>
<br/>
<a href="https://github.com/tangcent/easy-yapi/blob/master/IDEA_CHANGELOG.md">Full Changelog</a>
<ul>bug-fix:
<li>fix: request body preview-language in postman example<a
href="https://github.com/tangcent/easy-api/pull/281">(#281)</a>
</li>
</ul>
<a href="https://github.com/tangcent/easy-api/blob/master/IDEA_CHANGELOG.md">Full Changelog</a>
<ul>enhancement:
<li>feat: support new rule `api.open` <a
href="https://github.com/tangcent/easy-yapi/pull/179">(#179)</a>
<li>opti: support new rule `postman.prerequest`&`postman.test`<a
href="https://github.com/tangcent/easy-api/pull/283">(#283)</a>
</li>
<li>feat: support switch notice at `Setting` <a
href="https://github.com/tangcent/easy-yapi/pull/180">(#180)</a>
<li>opti: support new rule tool `config`<a
href="https://github.com/tangcent/easy-api/pull/284">(#284)</a>
</li>
</ul>
<ul>fix
<li>fix: preserving the order of field in `YapiFormatter` <a
href="https://github.com/tangcent/easy-yapi/pull/189">(#189)</a></li>
<li>opti: input new token if the old one be deleted. <a
href="https://github.com/tangcent/easy-yapi/pull/192">(#192)</a></li>
</ul>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.itangcent.idea.plugin.api.export

import com.itangcent.intellij.config.AutoSearchConfigReader
import com.itangcent.utils.Initializable

class EasyApiConfigReader : AutoSearchConfigReader() {
class EasyApiConfigReader : AutoSearchConfigReader(), Initializable {

// @PostConstruct
fun init() {
override fun init() {
loadConfigInfo()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.itangcent.idea.plugin.api.export.postman

import com.itangcent.intellij.config.AutoSearchConfigReader
import com.itangcent.utils.Initializable

class PostmanConfigReader : AutoSearchConfigReader() {
class PostmanConfigReader : AutoSearchConfigReader(), Initializable {

// @PostConstruct
fun init() {
override fun init() {
loadConfigInfo()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import com.itangcent.intellij.config.MutableConfigReader
import com.itangcent.intellij.extend.guice.PostConstruct
import com.itangcent.intellij.logger.Logger
import com.itangcent.intellij.psi.ContextSwitchListener
import com.itangcent.utils.Initializable
import org.apache.commons.io.IOUtils
import java.io.File
import java.util.*
import java.util.concurrent.TimeUnit


class RecommendConfigReader : ConfigReader {
class RecommendConfigReader : ConfigReader, Initializable {

@Inject
@Named("delegate_config_reader")
Expand Down Expand Up @@ -67,7 +68,7 @@ class RecommendConfigReader : ConfigReader {
}

@PostConstruct
fun init() {
override fun init() {

if (configReader is MutableConfigReader) {
contextSwitchListener!!.clear()
Expand All @@ -94,7 +95,11 @@ class RecommendConfigReader : ConfigReader {

private fun initDelegateAndRecommend() {
try {
configReader?.invokeMethod("init")
if (configReader is Initializable) {
configReader.init()
} else {
configReader?.invokeMethod("init")
}
} catch (e: Throwable) {
}
if (settingBinder?.read()?.useRecommendConfig == true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ import com.itangcent.common.logger.traceError
import com.itangcent.common.logger.traceWarn
import com.itangcent.common.utils.notNullOrEmpty
import com.itangcent.idea.plugin.rule.contextOf
import com.itangcent.intellij.config.ConfigReader
import com.itangcent.intellij.config.rule.RuleParser
import com.itangcent.intellij.config.rule.StringRule
import com.itangcent.intellij.context.ActionContext
import com.itangcent.intellij.extend.guice.PostConstruct
import com.itangcent.intellij.extend.rx.AutoComputer
import com.itangcent.intellij.jvm.DuckTypeHelper
import com.itangcent.intellij.logger.Logger
import com.itangcent.intellij.psi.ContextSwitchListener
import com.itangcent.intellij.psi.PsiClassUtils
import com.itangcent.intellij.util.ToolUtils
import org.apache.commons.lang3.exception.ExceptionUtils
Expand Down Expand Up @@ -71,6 +73,12 @@ class DebugDialog : JDialog() {
@Inject
val logger: Logger? = null

@Inject
val configReader: ConfigReader? = null

@Inject
val contextSwitchListener: ContextSwitchListener? = null

private var evalTimer: Timer = Timer()
private var lastEvalTime: AtomicLong = AtomicLong(0)
private var scriptInfo: ScriptInfo? = null
Expand Down Expand Up @@ -128,9 +136,13 @@ class DebugDialog : JDialog() {
doCopy()
}

// autoComputer.bind<Any>(this, "context")
// .with(this.contextTextField!!)
// .eval { contextStr -> }
autoComputer.listen(this::context)
.action { ele ->
ele?.let {
contextSwitchListener?.switchTo(it)
}
}

autoComputer.bind(this.contextTextField!!)
.with(this::context)
.eval { context ->
Expand Down Expand Up @@ -410,7 +422,7 @@ class DebugDialog : JDialog() {
}

override fun demoCode(): String {
return "var separator = tool.repeat(\"-\", 35) + \"\\n\\n\"\nvar sb = \"\"\nsb += \"debug `tool`:\\n\"\nsb += tool.debug(tool)\nsb += separator\nsb += \"debug `it`:\\n\"\nsb += tool.debug(it)\nsb += separator\nsb += \"debug `regex`:\\n\"\nsb += tool.debug(regex)\nsb += separator\nsb += \"debug `logger`:\\n\"\nsb += tool.debug(logger)\nsb += separator\nsb += \"debug `helper`:\\n\"\nsb += tool.debug(helper)\nsb += separator\nsb += \"debug `httpClient`:\\n\"\nsb += tool.debug(httpClient)\nsb += separator\nsb += \"debug `localStorage`:\\n\"\nsb += tool.debug(localStorage)\nsb += separator\nsb"
return "var separator = tool.repeat(\"-\", 35) + \"\\n\\n\"\nvar sb = \"\"\nsb += \"debug `tool`:\\n\"\nsb += tool.debug(tool)\nsb += separator\nsb += \"debug `it`:\\n\"\nsb += tool.debug(it)\nsb += separator\nsb += \"debug `regex`:\\n\"\nsb += tool.debug(regex)\nsb += separator\nsb += \"debug `logger`:\\n\"\nsb += tool.debug(logger)\nsb += separator\nsb += \"debug `helper`:\\n\"\nsb += tool.debug(helper)\nsb += separator\nsb += \"debug `httpClient`:\\n\"\nsb += tool.debug(httpClient)\nsb += separator\nsb += \"debug `localStorage`:\\n\"\nsb += tool.debug(localStorage)\nsb += separator\nsb += \"debug `config`:\\n\"\nsb += tool.debug(config)\nsb += separator\nsb"
}
}

Expand All @@ -433,7 +445,7 @@ class DebugDialog : JDialog() {
}

override fun demoCode(): String {
return "def separator = tool.repeat(\"-\", 35) + \"\\n\\n\"\ndef sb = \"\"\nsb += \"debug `tool`:\\n\"\nsb += tool.debug(tool)\nsb += separator\nsb += \"debug `it`:\\n\"\nsb += tool.debug(it)\nsb += separator\nsb += \"debug `regex`:\\n\"\nsb += tool.debug(regex)\nsb += separator\nsb += \"debug `logger`:\\n\"\nsb += tool.debug(logger)\nsb += separator\nsb += \"debug `helper`:\\n\"\nsb += tool.debug(helper)\nsb += separator\nsb += \"debug `httpClient`:\\n\"\nsb += tool.debug(httpClient)\nsb += separator\nsb += \"debug `localStorage`:\\n\"\nsb += tool.debug(localStorage)\nsb += separator\nreturn sb"
return "def separator = tool.repeat(\"-\", 35) + \"\\n\\n\"\ndef sb = \"\"\nsb += \"debug `tool`:\\n\"\nsb += tool.debug(tool)\nsb += separator\nsb += \"debug `it`:\\n\"\nsb += tool.debug(it)\nsb += separator\nsb += \"debug `regex`:\\n\"\nsb += tool.debug(regex)\nsb += separator\nsb += \"debug `logger`:\\n\"\nsb += tool.debug(logger)\nsb += separator\nsb += \"debug `helper`:\\n\"\nsb += tool.debug(helper)\nsb += separator\nsb += \"debug `httpClient`:\\n\"\nsb += tool.debug(httpClient)\nsb += separator\nsb += \"debug `localStorage`:\\n\"\nsb += tool.debug(localStorage)\nsb += separator\nsb += \"debug `config`:\\n\"\nsb += tool.debug(config)\nsb += separator\nreturn sb"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import com.itangcent.annotation.script.ScriptReturn
import com.itangcent.annotation.script.ScriptTypeName
import com.itangcent.idea.plugin.utils.LocalStorageUtils
import com.itangcent.idea.plugin.utils.RegexUtils
import com.itangcent.intellij.config.ConfigReader
import com.itangcent.intellij.config.rule.RuleContext
import com.itangcent.intellij.context.ActionContext
import com.itangcent.intellij.jvm.LinkExtractor
import com.itangcent.intellij.jvm.LinkResolver
import com.itangcent.suv.http.HttpClientProvider
Expand All @@ -21,7 +23,11 @@ abstract class StandardJdkRuleParser : ScriptRuleParser() {
@Inject
protected val localStorageUtils: LocalStorageUtils? = null

@Inject
protected val actionContext: ActionContext? = null

private var scriptEngine: ScriptEngine? = null

private var unsupported = false

protected abstract fun scriptType(): String
Expand Down Expand Up @@ -59,6 +65,7 @@ abstract class StandardJdkRuleParser : ScriptRuleParser() {
engineBindings["localStorage"] = localStorageUtils
engineBindings["helper"] = Helper(context.getPsiContext())
engineBindings["httpClient"] = httpClientProvider!!.getHttpClient()
engineBindings["config"] = actionContext!!.instance(Config::class)
}

@Inject
Expand Down Expand Up @@ -109,6 +116,26 @@ abstract class StandardJdkRuleParser : ScriptRuleParser() {

}

@ScriptTypeName("config")
class Config {

@Inject
private val configReader: ConfigReader? = null

fun get(name: String): String? {
return configReader!!.first(name)
}

@ScriptReturn("array<string>")
fun getValues(name: String): Collection<String>? {
return configReader!!.read(name)
}

fun resolveProperty(property: String): String {
return configReader!!.resolveProperty(property)
}
}

companion object {
private val toolBindings: Bindings

Expand Down
13 changes: 13 additions & 0 deletions idea-plugin/src/main/kotlin/com/itangcent/utils/Initializable.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.itangcent.utils

import com.itangcent.intellij.context.ActionContext

/**
* Interface to be implemented by beans that need to react once all their properties
* have been inject by [ActionContext]: e.g. to perform custom initialization,
* or merely to check that all mandatory properties have been set.
*/
interface Initializable {

fun init()
}
2 changes: 1 addition & 1 deletion idea-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>com.itangcent.idea.plugin.easy-yapi</id>
<name>EasyYapi</name>
<version>1.9.4.0.183.0</version>
<version>1.9.5.0.183.0</version>
<vendor email="[email protected]" url="https://github.com/tangcent">Tangcent</vendor>

<description><![CDATA[ Description will be added by gradle build]]></description>
Expand Down