linker

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package linker contains cross-file enrichers that run after detectors during `codeiq enrich`. Linkers walk the deterministic GraphBuilder snapshot and emit additional nodes/edges that span files (e.g. producer→consumer links via a shared topic, repository→entity QUERIES edges).

Mirrors src/main/java/io/github/randomcodespace/iq/analyzer/linker/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntityLinker

type EntityLinker struct{}

EntityLinker emits QUERIES edges from REPOSITORY nodes to the ENTITY nodes they manage, matched by naming convention (e.g. `UserRepository` → `User`, `OrderDao` → `Order`).

Mirrors src/main/java/io/github/randomcodespace/iq/analyzer/linker/EntityLinker.java (lines 33-98).

func NewEntityLinker

func NewEntityLinker() *EntityLinker

NewEntityLinker returns a stateless linker.

func (l *EntityLinker) Link(nodes []*model.CodeNode, edges []*model.CodeEdge) Result

Link iterates repositories and matches them to entities by simple-name (case-insensitive) after stripping the longest recognised suffix. Skips repositories that already have an outbound QUERIES edge to the candidate entity to avoid duplicates with what detectors emitted.

type Linker

type Linker interface {
	Link(nodes []*model.CodeNode, edges []*model.CodeEdge) Result
}

Linker mirrors the Java Linker interface. Implementations MUST be deterministic — same input slices in must produce identical output every time (sort any map iteration before emitting).

type ModuleContainmentLinker

type ModuleContainmentLinker struct{}

ModuleContainmentLinker groups nodes by their Module field and emits MODULE nodes plus CONTAINS edges pointing at each member.

Mirrors src/main/java/io/github/randomcodespace/iq/analyzer/linker/ModuleContainmentLinker.java (lines 30-97). MODULE-kind nodes are excluded from membership grouping so a module never contains itself; duplicate CONTAINS edges are suppressed.

func NewModuleContainmentLinker

func NewModuleContainmentLinker() *ModuleContainmentLinker

NewModuleContainmentLinker returns a stateless linker.

func (l *ModuleContainmentLinker) Link(nodes []*model.CodeNode, edges []*model.CodeEdge) Result

Link emits the new MODULE nodes and CONTAINS edges. Modules iterate in alphabetical order; members within a module iterate in ID order — making the output stable across runs.

type Result

type Result struct {
	Nodes []*model.CodeNode
	Edges []*model.CodeEdge
}

Result is the bag of new nodes + edges a linker contributes.

func (Result) Sorted

func (r Result) Sorted() Result

Sorted returns r with Nodes and Edges sorted by ID. Plan §1.4 — a defensive wrapper applied at the linker boundary so a future linker change can't re-introduce drift even if its internal map-iteration order shifts.

type TopicLinker

type TopicLinker struct{}

TopicLinker pairs messaging producers with consumers that share a topic/queue/event/message-queue node, emitting direct CALLS edges.

Mirrors src/main/java/io/github/randomcodespace/iq/analyzer/linker/TopicLinker.java (lines 34-115). Supports Kafka, RabbitMQ, TIBCO EMS, IBM MQ, Azure Service Bus, Spring application events, and other enterprise messaging patterns.

func NewTopicLinker

func NewTopicLinker() *TopicLinker

NewTopicLinker returns a stateless linker.

func (l *TopicLinker) Link(nodes []*model.CodeNode, edges []*model.CodeEdge) Result

Link scans nodes for topic-like kinds and edges for producer/consumer kinds, then emits a CALLS edge from each producer to each non-self consumer that share a topic label.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL