Enum CloneLanguage
pub enum CloneLanguage {
Rust,
Python,
Java,
JavaScript,
TypeScript,
Tsx,
}Expand description
Tier-1 languages CodeLore clone-detects. Mirrors
crate::complexity::language::Tier1Language for extension recognition,
but splits TSX out as its own variant: tree-sitter-typescript ships a
dedicated LANGUAGE_TSX grammar for .tsx files (the plain
LANGUAGE_TYPESCRIPT grammar errors on JSX tags). Complexity rolls TSX
into TypeScript because codelore-rca’s Coleman MI scoring is the same
for both — clone fingerprinting can’t make that simplification because
it parses the raw AST and JSX tags become real node kinds.
Variants§
Implementations§
§impl CloneLanguage
impl CloneLanguage
pub fn from_path(path: &Path) -> Option<Self>
pub fn from_path(path: &Path) -> Option<Self>
Map a file extension to its CloneLanguage. Returns None for
non-Tier-1 files (we silently skip them during the clone pass).
pub fn language(self) -> Language
pub fn language(self) -> Language
Build a tree-sitter Language for this CloneLanguage. The grammars
are the same exact-pinned crates codelore-rca uses, exposed via
codelore-rca’s re-exports so we get parser-ABI compatibility.
pub fn skip_kinds(self) -> &'static [&'static str]
pub fn skip_kinds(self) -> &'static [&'static str]
Per-language set of node-kind names to skip when fingerprinting.
Identifiers, literals, and comments are normalized away — dropping
identifiers/literals is what makes the fingerprint Type 2-aware, and
dropping comments keeps a lone // TODO from defeating an otherwise
exact match. The names are tree-sitter kind() strings, not numeric
kind ids (kind ids are language-specific and can shift across grammar
revisions; names are stable). Only the top-level comment kinds appear
here: the walk prunes a comment’s whole subtree (see
Self::comment_kinds), so a /// doc comment’s inner marker/text
children are never reached and need no entry.
pub fn comment_kinds(self) -> &'static [&'static str]
pub fn comment_kinds(self) -> &'static [&'static str]
Per-language set of comment node-kind names. A subset of
Self::skip_kinds, but tracked separately because comments must be
fully transparent to the fingerprint: unlike identifiers and
literals (which are dropped from the emitted sequence yet still count
toward their parent’s arity so shape is preserved), a comment must
also not inflate its parent’s child count — otherwise a lone
// TODO between two statements would perturb the enclosing block’s
arity and defeat the match. Only the top-level comment kinds appear
here; Rust’s doc-marker/doc_comment children live inside a
line_comment/block_comment and never as a direct child of a code
node, so they need no arity handling.
pub fn function_kinds(self) -> &'static [&'static str]
pub fn function_kinds(self) -> &'static [&'static str]
Per-language set of node-kind names that mark a function boundary. Each match becomes a standalone clone-detection unit.
Trait Implementations§
§impl Clone for CloneLanguage
impl Clone for CloneLanguage
§fn clone(&self) -> CloneLanguage
fn clone(&self) -> CloneLanguage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CloneLanguage
§impl Debug for CloneLanguage
impl Debug for CloneLanguage
impl Eq for CloneLanguage
§impl Hash for CloneLanguage
impl Hash for CloneLanguage
§impl PartialEq for CloneLanguage
impl PartialEq for CloneLanguage
impl StructuralPartialEq for CloneLanguage
Auto Trait Implementations§
impl Freeze for CloneLanguage
impl RefUnwindSafe for CloneLanguage
impl Send for CloneLanguage
impl Sync for CloneLanguage
impl Unpin for CloneLanguage
impl UnsafeUnpin for CloneLanguage
impl UnwindSafe for CloneLanguage
Blanket Implementations§
impl<T> Allocation for T
impl<T> Allocation for T
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
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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