pub struct SemanticUnit {
pub grammar: &'static str,
pub name: String,
pub start: Location,
pub end: Location,
pub range: [u32; 2],
pub token_count: u32,
pub text: String,
pub test: bool,
}Expand description
One function of a source, ready to embed.
Fields§
§grammar: &'static strGrammar of the extractor that found the function (oxc, rust, …).
Mutual best matches are taken per grammar, and z-scores against the
functions of one grammar.
name: StringDeclared or inferred name (<arrow> / <anonymous> when none).
start: Location§end: Location§range: [u32; 2]Inclusive detection-token index range inside the owning source.
token_count: u32Detection tokens covered by the function.
text: StringThe text given to the embedder: the function’s code without comments.
test: boolA test rather than code: --compare measures the two apart and
pairs a test only with a test. --semantic does not look at it.
Implementations§
Source§impl SemanticUnit
impl SemanticUnit
Sourcepub fn build(
grammar: &'static str,
name: String,
start: Location,
end: Location,
text: String,
spans: &[(Location, Location)],
) -> Option<Self>
pub fn build( grammar: &'static str, name: String, start: Location, end: Location, text: String, spans: &[(Location, Location)], ) -> Option<Self>
Attach the token range from the owning source’s token spans. Returns
None when no detection token lies inside the function (a body of
comments or type declarations only).
Trait Implementations§
Source§impl Clone for SemanticUnit
impl Clone for SemanticUnit
Source§impl Debug for SemanticUnit
impl Debug for SemanticUnit
Source§impl PartialEq for SemanticUnit
impl PartialEq for SemanticUnit
impl StructuralPartialEq for SemanticUnit
Auto Trait Implementations§
impl Freeze for SemanticUnit
impl RefUnwindSafe for SemanticUnit
impl Send for SemanticUnit
impl Sync for SemanticUnit
impl Unpin for SemanticUnit
impl UnsafeUnpin for SemanticUnit
impl UnwindSafe for SemanticUnit
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
Converts
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> ⓘ
Converts
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