MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / extract_superclass

Method extract_superclass

src/extraction/java_extractor.rs:1055–1093  ·  view source on GitHub ↗

Extract superclass (extends) from a `class_declaration`.

(state: &mut ExtractionState, node: TsNode<'_>, class_id: &str)

Source from the content-addressed store, hash-verified

1053
1054 /// Extract superclass (extends) from a `class_declaration`.
1055 fn extract_superclass(state: &mut ExtractionState, node: TsNode<'_>, class_id: &str) {
1056 // In tree-sitter-java, `superclass` is a named child of class_declaration.
1057 let mut cursor = node.walk();
1058 if cursor.goto_first_child() {
1059 loop {
1060 let child = cursor.node();
1061 if child.kind() == "superclass" {
1062 // The superclass node contains the type identifier.
1063 let mut inner_cursor = child.walk();
1064 if inner_cursor.goto_first_child() {
1065 loop {
1066 let inner_child = inner_cursor.node();
1067 if inner_child.is_named()
1068 && inner_child.kind() != "extends"
1069 && inner_child.kind() != "superclass"
1070 {
1071 let type_name = state.node_text(inner_child);
1072 state.unresolved_refs.push(UnresolvedRef {
1073 from_node_id: class_id.to_string(),
1074 reference_name: type_name,
1075 reference_kind: EdgeKind::Extends,
1076 line: inner_child.start_position().row as u32,
1077 column: inner_child.start_position().column as u32,
1078 file_path: state.file_path.clone(),
1079 });
1080 break;
1081 }
1082 if !inner_cursor.goto_next_sibling() {
1083 break;
1084 }
1085 }
1086 }
1087 }
1088 if !cursor.goto_next_sibling() {
1089 break;
1090 }
1091 }
1092 }
1093 }
1094
1095 /// Extract `super_interfaces` (implements) from a `class_declaration`.
1096 fn extract_super_interfaces(state: &mut ExtractionState, node: TsNode<'_>, class_id: &str) {

Callers

nothing calls this directly

Calls 3

kindMethod · 0.80
pushMethod · 0.80
node_textMethod · 0.45

Tested by

no test coverage detected