1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2026 Kirky.XðŸŒ
// SPDX-License-Identifier: MIT
//! Shared helpers used by all language extractors.
use Node;
use crateExtractResult;
/// Returns the UTF-8 text slice of `node` within `source`, or `None` when the
/// node's bytes are not valid UTF-8.
///
/// Shared by all language extractors — previously each of the 20 extractor
/// files carried a byte-identical private copy of this function.
pub
/// Returns a de-duplicated qualified name, appending `#L{line}` if `qn` has
/// already been registered in `result.seen_qns`.
///
/// Previously each extractor had its own O(N) implementation that scanned
/// `result.nodes` linearly on every call, making total extraction O(N²). This
/// shared version consults the O(1) `seen_qns` HashSet maintained by
/// [`ExtractResult::push_node`].
///
/// # Contract
///
/// The caller must push the resulting node via
/// [`ExtractResult::push_node`] (not `result.nodes.push(...))`), so that the
/// returned FQN is registered for future de-duplication.