pub struct FunctionFeatures {Show 15 fields
pub name: String,
pub kind: String,
pub start_line: usize,
pub end_line: usize,
pub start_column: usize,
pub end_column: usize,
pub start_byte: usize,
pub end_byte: usize,
pub parent: Option<usize>,
pub token_count: usize,
pub node_count: usize,
pub depth: usize,
pub exact_hashes: BTreeMap<Level, Hash128>,
pub features: BTreeMap<Level, LevelFeatures>,
pub tokens: Option<BTreeMap<Level, Vec<String>>>,
}Expand description
Features of one function unit.
Fields§
§name: StringFunction name for display; <anonymous> for lambdas and blocks. Never used for matching.
kind: StringTree-sitter node kind of the function.
start_line: usize1-based, inclusive.
end_line: usizeLast line of the function (1-based, inclusive).
start_column: usize1-based byte columns of the first and last character.
end_column: usize1-based byte column of the last character.
start_byte: usizeByte range in the file (0-based, end exclusive).
end_byte: usizeEnd of the byte range in the file (exclusive).
parent: Option<usize>Index of the enclosing function in the same file.
token_count: usizeNumber of N0 tokens.
node_count: usizeNumber of named AST nodes (comments excluded).
depth: usizeDepth of the syntax tree of the function.
exact_hashes: BTreeMap<Level, Hash128>Hash of the whole function at every normalization level.
features: BTreeMap<Level, LevelFeatures>Present only for functions with at least min_tokens tokens.
tokens: Option<BTreeMap<Level, Vec<String>>>Normalized tokens at every level, kept only with Config::keep_tokens.
Implementations§
Source§impl FunctionFeatures
impl FunctionFeatures
Sourcepub fn is_indexed(&self) -> bool
pub fn is_indexed(&self) -> bool
Whether this function is large enough to carry fingerprints.
§Examples
use pelicode_core::{Config, Language, extract_source};
let source = b"def area(w, h):\n return w * h\n";
let small = Config { min_tokens: 100, ..Config::default() };
assert!(!extract_source(Language::Python, source, &small).unwrap()[0].is_indexed());
let all = Config { min_tokens: 0, ..Config::default() };
assert!(extract_source(Language::Python, source, &all).unwrap()[0].is_indexed());Trait Implementations§
Source§impl Clone for FunctionFeatures
impl Clone for FunctionFeatures
Source§impl Debug for FunctionFeatures
impl Debug for FunctionFeatures
Auto Trait Implementations§
impl Freeze for FunctionFeatures
impl RefUnwindSafe for FunctionFeatures
impl Send for FunctionFeatures
impl Sync for FunctionFeatures
impl Unpin for FunctionFeatures
impl UnsafeUnpin for FunctionFeatures
impl UnwindSafe for FunctionFeatures
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more