kkharji/xbase

[server] support getting compile commands for header files

github-actions opened this issue · 1 comments

/// TODO(server): support getting compile commands for header files

#[cfg(feature = "server")]
impl State {
    /// Get [`CompilationDatabase`] for a .compile file path.
    /// TODO(server): support getting compile commands for header files
    pub fn compile_commands(&mut self, compile_filepath: &Path) -> Result<&XCCompilationDatabase> {
        tracing::debug!("Getting compile commands");
        if self.compile_commands.contains_key(compile_filepath) {
            tracing::debug!("Using Cached compile database");
            self.compile_commands.get(compile_filepath)
        } else {
            tracing::debug!("Reading from {compile_filepath:?}");
            XCCompilationDatabase::try_from_filepath(compile_filepath)?
                .pipe(|cmds| self.compile_commands.insert(compile_filepath.into(), cmds))
                .pipe(|_| self.compile_commands.get(compile_filepath))
        }