def build_func_widget(v, count): code = v['code'] code2 = str_utils.upperFirstWord(code) name = v['name'] content = '' for i in range(1, count): content += ''' SocTextField( key: const Key('%(code)sValueController%(i)s'), keyName: '%(code)sValueController%(i)s', focusNode: controller.%(code)sValueFocusNode%(i)s, controller: controller.%(code)sValueController%(i)s, labelText: \'${Langs.toolCalcVolumeSideLength}(a)\', keyboardType: TextInputType.numberWithOptions(decimal: true), maxDecimalLength: 8, clearIconFlag: true, ), BaseStyle.vGap12,''' % { 'code': code, 'i': str(i) } print(''' /// 构建%(name)s输入view Widget _build%(code2)sInputs(BuildContext context) { return Column( children: [ %(content)s ], ); }''' % { 'name': name, 'code2': code2, 'content': content })
def build_dispose_widget(v, count): code = v['code'] code2 = str_utils.upperFirstWord(code) name = v['name'] for i in range(1, count): print(code + 'ValueFocusNode' + str(i) + '.dispose();\n' + code + 'ValueController' + str(i) + '.dispose();\n')
def build_init_widget(v, count): code = v['code'] code2 = str_utils.upperFirstWord(code) name = v['name'] for i in range(1, count): print(code + 'ValueFocusNode' + str(i) + ' = FocusNode();\n' + code + 'ValueController' + str(i) + ' = TextEditingController();\n' + code + 'ValueController' + str(i) + '.text = \'\';\n')
def build_const_widget(v, count): code = v['code'] code2 = str_utils.upperFirstWord(code) name = v['name'] print(' /// %(name)s\n static const String %(code)s = \'%(code)s\';' % { 'code': code, 'name': name })
def build_late_widget(v, count): code = v['code'] code2 = str_utils.upperFirstWord(code) name = v['name'] for i in range(1, count): print('/// ' + name + ' ' + str(i)) print('late final FocusNode ' + code + 'ValueFocusNode' + str(i) + ';\nlate final TextEditingController ' + code + 'ValueController' + str(i) + ';\n')
def format_langs(): langMap = { 'tool.networkDns.host': 'Host', 'tool.networkDns.aRecord': 'A record', 'tool.networkDns.cname': 'Cname', 'tool.networkDns.ptrRecord': 'Ptr record', 'tool.networkDns.nsRecord': 'Ns record', 'tool.networkDns.maxRecord': 'Max record', 'tool.networkDns.txtRecord': 'Txt record', } content = '' for k, v in langMap.items(): ks = k.split('.') key = ks[0] + ''.join([str_utils.upperFirstWord(i) for i in ks[1:]]) content += ' static String get %s =>\'%s\'.tr;\n' % (key, k) print(content)
def analysis_java_class_info(cla) -> list: """解析java class Args: cla ([type]): [description] Returns: list: 输出JavaClass对象数组 """ global _clear_suffixs, _package_name javaClasses = [] javaClass = JavaClass(str_utils.clear_str_end_chart( cla.name, _clear_suffixs), packageName=_package_name) javaClass.fileName = str_utils.hump2underline( javaClass.name) + '_' + _package_name if cla.extends != None: javaClass.extends.append(cla.extends.name) if cla.documentation != None: javaClass.comment = cla.documentation for fie in cla.body: if type(fie).__name__ == 'FieldDeclaration': # 属性字段 if 'static' in fie.modifiers: # 静态变量忽略 # TODO @JsonIgnore @JsonIgnoreProperties @JSONField(serialize = false) 也需要忽略,待实现 continue fieName = str_utils.upperFirstWord(fie.declarators[0].name) typeType = type(fie.type).__name__ typeName = str_utils.clear_str_end_chart(fie.type.name, _clear_suffixs) listFlag = False mapFlag = False subTypes = [] if typeName in ('List', 'ArrayList', 'LinkList', 'Set', 'HashSet', 'TreeSet'): listFlag = True subTypes = [ str_utils.clear_str_end_chart( fie.type.arguments[0].type.name, _clear_suffixs) ] typeName = '[]' + subTypes[0] elif typeName in ('Map', 'HashMap', 'TreeMap', 'LinkedHashMap', 'Hashtable'): mapFlag = True subTypes = [ str_utils.clear_str_end_chart( fie.type.arguments[0].type.name, _clear_suffixs), str_utils.clear_str_end_chart( fie.type.arguments[1].type.name, _clear_suffixs) ] # TODO 还需要判断不是基本类型才能加 {} typeName = 'map[' + subTypes[0] + ']' + subTypes[1] + '{}' jsonName = fie.declarators[0].name comment = fie.documentation if fie.documentation != None else '' javaClass.fields.append( Field(fieName, typeType, typeName=typeName, subTypes=subTypes, jsonName=jsonName, comment=comment, listFlag=listFlag, mapFlag=mapFlag)) javaClasses.append(javaClass) elif type(fie).__name__ == 'ClassDeclaration': # 内部类 javaClasses.extend(analysis_java_class_info(fie)) return javaClasses
def build_map_widget(v, count): code = v['code'] print('CalcPerimeterController.%s: _build%sInputs,' % (code, str_utils.upperFirstWord(code)))
def build_focus_widget(v, count): code = v['code'] code2 = str_utils.upperFirstWord(code) name = v['name'] for i in range(1, count): print('controller.' + code + 'ValueFocusNode' + str(i) + ',')