예제 #1
0
 private String getObjCMethodSignature(IMethodBinding method) {
   StringBuilder sb = new StringBuilder(method.getName());
   boolean first = true;
   for (ITypeBinding paramType : method.getParameterTypes()) {
     String keyword = nameTable.parameterKeyword(paramType);
     if (first) {
       first = false;
       keyword = NameTable.capitalize(keyword);
     }
     sb.append(keyword + ":");
   }
   return sb.toString();
 }
 private String parameterKey(IMethodBinding method) {
   StringBuilder sb = new StringBuilder();
   ITypeBinding[] parameterTypes = method.getParameterTypes();
   for (int i = 0; i < parameterTypes.length; i++) {
     if (i == 0) {
       sb.append(NameTable.capitalize(NameTable.parameterKeyword(parameterTypes[i])));
     } else {
       sb.append(NameTable.parameterKeyword(parameterTypes[i]));
     }
     sb.append('_');
   }
   return sb.toString();
 }
 // Prints an annotation's values as a constructor argument list. If
 // the annotation type declares default values, then for any value that
 // isn't specified in the annotation will use the default.
 private void printAnnotationParameters(Annotation annotation) {
   IAnnotationBinding binding = Types.getAnnotationBinding(annotation);
   IMemberValuePairBinding[] valueBindings = BindingUtil.getSortedMemberValuePairs(binding);
   for (int i = 0; i < valueBindings.length; i++) {
     if (i > 0) {
       print(' ');
     }
     IMemberValuePairBinding valueBinding = valueBindings[i];
     print(i == 0 ? "With" : "with");
     printf("%s:", NameTable.capitalize(valueBinding.getName()));
     Object value = valueBinding.getValue();
     printAnnotationValue(annotation.getAST(), value);
   }
 }
 public void testCapitalize() {
   assertEquals("Test", NameTable.capitalize("test"));
   assertEquals("123", NameTable.capitalize("123"));
   assertEquals("", NameTable.capitalize(""));
 }