diff --git a/src/main/kotlin/com/itangcent/easyapi/core/export/EndpointBuilder.kt b/src/main/kotlin/com/itangcent/easyapi/core/export/EndpointBuilder.kt index 2d227aad..44940b93 100644 --- a/src/main/kotlin/com/itangcent/easyapi/core/export/EndpointBuilder.kt +++ b/src/main/kotlin/com/itangcent/easyapi/core/export/EndpointBuilder.kt @@ -4,8 +4,6 @@ import com.intellij.openapi.components.service import com.intellij.openapi.project.Project import com.intellij.psi.PsiClass import com.intellij.psi.PsiMethod -import com.itangcent.easyapi.core.export.ApiHeader -import com.itangcent.easyapi.core.export.ApiParameter import com.itangcent.easyapi.core.psi.PsiClassHelper import com.itangcent.easyapi.core.psi.helper.DocHelper import com.itangcent.easyapi.core.psi.helper.DocMetadataResolver @@ -110,7 +108,7 @@ class EndpointBuilder(private val project: Project) { * * The `method.return.main` rule specifies a field name within the response type where * the `@return` doc comment should be placed. For example, with `Result`: - * - Rule: `method.return.main[groovy:it.returnType().isExtend("Result")]=data` + * - Rule: `method.return.main[groovy:it.returnType().isExtend("com.example.Result")]=data` * - `@return "processed result"` is attached to the `data` field instead of the root * * If no explicit rule is set and `settings.inferReturnMain` is true, auto-detects diff --git a/src/main/kotlin/com/itangcent/easyapi/core/rule/context/ScriptPsiContexts.kt b/src/main/kotlin/com/itangcent/easyapi/core/rule/context/ScriptPsiContexts.kt index cb4d37c9..1ffdcf6f 100644 --- a/src/main/kotlin/com/itangcent/easyapi/core/rule/context/ScriptPsiContexts.kt +++ b/src/main/kotlin/com/itangcent/easyapi/core/rule/context/ScriptPsiContexts.kt @@ -37,6 +37,14 @@ interface ClassContext { fun fields(): Array fun fieldCnt(): Int fun type(): ScriptTypeContext + + /** + * Checks whether this class is, or inherits from, [superClass]. + * + * @param superClass the **fully qualified name** of the base class or + * interface, e.g. `"java.lang.Exception"`. A simple name like + * `"Exception"` never matches. + */ fun isExtend(superClass: String): Boolean fun isMap(): Boolean fun isCollection(): Boolean @@ -651,6 +659,13 @@ class ScriptTypeContext(private val context: RuleContext, private val resolvedTy override fun toString(): String = resolvedType.qualifiedName() + /** + * Checks whether this type is, or inherits from, [superClass]. + * + * @param superClass the **fully qualified name** of the base class or + * interface, e.g. `"java.lang.Exception"`. A simple name like + * `"Exception"` never matches. + */ fun isExtend(superClass: String): Boolean = when (resolvedType) { is ResolvedType.ClassType -> InheritanceHelper.isInheritor(resolvedType.psiClass, superClass) else -> false