Home | History | Annotate | Download | only in metalava

Lines Matching refs:method

43             override fun visitMethod(method: MethodItem) {
44 checkMethod(method)
58 fun checkMethod(method: MethodItem) {
59 if (!method.isConstructor()) {
60 ensureMethodNameNotKeyword(method)
61 ensureParameterNamesNotKeywords(method)
62 ensureDefaultParamsHaveJvmOverloads(method)
63 ensureCompanionJvmStatic(method)
64 ensureLambdaLastParameter(method)
65 ensureExceptionsDocumented(method)
69 private fun ensureExceptionsDocumented(method: MethodItem) {
70 if (!method.isKotlin()) {
74 val exceptions = method.findThrownExceptions()
78 val doc = method.documentation
83 val annotation = method.modifiers.findAnnotation("kotlin.jvm.Throws")
99 Errors.DOCUMENT_EXCEPTIONS, method,
100 "Method ${method.containingClass().simpleName()}.${method.name()} appears to be throwing ${exception.qualifiedName()}; this should be recorded with a @Throws annotation; see https://android.github.io/kotlin-guides/interop.html#document-exceptions"
105 Errors.DOCUMENT_EXCEPTIONS, method,
106 "Method ${method.containingClass().simpleName()}.${method.name()} appears to be throwing ${exception.qualifiedName()}; this should be listed in the documentation; see https://android.github.io/kotlin-guides/interop.html#document-exceptions"
143 private fun ensureLambdaLastParameter(method: MethodItem) {
144 val parameters = method.parameters()
155 method.containingClass().qualifiedName()}.${method.name()
158 reporter.report(Errors.SAM_SHOULD_BE_LAST, method, message)
166 private fun ensureCompanionJvmStatic(method: MethodItem) {
167 if (method.containingClass().simpleName() == "Companion" && method.isKotlin() && method.modifiers.isPublic()) {
168 if (method.isKotlinProperty()) {
170 // Only flag the read method, not the write method
171 if (method.name().startsWith("get")) {
177 val psi = method.psi()
183 field = method.containingClass().containingClass()?.findField(propertyName)
191 Errors.MISSING_JVMSTATIC, method,
196 Errors.MISSING_JVMSTATIC, method,
203 } else if (method.modifiers.findAnnotation("kotlin.jvm.JvmStatic") == null) {
205 Errors.MISSING_JVMSTATIC, method,
206 "Companion object methods like ${method.name()} should be marked @JvmStatic for Java interoperability; see https://android.github.io/kotlin-guides/interop.html#companion-functions"
216 private fun ensureMethodNameNotKeyword(method: MethodItem) {
217 checkKotlinKeyword(method.name(), "method", method)
220 private fun ensureDefaultParamsHaveJvmOverloads(method: MethodItem) {
221 if (!method.isKotlin()) {
225 val parameters = method.parameters()
232 if (parameters.isNotEmpty() && method.isJava()) {
243 if (haveDefault && method.modifiers.findAnnotation("kotlin.jvm.JvmOverloads") == null &&
245 !method.isExtensionMethod() && !method.modifiers.isInline()
248 Errors.MISSING_JVMSTATIC, method,
249 "A Kotlin method with default parameter values should be annotated with @JvmOverloads for better Java interoperability; see https://android.github.io/kotlin-guides/interop.html#function-overloads-for-defaults"
254 private fun ensureParameterNamesNotKeywords(method: MethodItem) {
255 val parameters = method.parameters()
257 if (parameters.isNotEmpty() && method.isJava()) {