def _GeneratePathCompletionCandidates(path_dir): completions = [] unicode_path = ToUnicode(path_dir) for rel_path in ListDirectory(unicode_path): absolute_path = os.path.join(unicode_path, rel_path) path_type = GetPathTypeName(GetPathType(absolute_path)) completions.append(responses.BuildCompletionData(rel_path, path_type)) return completions
def _ListIncludes( self, path, is_framework ): includes = [] for name in ListDirectory( path ): if is_framework: if not name.endswith( '.framework' ): continue name = name[ : -len( '.framework' ) ] inc_path = os.path.join( path, name ) entry_type = GetPathType( inc_path, is_framework ) includes.append( IncludeEntry( name, entry_type ) ) return includes
def _LatestMacClangIncludes(toolchain): # We use the first toolchain which actually contains any versions, rather than # trying all of the toolchains and picking the highest. We favour Xcode over # CommandLineTools as using Xcode is more common. It might be possible to # extract this information from xcode-select, though xcode-select -p does not # point at the toolchain directly. candidates_dir = os.path.join(toolchain, 'usr', 'lib', 'clang') versions = ListDirectory(candidates_dir) for version in reversed(sorted(versions)): candidate_include = os.path.join(candidates_dir, version, 'include') if os.path.exists(candidate_include): return ['-isystem', candidate_include] return []
def GetCompiledHeadRegexForDirectory(self, directory): mtime = GetModificationTime(directory) try: head_regex = self._head_path_for_directory[directory] if mtime and mtime <= head_regex['mtime']: return head_regex['regex'] except KeyError: pass current_paths = ListDirectory(directory) current_paths_pattern = '|'.join( [re.escape(path) for path in current_paths]) head_pattern = ('(' + self._head_path_pattern + '|' + current_paths_pattern + ')$') head_regex = re.compile(head_pattern, re.VERBOSE) if mtime: self._head_path_for_directory[directory] = { 'regex': head_regex, 'mtime': mtime } return head_regex