protected String getMethodSignature ( MethodDeclaration m ) { StringBuilder sb = new StringBuilder ( ) ; ExecutableElement element = m . getExecutableElement ( ) ; char prefix = Modifier . isStatic ( m . getModifiers ( ) ) ? ' ' : ' ' ; String returnType = nameTable . getObjCType ( element . getReturnType ( ) ) ; String selector = nameTable . getMethodSelector ( element ) ; if ( m . isConstructor ( ) ) { returnType = "instancetype" ; } else if ( selector . equals ( "hash" ) ) { // Explicitly test hashCode() because of NSObject's hash return value. returnType = "NSUInteger" ; } sb . append ( UnicodeUtils . format ( "%c (%s%s)" , prefix , returnType , nullability ( element ) ) ) ; List < SingleVariableDeclaration > params = m . getParameters ( ) ; String [ ] selParts = selector . split ( ":" ) ; if ( params . isEmpty ( ) ) { assert selParts . length == 1 && ! selector . endsWith ( ":" ) ; sb . append ( selParts [ 0 ] ) ; } else { assert params . size ( ) == selParts . length ; int baseLength = sb . length ( ) + selParts [ 0 ] . length ( ) ; for ( int i = 0 ; i < params . size ( ) ; i ++ ) { if ( i != 0 ) { sb . append ( ' ' ) ; sb . append ( pad ( baseLength - selParts [ i ] . length ( ) ) ) ; } VariableElement var = params . get ( i ) . getVariableElement ( ) ; String typeName = nameTable . getObjCType ( var . asType ( ) ) ; sb . append ( UnicodeUtils . format ( "%s:(%s%s)%s" , selParts [ i ] , typeName , nullability ( var ) , nameTable . getVariableShortName ( var ) ) ) ; } } return sb . toString ( ) ; }
Create an Objective - C method signature string .