mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: some basic extraction of function names (with locations!)
This commit is contained in:
@@ -1,25 +1,23 @@
|
||||
// generated by {{generator}}
|
||||
|
||||
use crate::trap::{TrapLabel, TrapEntry, quoted};
|
||||
use crate::trap::{TrapLabel, TrapId, TrapEntry, quoted};
|
||||
use std::io::Write;
|
||||
|
||||
{{#classes}}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct {{name}} {
|
||||
pub key: Option<String>,
|
||||
pub id: TrapId,
|
||||
{{#fields}}
|
||||
pub {{field_name}}: {{type}},
|
||||
{{/fields}}
|
||||
}
|
||||
|
||||
impl TrapEntry for {{name}} {
|
||||
type Label = TrapLabel;
|
||||
fn extract_id(&mut self) -> TrapId {
|
||||
std::mem::replace(&mut self.id, TrapId::Star)
|
||||
}
|
||||
|
||||
fn prefix() -> &'static str { "{{name}}_" }
|
||||
|
||||
fn key(&self) -> Option<&str> { self.key.as_ref().map(String::as_str) }
|
||||
|
||||
fn emit<W: Write>(&self, id: &Self::Label, out: &mut W) -> std::io::Result<()> {
|
||||
fn emit<W: Write>(self, id: TrapLabel, out: &mut W) -> std::io::Result<()> {
|
||||
write!(out, "{{table_name}}({id}{{#single_fields}}, {}{{/single_fields}})\n"{{#single_fields}}, {{#emitter}}self.{{field_name}}{{/emitter}}{{/single_fields}})?;
|
||||
{{#fields}}
|
||||
{{#is_predicate}}
|
||||
@@ -50,5 +48,4 @@ impl TrapEntry for {{name}} {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
{{/classes}}
|
||||
|
||||
Reference in New Issue
Block a user