Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<T>`:
* - 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ interface ClassContext {
fun fields(): Array<ScriptPsiFieldContext>
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
Expand Down Expand Up @@ -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
Expand Down
Loading