pub fn validate(path: impl AsRef<Path>, content: &str) -> Option<Error> {
    let path = path.as_ref();

    // Get file extension
    let ext = match path.extension().and_then(|e| e.to_str()) {
        Some(ext) => ext,
        None => return Some(Error::Extension),
    };

    // Get language for the extension
    // If we don't support the language, consider it valid
    let language = extension(ext)?;

    // Initialize parser
    let mut parser = Parser::new();
    if let Err(e) = parser.set_language(&language) {
        return Some(Error::Language(e));
    }

    // Try parsing the content
    let Some(tree) = parser.parse(content, None) else {
        return Some(Error::Parse {
            file_path: path.display().to_string(),
            extension: ext.to_string(),
        });
    };

    // Find syntax errors in the tree
    let root_node = tree.root_node();
    (root_node.has_error() || root_node.is_error()).then(|| Error::Parse {
        file_path: path.display().to_string(),
        extension: ext.to_string(),
    })
}
Validates source code content using Tree-sitter parsers.

This function attempts to parse the provided content using a Tree-sitter
parser appropriate for the file's extension. It checks for syntax errors in
the parsed abstract syntax tree.

# Arguments
* `path` - The path to the file being validated (used to determine language)
* `content` - The source code content to validate

# Returns
* `Ok(())` - If the content is valid for the given language
* `Err(String)` - If validation fails, contains error description

# Note
Files with unsupported extensions are considered valid and will return
Ok(()). Files with no extension will return an error.
crates/forge_services/src/tool_services/syn/validate.rs