Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions crates/ecp-analyzer/src/post_process/schema_field_mirrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use crate::resolution::index::SymbolTable;
use ecp_core::analyzer::types::{LocalGraph, SchemaType};
use ecp_core::graph::{Edge, Node, NodeKind, RelType};
use ecp_core::pool::StringPool;
use ecp_core::uid;
use rustc_hash::FxHashMap;

/// Promote `RawSchemaField`s to `SchemaField` Nodes + emit `HasProperty`
Expand Down Expand Up @@ -96,23 +97,28 @@ pub fn emit_edges(
continue;
};

// UID format: stable across reindex; includes framework so
// cross-framework mirrors with same (owner, name) get distinct
// UIDs. Format mirrors File-node UID convention.
let uid_str = format!(
"SchemaField:{:?}:{}.{}:{}",
raw_sf.framework, owner_name, field_name, path_str
// UID: T1-5 canonical xxh3-64 over (kind, path, owner, name).
// owner_class is included so cross-framework mirrors with the same
// (owner, name) but different SchemaField nodes get distinct UIDs
// via path / owner disambiguation upstream.
let node_uid = uid::compute(
NodeKind::SchemaField,
&path_str,
Some(owner_name),
field_name,
);
let uid_ref = string_pool.add(&uid_str);
let name_ref = string_pool.add(field_name);
let owner_ref = string_pool.add(owner_name);
let sf_idx = nodes.len() as u32;
nodes.push(Node {
uid: uid_ref,
uid: node_uid,
name: name_ref,
file_idx,
kind: NodeKind::SchemaField,
span: raw_sf.span,
community_id: 0,
owner_class: owner_ref,
content_hash: 0,
});

// HasProperty: <Class> -> <SchemaField>. Non-heuristic
Expand Down
10 changes: 4 additions & 6 deletions crates/ecp-analyzer/src/protobuf/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use super::schema_extractors::{
};
use ecp_core::analyzer::provider::LanguageProvider;
use ecp_core::analyzer::types::{LocalGraph, RawSchemaField};
use ecp_core::pool::StringPool;
use std::path::Path;

pub struct ProtobufProvider;
Expand All @@ -28,8 +27,7 @@ impl LanguageProvider for ProtobufProvider {
let text = std::str::from_utf8(source)
.map_err(|e| anyhow::anyhow!("protobuf: UTF-8 decode error in {:?}: {}", path, e))?;

let mut pool = StringPool::new();
let fields = extract_proto_fields(text, &mut pool);
let fields = extract_proto_fields(text);
let schema_fields = (!fields.is_empty()).then(|| fields.into_boxed_slice());

Ok(LocalGraph {
Expand All @@ -48,7 +46,7 @@ impl LanguageProvider for ProtobufProvider {
/// - `depth`: brace nesting depth. A top-level `message` bumps depth to 1;
/// any nested `{` (including nested messages, oneofs, options) bumps it
/// further. Fields are only emitted when `depth == 1`.
fn extract_proto_fields(text: &str, pool: &mut StringPool) -> Vec<RawSchemaField> {
fn extract_proto_fields(text: &str) -> Vec<RawSchemaField> {
let mut out: Vec<RawSchemaField> = Vec::new();
let mut current_message: Option<String> = None;
let mut depth: u32 = 0;
Expand Down Expand Up @@ -102,9 +100,9 @@ fn extract_proto_fields(text: &str, pool: &mut StringPool) -> Vec<RawSchemaField
let type_class = classify_protobuf_type(type_token);
let span = (row, 0u32, row, line.len() as u32);
out.push(RawSchemaField {
name: pool.add(&field_name),
name: field_name.into_boxed_str(),
type_class,
owner_class: pool.add(owner),
owner_class: Box::from(owner.as_str()),
framework: PROTOBUF_FRAMEWORK,
span,
});
Expand Down
1 change: 1 addition & 0 deletions crates/ecp-analyzer/src/python/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use ecp_core::analyzer::types::{
RawRoute, RawTxScope,
};
use ecp_core::graph::{FileCategory, NodeKind};
use ecp_core::pool::StringPool;
use std::path::Path;
use streaming_iterator::StreamingIterator;
use tree_sitter::{Node, Query, QueryCursor};
Expand Down
Loading