image.vision\aoci\aoci_symbol.mbt
94.1% · 16 / 17 points · 90 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # AOCI 符号坐标类型 AOCI Symbol Coordinate Types - 3
/// - 4
/// 符号在代码库中的位置和元信息 - 5
/// 符号位置与元数据 Symbol position - 6
// AOCI 符号语义索引 — 符号坐标类型 - 7
// SymbolCoord: 符号在代码库中的位置和元信息 - 8
- 9
///| - 10
/// `#non_exhaustive` 表示未来可能添加新构造器 - 11
#derive(Eq, @debug.Debug) - 12
#non_exhaustive - 13
pub(all) enum SymbolKind { - 14
Function - 15
Method - 16
Type - 17
TypeAlias - 18
Enum - 19
Struct - 20
} - 21
- 22
///| - 23
pub extend SymbolKind with Eq::{not_equal, equal} - 24
- 25
///| - 26
pub extend SymbolKind with @debug.Debug::{to_repr} - 27
- 28
///| - 29
pub fn SymbolKind::to_string(self : SymbolKind) -> String { - 30●
match self { - 31●
Function => "Function" - 32●
Method => "Method" - 33●
Type => "Type" - 34○
TypeAlias => "TypeAlias" - 35●
Enum => "Enum" - 36●
Struct => "Struct" - 37
} - 38
} - 39
- 40
///| - 41
#derive(Eq, @debug.Debug) - 42
pub(all) struct SymbolCoord { - 43
pkg : String - 44
name : String - 45
kind : SymbolKind - 46
signature : String - 47
doc : String - 48
keywords : Array[String] - 49
} - 50
- 51
///| - 52
pub extend SymbolCoord with Eq::{not_equal, equal} - 53
- 54
///| - 55
pub extend SymbolCoord with @debug.Debug::{to_repr} - 56
- 57
///| - 58
pub fn SymbolCoord::make( - 59
pkg~ : String, - 60
name~ : String, - 61
kind~ : SymbolKind, - 62
signature~ : String = "", - 63
doc~ : String = "", - 64
keywords~ : Array[String] = [], - 65
) -> SymbolCoord { - 66●
{ pkg, name, kind, signature, doc, keywords, } - 67
} - 68
- 69
///| - 70
pub fn SymbolCoord::full_name(self : SymbolCoord) -> String { - 71●
self.pkg + "::" + self.name - 72
} - 73
- 74
///| - 75
pub fn SymbolCoord::has_keyword(self : SymbolCoord, keyword : String) -> Bool { - 76●
for kw in self.keywords { - 77●
if kw == keyword { - 78●
return true - 79
} - 80
} - 81
false - 82
} - 83
- 84
///| - 85
pub fn SymbolCoord::estimated_tokens(self : SymbolCoord) -> Int32 { - 86●
let name_tokens = self.name.length() / 4 + 1 - 87●
let sig_tokens = self.signature.length() / 4 + 1 - 88●
let doc_tokens = self.doc.length() / 4 + 1 - 89
name_tokens + sig_tokens + doc_tokens + 10 - 90
}