-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from tangcent/release/stable
release v1.1.0.183.0.2
- Loading branch information
Showing
12 changed files
with
126 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
group 'com.itangcent' | ||
version '1.1.0.183.0.1' | ||
version '1.1.0.183.0.2' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/CommentResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.itangcent.idea.plugin.api.export | ||
|
||
import com.google.inject.Inject | ||
import com.google.inject.Singleton | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiType | ||
import com.itangcent.common.utils.KVUtils | ||
import com.itangcent.intellij.config.rule.RuleComputer | ||
import com.itangcent.intellij.jvm.JvmClassHelper | ||
import com.itangcent.intellij.jvm.PsiClassHelper | ||
import com.itangcent.intellij.jvm.PsiResolver | ||
import com.itangcent.intellij.logger.Logger | ||
import com.itangcent.intellij.psi.ClassRuleKeys | ||
|
||
@Singleton | ||
class CommentResolver { | ||
|
||
@Inject | ||
protected val logger: Logger? = null | ||
|
||
@Inject | ||
protected val ruleComputer: RuleComputer? = null | ||
|
||
@Inject | ||
protected val jvmClassHelper: JvmClassHelper? = null | ||
|
||
@Inject | ||
protected val psiResolver: PsiResolver? = null | ||
|
||
@Inject | ||
protected val psiClassHelper: PsiClassHelper? = null | ||
|
||
|
||
fun resolveCommentForType(psiType: PsiType, context: PsiElement): String? { | ||
|
||
if (jvmClassHelper!!.isEnum(psiType)) { | ||
|
||
val convertTo = ruleComputer!!.computer(ClassRuleKeys.ENUM_CONVERT, psiType, context) | ||
|
||
if (!convertTo.isNullOrBlank()) { | ||
if (convertTo.contains("#")) { | ||
val options = psiClassHelper!!.resolveEnumOrStatic(convertTo, context, "") | ||
if (!options.isNullOrEmpty()) { | ||
return KVUtils.getOptionDesc(options) | ||
} | ||
} else { | ||
val resolveClass = psiResolver!!.resolveClass(convertTo, context) | ||
if (resolveClass == null) { | ||
logger!!.error("failed to resolve class:$convertTo") | ||
return null | ||
} | ||
val constants = psiClassHelper!!.parseEnumConstant(resolveClass) | ||
if (constants.isEmpty()) { | ||
logger!!.error("nothing be found at:$convertTo") | ||
return null | ||
} | ||
|
||
return KVUtils.getConstantDesc(constants) | ||
} | ||
} | ||
|
||
val enumClass = jvmClassHelper.resolveClassInType(psiType)!! | ||
val constants = psiClassHelper!!.parseEnumConstant(enumClass) | ||
if (constants.isEmpty()) { | ||
logger!!.error("nothing be found at:$convertTo") | ||
return null | ||
} | ||
|
||
return KVUtils.getConstantDesc(constants) | ||
} | ||
|
||
return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.1.0.183.0.1</version> | ||
<version>1.1.0.183.0.2</version> | ||
<vendor email="[email protected]" url="https://github.com/tangcent">Tangcent</vendor> | ||
|
||
<description><![CDATA[ Description will be added by gradle build]]></description> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters