Skip to content

Commit

Permalink
Merge pull request #170 from tangcent/release/stable
Browse files Browse the repository at this point in the history
release v1.9.1.0.183.0
  • Loading branch information
tangcent authored Mar 30, 2020
2 parents 35d2406 + cfff67f commit 62eb782
Show file tree
Hide file tree
Showing 37 changed files with 251 additions and 141 deletions.
8 changes: 7 additions & 1 deletion IDEA_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,10 @@
* log saved file path [(#264)](https://github.com/tangcent/easy-api/pull/264)

* opti: [DEBUG ACTION] [(#265)](https://github.com/tangcent/easy-api/pull/265)


* fix HttpRequest querys [(#267)](https://github.com/tangcent/easy-api/pull/267)

* new rule tool: localStorage [(#268)](https://github.com/tangcent/easy-api/pull/268)


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.0.0.183.0'
version '1.9.1.0.183.0'
2 changes: 1 addition & 1 deletion common-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {

compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

compile('com.itangcent:commons:0.5.1-SNAPSHOT') {
compile('com.itangcent:commons:0.5.2-SNAPSHOT') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.itangcent.common.kit

import com.itangcent.common.constant.Attrs
import com.itangcent.common.utils.KV
import com.itangcent.common.utils.isNullOrBlank
import com.itangcent.common.utils.isNullOrEmpty
import com.itangcent.common.utils.joinToString
import com.itangcent.common.utils.*
import java.util.*
import kotlin.collections.ArrayList

Expand All @@ -25,7 +22,7 @@ object KVUtils {
val optionList = options as List<Map<String, Any?>>

val optionDesc = getOptionDesc(optionList)
if (!optionDesc.isNullOrBlank()) {
if (optionDesc.notNullOrEmpty()) {
desc = if (desc.isNullOrBlank()) {
optionDesc
} else {
Expand Down
16 changes: 16 additions & 0 deletions common-api/src/main/kotlin/com/itangcent/common/kit/KitUtils.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.itangcent.common.kit

import com.itangcent.common.utils.GsonUtils
import com.itangcent.common.utils.isNullOrBlank

import kotlin.reflect.KClass

Expand Down Expand Up @@ -92,3 +93,18 @@ fun String?.equalIgnoreCase(str: String?): Boolean {
return this.toLowerCase() == str.toLowerCase()
}

fun String?.notNullOrBlank(): Boolean {
return !this.isNullOrBlank()
}

fun Array<*>?.notNullOrEmpty(): Boolean {
return !this.isNullOrEmpty()
}

fun Collection<*>?.notNullOrEmpty(): Boolean {
return !this.isNullOrEmpty()
}

fun Map<*, *>?.notNullOrEmpty(): Boolean {
return !this.isNullOrEmpty()
}
15 changes: 10 additions & 5 deletions common-api/src/main/kotlin/com/itangcent/http/ApacheHttpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.itangcent.http

import com.itangcent.annotation.script.ScriptIgnore
import com.itangcent.annotation.script.ScriptTypeName
import com.itangcent.common.utils.append
import com.itangcent.common.kit.notNullOrEmpty
import com.itangcent.common.kit.toJson
import org.apache.http.HttpEntity
import org.apache.http.NameValuePair
Expand Down Expand Up @@ -67,9 +67,14 @@ open class ApacheHttpClient : HttpClient {
open fun call(request: ApacheHttpRequest): HttpResponse {

var url = request.url()!!
request.querys()?.let { params ->
params.joinToString("&") { "${it.name()}=${it.value()}" }
}?.let { url = url.append(it, "&")!! }
val querys = request.querys()
if (querys.notNullOrEmpty()) {
val urlParams = querys!!.joinToString("&") { "${it.name()}=${it.value()}" }
url = when {
url.contains('?') -> "$url&$urlParams"
else -> "$url?$urlParams"
}
}

val requestBuilder = RequestBuilder.create(request.method())
.setUri(url)
Expand All @@ -81,7 +86,7 @@ open class ApacheHttpClient : HttpClient {
if (request.method().toUpperCase() != "GET") {

var requestEntity: HttpEntity? = null
if (!request.params().isNullOrEmpty()) {
if (request.params().notNullOrEmpty()) {

if (request.contentType()?.startsWith("application/x-www-form-urlencoded") != true) {
if (request.contentType()?.startsWith("multipart/form-data") == true) {
Expand Down
5 changes: 3 additions & 2 deletions common-api/src/main/kotlin/com/itangcent/http/RequestUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.itangcent.http

import com.itangcent.common.constant.Attrs
import com.itangcent.common.kit.mutable
import com.itangcent.common.kit.notNullOrBlank
import com.itangcent.common.utils.GsonUtils
import com.itangcent.common.utils.append
import com.itangcent.common.utils.mapToTypedArray
Expand Down Expand Up @@ -105,11 +106,11 @@ object RequestUtils {
.append(this.protocol ?: "http")
.append("://")
.append(host!!.removeSuffix("?/"))
if (!path.isNullOrBlank()) {
if (path.notNullOrBlank()) {
sb.append("/")
sb.append(path!!.removePrefix("/").removeSuffix("?"))
}
if (!query.isNullOrBlank()) {
if (query.notNullOrBlank()) {
sb.append("?")
sb.append(query!!.removePrefix("?"))
}
Expand Down
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.0.0.183.0
plugin_version=1.9.1.0.183.0

descriptionFile=parts/pluginDescription.html
changesFile=parts/pluginChanges.html
6 changes: 3 additions & 3 deletions idea-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ dependencies {
// compile fileTree(dir: 'libs', include: ['*.jar'])


compile('com.itangcent:intellij-idea:0.5.1-SNAPSHOT') {
compile('com.itangcent:intellij-idea:0.5.2-SNAPSHOT') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}

compile('com.itangcent:intellij-kotlin-support:0.5.1-SNAPSHOT') {
compile('com.itangcent:intellij-kotlin-support:0.5.2-SNAPSHOT') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}

compile('com.itangcent:intellij-scala-support:0.5.1-SNAPSHOT') {
compile('com.itangcent:intellij-scala-support:0.5.2-SNAPSHOT') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}
Expand Down
31 changes: 5 additions & 26 deletions idea-plugin/parts/pluginChanges.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
<a href="https://github.com/tangcent/easy-yapi/releases/tag/v1.9.0.0">v1.9.0.0.183.0(2020-03-23)</a>
<a href="https://github.com/tangcent/easy-yapi/releases/tag/v1.9.1.0">v1.9.1.0.183.0(2020-03-31)</a>
<br/>
<a href="https://github.com/tangcent/easy-yapi/blob/master/IDEA_CHANGELOG.md">Full Changelog</a>
<ul>bug-fix:
<li>fix type parse for markdown formatter<a
href="https://github.com/tangcent/easy-api/pull/255">(#255)</a>
</li>
<li>addHeaderIfMissed only if the request hasBody<a
href="https://github.com/tangcent/easy-api/pull/258">(#258)</a>
</li>
<li>fix name of api without any comment<a
href="https://github.com/tangcent/easy-api/pull/263">(#263)</a>
<li>fix HttpRequest querys<a
href="https://github.com/tangcent/easy-api/pull/267">(#267)</a>
</li>
</ul>
<ul>enhancement:
<li>recommend config: private_protected_field_only<a
href="https://github.com/tangcent/easy-api/pull/256">(#256)</a>
</li>
<li>refactor http client<a
href="https://github.com/tangcent/easy-api/pull/257">(#257)</a>
</li>
<li>resolve RequestMapping#params<a
href="https://github.com/tangcent/easy-api/pull/259">(#259)</a>
</li>
<li>resolve RequestMapping#headers<a
href="https://github.com/tangcent/easy-api/pull/260">(#260)</a>
</li>
<li>log saved file path<a
href="https://github.com/tangcent/easy-api/pull/264">(#264)</a>
</li>
<li>opti: [DEBUG ACTION]<a
href="https://github.com/tangcent/easy-api/pull/265">(#265)</a>
<li>new rule tool: localStorage<a
href="https://github.com/tangcent/easy-api/pull/268">(#268)</a>
</li>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.intellij.lang.jvm.JvmModifier
import com.intellij.psi.*
import com.intellij.psi.util.*
import com.itangcent.common.kit.KVUtils
import com.itangcent.common.utils.mapToTypedArray
import com.itangcent.common.kit.notNullOrBlank
import com.itangcent.common.logger.traceError
import com.itangcent.common.utils.*
import com.itangcent.idea.plugin.settings.SettingBinder
Expand Down Expand Up @@ -277,7 +277,7 @@ class DefaultMethodInferHelper : MethodInferHelper {
valueOf(args[0])?.let {
asMap(realCaller)?.put(it, valueOf(args[1]))
val attr = findAttrFromContext(context)
if (!attr.isNullOrBlank()) {
if (attr.notNullOrBlank()) {
KVUtils.addComment(asMap(realCaller)!!, it, attr)
}
}
Expand Down Expand Up @@ -450,7 +450,7 @@ class DefaultMethodInferHelper : MethodInferHelper {
if (context == null) return null

var comment = findNextEndOfLineComment(context)
if (!comment.isNullOrBlank()) return comment
if (comment.notNullOrBlank()) return comment
comment = findPreLineEndOfLineComment(context)
return comment
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.google.inject.name.Named
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.itangcent.common.exception.ProcessCanceledException
import com.itangcent.common.kit.notNullOrEmpty
import com.itangcent.common.logger.traceError
import com.itangcent.common.model.Request
import com.itangcent.idea.plugin.StatusRecorder
Expand Down Expand Up @@ -94,7 +95,7 @@ class CachedRequestClassExporter : ClassExporter, Worker {
&& fileApiCache.lastModified!! > FileUtils.getLastModified(psiFile) ?: System.currentTimeMillis()
&& fileApiCache.md5 == md5) {

if (!fileApiCache.requests.isNullOrEmpty()) {
if (fileApiCache.requests.notNullOrEmpty()) {
statusRecorder.newWork()
actionContext.runInReadUI {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ package com.itangcent.idea.plugin.api.export
import com.google.inject.Inject
import com.intellij.lang.jvm.JvmModifier
import com.intellij.psi.*
import com.intellij.util.containers.isNullOrEmpty
import com.itangcent.common.constant.Attrs
import com.itangcent.common.constant.HttpMethod
import com.itangcent.common.exception.ProcessCanceledException
import com.itangcent.common.kit.KVUtils
import com.itangcent.common.kit.KitUtils
import com.itangcent.common.kit.getAs
import com.itangcent.common.kit.getAsKv
import com.itangcent.common.kit.*
import com.itangcent.common.logger.traceError
import com.itangcent.common.model.*
import com.itangcent.common.utils.*
Expand Down Expand Up @@ -200,7 +196,7 @@ abstract class AbstractRequestClassExporter : ClassExporter, Worker {
//parse additionalHeader by config
val additionalHeader = ruleComputer!!.computer(ClassExportRuleKeys.METHOD_ADDITIONAL_HEADER,
method)
if (!additionalHeader.isNullOrEmpty()) {
if (additionalHeader.notNullOrEmpty()) {
val additionalHeaders = additionalHeader!!.lines()
for (headerStr in additionalHeaders) {
cacheAble!!.cache("header" to headerStr) {
Expand All @@ -224,7 +220,7 @@ abstract class AbstractRequestClassExporter : ClassExporter, Worker {

//parse additionalParam by config
val additionalParam = ruleComputer.computer(ClassExportRuleKeys.METHOD_ADDITIONAL_PARAM, method)
if (!additionalParam.isNullOrEmpty()) {
if (additionalParam.notNullOrEmpty()) {
val additionalParams = additionalParam!!.lines()
for (paramStr in additionalParams) {
cacheAble!!.cache("param" to paramStr) {
Expand All @@ -247,10 +243,10 @@ abstract class AbstractRequestClassExporter : ClassExporter, Worker {
}

//parse additionalResponseHeader by config
if (!request.response.isNullOrEmpty()) {
if (request.response.notNullOrEmpty()) {
val additionalResponseHeader =
ruleComputer.computer(ClassExportRuleKeys.METHOD_ADDITIONAL_RESPONSE_HEADER, method)
if (!additionalResponseHeader.isNullOrEmpty()) {
if (additionalResponseHeader.notNullOrEmpty()) {
val additionalHeaders = additionalResponseHeader!!.lines()
for (headerStr in additionalHeaders) {
cacheAble!!.cache("header" to headerStr) {
Expand Down Expand Up @@ -281,7 +277,7 @@ abstract class AbstractRequestClassExporter : ClassExporter, Worker {
var returnType: DuckType? = null
var fromRule = false
val returnTypeByRule = ruleComputer!!.computer(ClassExportRuleKeys.METHOD_RETURN, method)
if (!returnTypeByRule.isNullOrBlank()) {
if (returnTypeByRule.notNullOrBlank()) {
val resolvedReturnType = duckTypeHelper!!.resolve(returnTypeByRule!!.trim(), method.psi())
if (resolvedReturnType != null) {
returnType = resolvedReturnType
Expand All @@ -301,7 +297,7 @@ abstract class AbstractRequestClassExporter : ClassExporter, Worker {
val typedResponse = parseResponseBody(returnType, fromRule, method)

val descOfReturn = docHelper!!.findDocByTag(method.psi(), "return")
if (!descOfReturn.isNullOrBlank()) {
if (descOfReturn.notNullOrBlank()) {
val methodReturnMain = ruleComputer.computer(ClassExportRuleKeys.METHOD_RETURN_MAIN, method)
if (methodReturnMain.isNullOrBlank()) {
requestHelper.appendResponseBodyDesc(response, descOfReturn)
Expand Down Expand Up @@ -340,12 +336,12 @@ abstract class AbstractRequestClassExporter : ClassExporter, Worker {
}
})

if (!comment.isNullOrBlank()) {
if (comment.notNullOrBlank()) {
if (!KVUtils.addKeyComment(typedResponse, methodReturnMain!!, comment!!)) {
requestHelper.appendResponseBodyDesc(response, comment)
}
}
if (!options.isNullOrEmpty()) {
if (options.notNullOrEmpty()) {
if (!KVUtils.addKeyOptions(typedResponse, methodReturnMain!!, options)) {
requestHelper.appendResponseBodyDesc(response, KVUtils.getOptionDesc(options))
}
Expand Down Expand Up @@ -399,7 +395,7 @@ abstract class AbstractRequestClassExporter : ClassExporter, Worker {
val name: String = entry.key
val value: String? = entry.value
if (methodParamComment == null) methodParamComment = KV.create()
if (!value.isNullOrBlank()) {
if (value.notNullOrBlank()) {

val options: ArrayList<HashMap<String, Any?>> = ArrayList()
val comment = linkExtractor!!.extract(value, psiMethod, object : AbstractLinkResolve() {
Expand Down Expand Up @@ -436,7 +432,7 @@ abstract class AbstractRequestClassExporter : ClassExporter, Worker {
})

methodParamComment!![name] = comment ?: ""
if (!options.isNullOrEmpty()) {
if (options.notNullOrEmpty()) {
methodParamComment!!["$name@options"] = options
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.google.inject.Singleton
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiType
import com.itangcent.common.kit.KVUtils
import com.itangcent.common.kit.notNullOrBlank
import com.itangcent.common.kit.notNullOrEmpty
import com.itangcent.intellij.config.rule.RuleComputer
import com.itangcent.intellij.jvm.DuckTypeHelper
import com.itangcent.intellij.jvm.JvmClassHelper
Expand Down Expand Up @@ -53,11 +55,11 @@ class CommentResolver {

val convertTo = ruleComputer!!.computer(ClassRuleKeys.ENUM_CONVERT, duckType, context)

if (!convertTo.isNullOrBlank()) {
if (convertTo.contains("#")) {
if (convertTo.notNullOrBlank()) {
if (convertTo!!.contains("#")) {
val options = psiClassHelper!!.resolveEnumOrStatic(convertTo, context, "")
if (!options.isNullOrEmpty()) {
return KVUtils.getOptionDesc(options)
if (options.notNullOrEmpty()) {
return KVUtils.getOptionDesc(options!!)
}
} else {
val resolveClass = duckTypeHelper!!.resolveClass(convertTo, context)
Expand Down Expand Up @@ -97,11 +99,11 @@ class CommentResolver {

val convertTo = ruleComputer!!.computer(ClassRuleKeys.ENUM_CONVERT, psiType, context)

if (!convertTo.isNullOrBlank()) {
if (convertTo.contains("#")) {
if (convertTo.notNullOrBlank()) {
if (convertTo!!.contains("#")) {
val options = psiClassHelper!!.resolveEnumOrStatic(convertTo, context, "")
if (!options.isNullOrEmpty()) {
return KVUtils.getOptionDesc(options)
if (options.notNullOrEmpty()) {
return KVUtils.getOptionDesc(options!!)
}
} else {
val resolveClass = duckTypeHelper!!.resolveClass(convertTo, context)
Expand Down
Loading

0 comments on commit 62eb782

Please sign in to comment.