pub struct TclCode { /* private fields */ }Expand description
Per-language code type tag for Tcl; carries no data.
Trait Implementations§
Source§impl Alterator for TclCode
impl Alterator for TclCode
Source§fn alterate(
node: &Node<'_>,
code: &[u8],
span: bool,
field_name: Option<&'static str>,
children: Vec<AstNode>,
) -> AstNode
fn alterate( node: &Node<'_>, code: &[u8], span: bool, field_name: Option<&'static str>, children: Vec<AstNode>, ) -> AstNode
Creates a new
AST node containing the code associated to the node,
its span, the grammar field name through which the parent reaches
it (if any), and its children. Read moreSource§fn keeps_children<'a>(
node: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
) -> bool
fn keeps_children<'a>( node: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, ) -> bool
Whether
node must keep its children even though
Self::alterate would flatten it into a verbatim leaf. Read moreSource§fn get_text_span(
node: &Node<'_>,
code: &[u8],
span: bool,
text: bool,
) -> (String, Option<Span>)
fn get_text_span( node: &Node<'_>, code: &[u8], span: bool, text: bool, ) -> (String, Option<Span>)
Gets the code as text and the span associated to a node.
Source§fn get_default(
node: &Node<'_>,
code: &[u8],
span: bool,
field_name: Option<&'static str>,
children: Vec<AstNode>,
) -> AstNode
fn get_default( node: &Node<'_>, code: &[u8], span: bool, field_name: Option<&'static str>, children: Vec<AstNode>, ) -> AstNode
Gets a default
AST node containing the code associated to the
node, its span, its grammar field name (if any), and its
children.Source§fn flatten_verbatim(
node: &Node<'_>,
code: &[u8],
span: bool,
field_name: Option<&'static str>,
) -> AstNode
fn flatten_verbatim( node: &Node<'_>, code: &[u8], span: bool, field_name: Option<&'static str>, ) -> AstNode
Renders
node as one leaf holding its whole source text, children
dropped: what every string literal — the StringLit row’s
owners, and the character literals the dump treats alike — becomes
in the dump (#699), so a raw string’s delimiter and
string_content children, a template’s ${…} substitutions and
a heredoc’s fragments all collapse into the flat text payload.Source§impl Getter for TclCode
impl Getter for TclCode
Source§fn get_space_kind(node: &Node<'_>) -> SpaceKind
fn get_space_kind(node: &Node<'_>) -> SpaceKind
The kind of space
node opens by its kind alone, or
SpaceKind::Unknown when it opens none: the byte-less spelling
of get_space_kind_with_code,
that classifier asked with no bytes and a known-empty chain. The
walk calls the _with_code one. Required, as
Checker::is_func_space is and for its reason (#1863): a
language emits it through impl_byte_less_space_kind!, which
carries the build-time pin, or writes it by hand.Source§fn get_space_kind_with_code<'a>(
node: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
) -> SpaceKind
fn get_space_kind_with_code<'a>( node: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, ) -> SpaceKind
The kind of space
node opens, as the walk asks it: with the
source bytes and the chain it descended through. Required: every
language answers from its role table’s opens_space fold, and
the byte-less get_space_kind derives
from this, never the reverse (#1863). Read moreSource§fn get_keyword_role<'a>(
node: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
) -> TokenRole
fn get_keyword_role<'a>( node: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, ) -> TokenRole
Classifies
node when it is a keyword the language’s role rows
declare — a Modifier, DeclKeyword or Primitive — and
answers TokenRole::Unknown for every other node (#1693). Read moreSource§fn get_paying_role<'a>(
node: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
) -> TokenRole
fn get_paying_role<'a>( node: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, ) -> TokenRole
The Halstead role of a node some paying-construct row of
crate::roles declares — the paying token of a Comparison,
ShortCircuit, EagerLogical, Ternary, CaseArm, Guard or
NullSafe row — and TokenRole::Unknown for every other node
(#1694, #1695). Read after get_keyword_role
and before the byte-less get_op_type on
every path the walk takes. Read moreSource§fn get_op_type<'a>(node: &Node<'a>, ancestors: Ancestors<'a, '_>) -> TokenRole
fn get_op_type<'a>(node: &Node<'a>, ancestors: Ancestors<'a, '_>) -> TokenRole
Classifies
node as a Halstead operator, operand, or neither. Read moreSource§fn get_op_type_with_code<'a>(
node: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
) -> TokenRole
fn get_op_type_with_code<'a>( node: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, ) -> TokenRole
Source-aware variant of
get_op_type, and the spelling the
walk calls. The default forwards to the crate-private
keyword_or_op_type, which reads get_keyword_role, then
get_paying_role, and falls
back to get_op_type; languages whose Halstead operand
classification depends on token text override this and end in
the same call. Kotlin uses
it to recover the variable in a short-form string template
("Hi $name"), which the grammar emits as bare string_content
tokens with no structured interpolation node — the distinction
between an interpolated $name and a literal $5 is only
visible in the source bytes (#454).Source§fn get_operator_id_as_str(id: u16) -> &'static str
fn get_operator_id_as_str(id: u16) -> &'static str
The grammar’s name for the operator kind
id, used to render a
Halstead operator; empty for languages that do not report them.Source§fn get_func_name<'a, 'tree>(
node: &Node<'tree>,
code: &'a [u8],
ancestors: Ancestors<'tree, '_>,
) -> Option<&'a str>
fn get_func_name<'a, 'tree>( node: &Node<'tree>, code: &'a [u8], ancestors: Ancestors<'tree, '_>, ) -> Option<&'a str>
Names the function
node declares. Defaults to
get_func_space_name.Source§fn get_func_space_name<'a, 'tree>(
node: &Node<'tree>,
code: &'a [u8],
ancestors: Ancestors<'tree, '_>,
) -> Option<&'a str>
fn get_func_space_name<'a, 'tree>( node: &Node<'tree>, code: &'a [u8], ancestors: Ancestors<'tree, '_>, ) -> Option<&'a str>
Names the space
node opens. Read moreSource§fn get_operator_spelling<'a>(
_node: &Node<'a>,
_ancestors: Ancestors<'a, '_>,
) -> Option<&'static str>
fn get_operator_spelling<'a>( _node: &Node<'a>, _ancestors: Ancestors<'a, '_>, ) -> Option<&'static str>
The fixed spelling an operator
node is keyed under in place of
its kind id, for a token whose kind the grammar shares with a
different operator; None keys it by kind. A generic list’s <
is the case (#1559): it has the comparison’s kind but is keyed as
the "<>" pair, as (), [] and {} are. Consulted only for a
node get_op_type_with_code calls
an operator.Source§fn get_operand_id<'a>(
node: &Node<'a>,
code: &'a [u8],
_ancestors: Ancestors<'a, '_>,
) -> &'a [u8] ⓘ
fn get_operand_id<'a>( node: &Node<'a>, code: &'a [u8], _ancestors: Ancestors<'a, '_>, ) -> &'a [u8] ⓘ
Returns the source-byte slice used to key a Halstead operand.
The default keys on the operand node’s full byte range. Kotlin
overrides this to narrow a short-interpolation name token
(
$name) to its leading identifier prefix, because the grammar
glues trailing inter-segment text onto the name token
("$a $b" → "a "); keying the raw bytes would record a
distinct "a " operand and break parity with the long ${a}
form (#454).Source§fn string_operand_type(node: &Node<'_>, interp_kinds: &[u16]) -> TokenRole
fn string_operand_type(node: &Node<'_>, interp_kinds: &[u16]) -> TokenRole
Classifies a string-literal
node as a single Halstead
operand, unless it wraps an interpolation child drawn from
interp_kinds — in which case the wrapper yields
TokenRole::Unknown because the inner expressions are
walked and counted separately. Counting the wrapper too would
double-count their contribution to N2. Read moreSource§fn is_subsumed_braced_word<'a>(
node: &Node<'a>,
ancestors: Ancestors<'a, '_>,
kinds: &BracedWordKinds,
) -> bool
fn is_subsumed_braced_word<'a>( node: &Node<'a>, ancestors: Ancestors<'a, '_>, kinds: &BracedWordKinds, ) -> bool
Whether
node is a fragment of a Tcl-family braced word rather
than a token of its own, and so contributes no operand (#1354). Read moreSource§fn generic_argument_command<'tree, 'chain>(
word: &Node<'tree>,
ancestors: Ancestors<'tree, 'chain>,
kinds: &BracedWordKinds,
) -> Option<(Node<'tree>, Ancestors<'tree, 'chain>)>
fn generic_argument_command<'tree, 'chain>( word: &Node<'tree>, ancestors: Ancestors<'tree, 'chain>, kinds: &BracedWordKinds, ) -> Option<(Node<'tree>, Ancestors<'tree, 'chain>)>
The generic
command node word is an argument of, paired with
that command’s own ancestry — or None when word instead
fills a slot of a construct the grammar models, and so is a
script by construction. Read moreSource§fn is_value_braced_word<'a>(
word: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
kinds: &BracedWordKinds,
) -> bool
fn is_value_braced_word<'a>( word: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, kinds: &BracedWordKinds, ) -> bool
Whether a braced script-kind word is really a plain value —
the literal
{a b} of lappend x {a b} rather than the block
of eval {…} (#1318). Read moreSource§fn is_braced_script_word<'a>(
node: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
kinds: &BracedWordKinds,
) -> bool
fn is_braced_script_word<'a>( node: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, kinds: &BracedWordKinds, ) -> bool
Whether
node is a Tcl-family braced script — a proc or if
body, an iRules when handler — rather than a braced literal
(#1381). Read moreSource§fn is_braced_literal_slot<'a>(
word: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
kinds: &BracedWordKinds,
) -> bool
fn is_braced_literal_slot<'a>( word: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, kinds: &BracedWordKinds, ) -> bool
Whether
word, a braced word is_value_braced_word calls a
script, fills a slot whose documented syntax takes a value. Read moreSource§fn is_switch_arm_body(word: &Node<'_>, command: &Node<'_>) -> bool
fn is_switch_arm_body(word: &Node<'_>, command: &Node<'_>) -> bool
Whether
word, an argument of a switch arm command
(is_switch_arm), sits in a body position rather than a
pattern position. Read moreSource§fn command_leading_word<'c>(
command: &Node<'_>,
code: &'c [u8],
kinds: &BracedWordKinds,
) -> Option<&'c str>
fn command_leading_word<'c>( command: &Node<'_>, code: &'c [u8], kinds: &BracedWordKinds, ) -> Option<&'c str>
A command’s leading word, when it is a statically resolvable
simple_word. Read moreAuto Trait Implementations§
impl Forget for TclCode
impl Freeze for TclCode
impl Move for TclCode
impl RefUnwindSafe for TclCode
impl Send for TclCode
impl Sync for TclCode
impl Unpin for TclCode
impl UnsafeUnpin for TclCode
impl UnwindSafe for TclCode
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