def returnSymbolCompletions(view, symbol_type): projects_cache = cache.projects_cache if not symbol_type in commands.symbol_dict: return [] file_key, project_key = cache.get_keys( view, return_both=True ) completion_list = [] for file in project.get_external_files(): if file in projects_cache: completion_list = completion_list + projects_cache[file][symbol_type][file] if file_key in projects_cache: if symbol_type in projects_cache[file_key]: completion_list = completion_list + projects_cache[file_key][symbol_type][file_key] if project_key in projects_cache: if symbol_type in projects_cache[project_key]: for file in projects_cache[project_key][symbol_type]: completion_list = completion_list + projects_cache[project_key][symbol_type][file] if completion_list: return [ tuple(completions) for completions in completion_list ] else: # we have no cache so just return whats in the current view return get_view_completions( view, commands.symbol_dict[symbol_type] )
def update_cache(view): projects_cache = cache.projects_cache file_key, project_key = cache.get_keys(view) # if there is no project_key set the project_key as the file_key # so that we can cache on a per file basis if not project_key: project_key = file_key if project_key in projects_cache: _cache = projects_cache[project_key] else: _cache = {} for symbol in commands.symbol_dict: if '_command' in symbol: continue if symbol not in _cache: _cache[symbol] = {} _completions = completions.get_view_completions(view, symbol) if _completions: _cache[symbol][file_key] = _completions elif not _cache[symbol]: _cache.pop(symbol, None) if _cache: projects_cache[project_key] = _cache cache.save_cache()
def returnSymbolCompletions(view, symbol_type): projects_cache = cache.projects_cache if not symbol_type in commands.symbol_dict: return [] file_key, project_key = cache.get_keys(view, return_both=True) completion_list = [] for file in project.get_external_files(): if file in projects_cache: completion_list = completion_list + projects_cache[file][ symbol_type][file] if file_key in projects_cache: if symbol_type in projects_cache[file_key]: completion_list = completion_list + projects_cache[file_key][ symbol_type][file_key] if project_key in projects_cache: if symbol_type in projects_cache[project_key]: for file in projects_cache[project_key][symbol_type]: completion_list = completion_list + projects_cache[ project_key][symbol_type][file] if completion_list: return [tuple(completions) for completions in completion_list] else: # we have no cache so just return whats in the current view return get_view_completions(view, commands.symbol_dict[symbol_type])