def AddIdentifiersFromTagFiles(self): tag_files = vim.eval('tagfiles()') current_working_directory = os.getcwd() absolute_paths_to_tag_files = ycm_core.StringVec() for tag_file in tag_files: absolute_tag_file = os.path.join(current_working_directory, tag_file) try: current_mtime = os.path.getmtime(absolute_tag_file) except: continue last_mtime = self.tags_file_last_mtime[absolute_tag_file] # We don't want to repeatedly process the same file over and over; we only # process if it's changed since the last time we looked at it if current_mtime <= last_mtime: continue self.tags_file_last_mtime[absolute_tag_file] = current_mtime absolute_paths_to_tag_files.append(absolute_tag_file) if not absolute_paths_to_tag_files: return common_filetype = self.GetFiletypeOrCommonGroup() if common_filetype != COMMON_FILETYPE: common_filetype = "" self.completer.AddIdentifiersToDatabaseFromTagFilesAsync( absolute_paths_to_tag_files, common_filetype)
def _IdentifiersFromBuffer(text, filetype, collect_from_comments_and_strings): if not collect_from_comments_and_strings: text = identifier_utils.RemoveIdentifierFreeText(text) idents = identifier_utils.ExtractIdentifiersFromText(text, filetype) vector = ycm_core.StringVec() for ident in idents: vector.append(ToUtf8IfNeeded(ident)) return vector
def AddIdentifiersFromSyntax(self, keyword_list, filetypes): keyword_vector = ycm_core.StringVec() for keyword in keyword_list: keyword_vector.append(ToUtf8IfNeeded(keyword)) filepath = SYNTAX_FILENAME + filetypes[0] self._completer.AddIdentifiersToDatabase(keyword_vector, ToUtf8IfNeeded(filetypes[0]), ToUtf8IfNeeded(filepath))
def AddIdentifier(self, identifier): filetype = self.GetFiletypeOrCommonGroup() filepath = vim.eval("expand('%:p')") if not filetype or not filepath or not identifier: return vector = ycm_core.StringVec() vector.append(identifier) self.completer.AddIdentifiersToDatabase(vector, filetype, filepath)
def AddIdentifier(self, identifier): filetype = vim.eval("&filetype") filepath = vim.eval("expand('%:p')") if not filetype or not filepath or not identifier: return vector = ycm_core.StringVec() vector.append(identifier) self.completer.AddCandidatesToDatabase(vector, filetype, filepath)
def AddIdentifier( self, identifier, request_data ): filetype = request_data[ 'filetypes' ][ 0 ] filepath = request_data[ 'filepath' ] if not filetype or not filepath or not identifier: return vector = ycm_core.StringVec() vector.append( ToUtf8IfNeeded( identifier ) ) self._logger.info( 'Adding ONE buffer identifier for file: %s', filepath ) self._completer.AddIdentifiersToDatabase( vector, ToUtf8IfNeeded( filetype ), ToUtf8IfNeeded( filepath ) )
def AddIdentifiersFromSyntax(self): filetype = vim.eval("&filetype") if filetype in self.filetypes_with_keywords_loaded: return self.filetypes_with_keywords_loaded.add(filetype) keyword_set = syntax_parse.SyntaxKeywordsForCurrentBuffer() keywords = ycm_core.StringVec() for keyword in keyword_set: keywords.append(keyword) filepath = SYNTAX_FILENAME + filetype self.completer.AddIdentifiersToDatabase(keywords, filetype, filepath)
def AddIdentifiersFromTagFiles(self, tag_files): absolute_paths_to_tag_files = ycm_core.StringVec() for tag_file in tag_files: try: current_mtime = os.path.getmtime(tag_file) except: continue last_mtime = self._tags_file_last_mtime[tag_file] # We don't want to repeatedly process the same file over and over; we only # process if it's changed since the last time we looked at it if current_mtime <= last_mtime: continue self._tags_file_last_mtime[tag_file] = current_mtime absolute_paths_to_tag_files.append(ToUtf8IfNeeded(tag_file)) if not absolute_paths_to_tag_files: return self._completer.AddIdentifiersToDatabaseFromTagFiles( absolute_paths_to_tag_files)
def _SanitizeFlags(flags): """Drops unsafe flags. Currently these are only -arch flags; they tend to crash libclang.""" sanitized_flags = [] saw_arch = False for i, flag in enumerate(flags): if flag == '-arch': saw_arch = True continue elif flag.startswith('-arch'): continue elif saw_arch: saw_arch = False continue sanitized_flags.append(flag) vector = ycm_core.StringVec() for flag in sanitized_flags: vector.append(flag) return vector