def check_struct_or_typedef(name): """check if name is a struct or typedef in the project """ if ctagscache.parse(name, 'st'): return True else: return False
def resolve_single(name, t=''): """Resolve a name :return a dict {name: code, name.t: code} """ result = {} ctags_result = ctagscache.parse(name, t) path = ctagscache.get_path() if ctags_result: for filename,line_number,t,fields in ctags_result: # 'm' because A.b will be parsed by srcml as <expr><name>A</name>.<name>b</name></expr> # so it will be extracted as variable to resolve. (get_undefined_vars) # if 'm', just ignore it is ok if t in 'm': code = '' else: code = fileutil.get_block(os.path.join(path, filename), line_number, t=t) # this is hot fix for the struct settings settings declared above. # we need to return both of them # for every type, we only contain one. # This is for the two static function in different file. # But we didn't choose which to use, which is potentially a bug. new_name = name+'.'+t if code: result[new_name] = (code.strip(), filename, line_number) return result
def check_global_variable(name): """check if name is a global variable in the project """ # variables # defines # union members # e: enum members if ctagscache.parse(name, 'vdme'): return True else: return False