def GetClangdExecutableAndResourceDir(user_options): """Return the Clangd binary from the path specified in the 'clangd_binary_path' option. Let the binary find its resource directory in that case. If no binary is found or if it's out-of-date, return nothing. If 'clangd_binary_path' is empty, return the third-party Clangd and its resource directory if the user downloaded it and if it's up to date. Otherwise, return nothing.""" clangd = user_options['clangd_binary_path'] resource_dir = None if clangd: clangd = FindExecutable(ExpandVariablesInPath(clangd)) if not clangd: LOGGER.error('No Clangd executable found at %s', user_options['clangd_binary_path']) return None, None if not CheckClangdVersion(clangd): LOGGER.error('Clangd at %s is out-of-date', clangd) return None, None # Try looking for the pre-built binary. else: third_party_clangd = GetThirdPartyClangd() if not third_party_clangd: return None, None clangd = third_party_clangd resource_dir = CLANG_RESOURCE_DIR LOGGER.info('Using Clangd from %s', clangd) return clangd, resource_dir
def _GetRustSrcPath( self ): """ Attempt to read user option for rust_src_path. Fallback to environment variable if it's not provided. Finally try to be smart and figure out the path assuming the user set up rust by the means of rustup. """ rust_src_path = ( self.user_options[ 'rust_src_path' ] or os.environ.get( 'RUST_SRC_PATH' ) ) if rust_src_path: return ExpandVariablesInPath( rust_src_path ) # Try to figure out the src path using rustup rustc_executable = FindExecutable( 'rustc' ) if not rustc_executable: return None rust_sysroot = _GetRustSysroot( rustc_executable ) rust_src_path = p.join( rust_sysroot, 'lib', 'rustlib', 'src', 'rust', 'src' ) return rust_src_path if p.isdir( rust_src_path ) else None
def __init__(self, user_options): super().__init__(user_options) self._solution_for_file = {} self._completer_per_solution = {} self._diagnostic_store = None self._solution_state_lock = threading.Lock() self.SetSignatureHelpTriggers(['(', ',']) if os.path.isfile(user_options['roslyn_binary_path']): self._roslyn_path = user_options['roslyn_binary_path'] else: self._roslyn_path = PATH_TO_OMNISHARP_ROSLYN_BINARY self._mono_path = FindExecutableWithFallback( user_options['mono_binary_path'], FindExecutable('mono'))
def ShouldEnableCsCompleter(user_options): user_roslyn_path = user_options['roslyn_binary_path'] if user_roslyn_path and not os.path.isfile(user_roslyn_path): LOGGER.error('No omnisharp-roslyn executable at %s', user_roslyn_path) # We should trust the user who specifically asked for a custom path. return False if os.path.isfile(user_roslyn_path): roslyn = user_roslyn_path else: roslyn = PATH_TO_OMNISHARP_ROSLYN_BINARY mono = FindExecutableWithFallback(user_options['mono_binary_path'], FindExecutable('mono')) if roslyn and (mono or utils.OnWindows()): return True LOGGER.info('No mono executable at %s', mono) return False
def _EnvironmentForInterpreterPath( self, interpreter_path ): if interpreter_path: resolved_interpreter_path = FindExecutable( ExpandVariablesInPath( interpreter_path ) ) if not resolved_interpreter_path: raise RuntimeError( 'Cannot find Python interpreter path {}.'.format( interpreter_path ) ) interpreter_path = os.path.normpath( resolved_interpreter_path ) try: return self._environment_for_interpreter_path[ interpreter_path ] except KeyError: pass # Assume paths specified by the user are safe. environment = ( jedi.get_default_environment() if not interpreter_path else jedi.create_environment( interpreter_path, safe = False ) ) self._environment_for_interpreter_path[ interpreter_path ] = environment return environment