Skip to content

Commit

Permalink
feat: remove recommend config of enum (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangcent authored Jun 27, 2021
1 parent af88a98 commit cfc08b3
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 98 deletions.
2 changes: 1 addition & 1 deletion common-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {

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

implementation('com.itangcent:commons:1.0.61-SNAPSHOT') {
implementation('com.itangcent:commons:1.0.7') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}
Expand Down
8 changes: 4 additions & 4 deletions idea-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar'])


implementation('com.itangcent:intellij-idea:1.0.61-SNAPSHOT') {
implementation('com.itangcent:intellij-idea:1.0.7') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}

implementation('com.itangcent:intellij-kotlin-support:1.0.61-SNAPSHOT') {
implementation('com.itangcent:intellij-kotlin-support:1.0.7') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}

// implementation('com.itangcent:intellij-scala-support:1.0.61-SNAPSHOT') {
// implementation('com.itangcent:intellij-scala-support:1.0.7') {
// exclude group: 'com.google.inject'
// exclude group: 'com.google.code.gson'
// }
Expand Down Expand Up @@ -124,7 +124,7 @@ dependencies {
// https://mvnrepository.com/artifact/org.mockito/mockito-inline
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '3.11.0'

testImplementation('com.itangcent:intellij-idea-test:1.0.61-SNAPSHOT') {
testImplementation('com.itangcent:intellij-idea-test:1.0.7') {
exclude group: 'com.nhaarman.mockitokotlin2', module: 'mockito-kotlin'
}
}
Expand Down
8 changes: 1 addition & 7 deletions idea-plugin/src/main/resources/.recommend.easy.api.config
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,4 @@ field.mock[groovy:it.hasAnn("javax.validation.constraints.DecimalMin")&&${java_i
field.mock[groovy:it.hasAnn("javax.validation.constraints.DecimalMax")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float(0,"+it.ann("javax.validation.constraints.DecimalMax")+",${float_dmin})"
field.mock[groovy:it.hasAnn("javax.validation.constraints.DecimalMin")&&${java_float_types}.contains(it.jsonType().name())]=groovy:"@float("+it.ann("javax.validation.constraints.DecimalMin")+",${float_dmin})"

###set resolveMulti = error

#[support_enum_common]*
#support the common ways to use enum
enum.use.name=groovy:it.type().name()=="java.lang.String"
enum.use.ordinal=groovy:it.type().name()=="int"
enum.use.ordinal=groovy:it.type().name()=="java.lang.Integer"
###set resolveMulti = error
4 changes: 2 additions & 2 deletions idea-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
<category>Web</category>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="183.0"/>
<!-- <idea-version since-build="183.0"/>-->

<!--for compatible-->
<!--<idea-version since-build="173.0" until-build="183.0"/>-->

<!--for dev-->
<!--<idea-version since-build="173.0"/>-->
<idea-version since-build="173.0"/>


<change-notes><![CDATA[ Change notes will be filled by gradle build ]]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ internal class YapiPsiClassHelperTest : CustomizedPsiClassHelperBaseTest() {
//testResolveEnumOrStatic---------------------------------------------------------------------------------

assertEquals(
"[]",
"[{\"value\":\"JAVA_0_9\",\"desc\":\"The Java version reported by Android. This is not an official Java version number.\"},{\"value\":\"JAVA_1_1\",\"desc\":\"Java 1.1.\"},{\"value\":\"JAVA_1_2\",\"desc\":\"Java 1.2.\"},{\"value\":\"JAVA_1_3\",\"desc\":\"Java 1.3.\"},{\"value\":\"JAVA_1_4\",\"desc\":\"Java 1.4.\"},{\"value\":\"JAVA_1_5\",\"desc\":\"Java 1.5.\"},{\"value\":\"JAVA_1_6\",\"desc\":\"Java 1.6.\"},{\"value\":\"JAVA_1_7\",\"desc\":\"Java 1.7.\"},{\"value\":\"JAVA_1_8\",\"desc\":\"Java 1.8.\"},{\"value\":\"JAVA_1_9\",\"desc\":\"Java 1.9.\"},{\"value\":\"JAVA_9\",\"desc\":\"Java 9\"},{\"value\":\"JAVA_10\",\"desc\":\"Java 10\"},{\"value\":\"JAVA_11\",\"desc\":\"Java 11\"},{\"value\":\"JAVA_12\",\"desc\":\"Java 12\"},{\"value\":\"JAVA_13\",\"desc\":\"Java 13\"}]",
GsonUtils.toJson(
psiClassHelper.resolveEnumOrStatic(
"com.itangcent.constant.JavaVersion",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,37 @@ internal class RecommendConfigSettingsHelperTest : SettingsHelperTest() {

@Test
fun testLoadRecommendConfig() {
settings.recommendConfigs = "-Jackson_JsonIgnoreProperties,-converts,-yapi_tag,-spring.ui,-import_spring_properties,-support_mock_for_general,-deprecated_java,-deprecated_kotlin,-spring_Entity,-spring_webflux,-javax.validation,-javax.validation(grouped),-support_mock_for_javax_validation"
assertEquals("#Get the module from the comment,group the apis\n" +
"module=#module\n" +
"#Ignore class/api\n" +
"ignore=#ignore\n" +
"#Support for Jackson annotations\n" +
"[email protected]#value\n" +
"[email protected]#value\n" +
"#Support for Gson annotations\n" +
"field.name=@com.google.gson.annotations.SerializedName#value\n" +
"[email protected]#serialize\n" +
"#ignore transient field\n" +
"field.ignore=groovy:it.hasModifier(\"transient\")\n" +
"#Support spring.validations\n" +
"field.[email protected]\n" +
"param.ignore=groovy:it.type().isExtend(\"org.springframework.validation.BindingResult\")\n" +
"#Support spring file\n" +
"type.is_file=groovy:it.isExtend(\"org.springframework.web.multipart.MultipartFile\")\n" +
"#yapi tag for kotlin\n" +
"api.tag[@kotlin.Deprecated]=deprecated\n" +
"api.tag[groovy:it.containingClass().hasAnn(\"kotlin.Deprecated\")]=deprecated\n" +
"#yapi status\n" +
"api.status[#undone]=undone\n" +
"api.status[#todo]=undone\n" +
"#yapi mock\n" +
"field.mock=#mock\n" +
"#ignore serialVersionUID\n" +
"constant.field.ignore=groovy:it.name()==\"serialVersionUID\"\n" +
"#support the common ways to use enum\n" +
"enum.use.name=groovy:it.type().name()==\"java.lang.String\"\n" +
"enum.use.ordinal=groovy:it.type().name()==\"int\"\n" +
"enum.use.ordinal=groovy:it.type().name()==\"java.lang.Integer\"", recommendConfigSettingsHelper.loadRecommendConfig().toUnixString())
settings.recommendConfigs =
"-Jackson_JsonIgnoreProperties,-converts,-yapi_tag,-spring.ui,-import_spring_properties,-support_mock_for_general,-deprecated_java,-deprecated_kotlin,-spring_Entity,-spring_webflux,-javax.validation,-javax.validation(grouped),-support_mock_for_javax_validation"
assertEquals(
"#Get the module from the comment,group the apis\n" +
"module=#module\n" +
"#Ignore class/api\n" +
"ignore=#ignore\n" +
"#Support for Jackson annotations\n" +
"[email protected]#value\n" +
"field.ignore=@com.fasterxml.jackson.annotation.JsonIgnore#value\n" +
"#Support for Gson annotations\n" +
"field[email protected]#value\n" +
"field.ignore=[email protected]#serialize\n" +
"#ignore transient field\n" +
"field.ignore=groovy:it.hasModifier(\"transient\")\n" +
"#Support spring.validations\n" +
"[email protected]\n" +
"param.ignore=groovy:it.type().isExtend(\"org.springframework.validation.BindingResult\")\n" +
"#Support spring file\n" +
"type.is_file=groovy:it.isExtend(\"org.springframework.web.multipart.MultipartFile\")\n" +
"#yapi tag for kotlin\n" +
"api.tag[@kotlin.Deprecated]=deprecated\n" +
"api.tag[groovy:it.containingClass().hasAnn(\"kotlin.Deprecated\")]=deprecated\n" +
"#yapi status\n" +
"api.status[#undone]=undone\n" +
"api.status[#todo]=undone\n" +
"#yapi mock\n" +
"field.mock=#mock\n" +
"#ignore serialVersionUID\n" +
"constant.field.ignore=groovy:it.name()==\"serialVersionUID\"",
recommendConfigSettingsHelper.loadRecommendConfig().toUnixString()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ internal class CustomizedPsiClassHelperTest : CustomizedPsiClassHelperBaseTest()

fun testResolveEnumOrStatic() {
assertEquals(
"[]",
"[{\"value\":\"JAVA_0_9\",\"desc\":\"The Java version reported by Android. This is not an official Java version number.\"},{\"value\":\"JAVA_1_1\",\"desc\":\"Java 1.1.\"},{\"value\":\"JAVA_1_2\",\"desc\":\"Java 1.2.\"},{\"value\":\"JAVA_1_3\",\"desc\":\"Java 1.3.\"},{\"value\":\"JAVA_1_4\",\"desc\":\"Java 1.4.\"},{\"value\":\"JAVA_1_5\",\"desc\":\"Java 1.5.\"},{\"value\":\"JAVA_1_6\",\"desc\":\"Java 1.6.\"},{\"value\":\"JAVA_1_7\",\"desc\":\"Java 1.7.\"},{\"value\":\"JAVA_1_8\",\"desc\":\"Java 1.8.\"},{\"value\":\"JAVA_1_9\",\"desc\":\"Java 1.9.\"},{\"value\":\"JAVA_9\",\"desc\":\"Java 9\"},{\"value\":\"JAVA_10\",\"desc\":\"Java 10\"},{\"value\":\"JAVA_11\",\"desc\":\"Java 11\"},{\"value\":\"JAVA_12\",\"desc\":\"Java 12\"},{\"value\":\"JAVA_13\",\"desc\":\"Java 13\"}]",
GsonUtils.toJson(
psiClassHelper.resolveEnumOrStatic(
"com.itangcent.constant.JavaVersion",
Expand Down

0 comments on commit cfc08b3

Please sign in to comment.