Skip to main content

Crate code_split_plugin_api

Crate code_split_plugin_api 

Source
Expand description

§code-split-plugin-api

The contract everything in Code Split builds on: a generic property-graph model plus the LanguagePlugin trait. This crate is the foundation — it depends on nothing else from Code Split and re-exports nothing. Every other crate (graph operations, complexity, language plugins, viewer, cli) depends on this.

§Model

Analysis produces a Graph of **Node**s connected by **Edge**s. A node is anything we analyze: today a source file (kind == "file"), tomorrow a folder, module, function, variable or line — with no model change. kind is a free-form String (the plugin’s own vocabulary); the core never interprets it, it only stores and projects.

Both nodes and edges carry free-form Attributes (string key → scalar AttrValue). There is no fixed, file/language-specific field set: the plugin chooses keys (path, loc, visibility, version, or language-specific ones), the orchestrator adds computed keys (metrics, cycle), and the core reads only the keys it understands. Each level describes its keys with an AttributeSpec dictionary (type + label/hint), so the UI knows what each key means and what it can do with it.

§Responsibilities

A LanguagePlugin is a pure parser: it turns a workspace into nodes + edges at a requested level (by name; see Level). It does not compute metrics — complexity / cycles / Henry-Kafura / stats are filled in centrally, for all languages, by the orchestrator. The plugin also describes its edge kinds (EdgeKindSpec) and attribute keys (AttributeSpec), so the core scores, draws and labels unknown kinds/keys without hardcoding their names.

Re-exports§

pub use attrs::AttrValue;
pub use attrs::Attributes;
pub use attrs::ValueType;
pub use edge::Edge;
pub use graph::Graph;
pub use level::AttributeGroup;
pub use level::AttributeSpec;
pub use level::CycleKindSpec;
pub use level::EdgeKindSpec;
pub use level::Level;
pub use level::NodeKindSpec;
pub use level::Thresholds;
pub use node::Node;
pub use node::NodeId;
pub use plugin::LanguagePlugin;
pub use plugin::Options;
pub use plugin::PluginInput;
pub use plugin::Preset;

Modules§

attrs
Free-form attributes for nodes and edges — a string-keyed map of scalar values — plus the value-type tag used by the attribute dictionaries.
edge
A Edge — a directed edge between two nodes (an import, a call, a containment, …). The kind is the plugin’s own vocabulary; its semantics (flow vs structural, label, hint) come from a matching EdgeKindSpec.
graph
Graph — what a plugin’s analyze returns: pure structure, nodes + edges, and nothing computed.
level
Level descriptors + the semantics dictionaries that let the core handle unknown kinds/keys without hardcoding their names, and let the UI render any language/metric set purely from data: edge kinds (EdgeKindSpec), node/edge attributes (AttributeSpec, grouped via AttributeGroup), node kinds (NodeKindSpec) and cycle kinds (CycleKindSpec).
log
Shared stderr progress/timing log.
node
The Node — anything we analyze. Today a source file (kind == "file"), later a folder / module / function / variable / line, with no model change.
plugin
The LanguagePlugin trait + Options + Preset.

Functions§

default_cycle_kinds
The generic cycle-kind vocabulary (mutual / chain).
default_node_kinds
The generic node-kind palette every file-based plugin seeds its level with: file (a project source unit, blue) and external (a third-party library, amber, flagged external). A plugin may recolor or add kinds.