refs

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package refs answers "who defines/uses this symbol across the tree" in one call: a deterministic, word-boundary-matched scan (built on the same walker + matcher infrastructure as internal/common/grep) that labels every hit with its enclosing function/type — the def/use fan `sf grep <symbol>` plus opening each caller by hand would otherwise take. Go gets an AST- accurate enclosing label (internal/common/code/gocode); PHP/TS/TSX/Vue reuse internal/codectx's regex heuristics, the same ones `sf grep` uses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommand

func NewCommand() *cobra.Command

NewCommand returns the `sf refs` Cobra command.

func Run

func Run(opts Options, w io.Writer) error

Run executes the scan and renders the result to w.

Types

type Options

type Options struct {
	Symbol     string
	Root       string   // default "."
	Exts       []string // default defaultExts
	IgnoreDirs []string // extra, on top of grep.DefaultIgnoreDirs
	Max        int      // 0 = default 30; <0 = unlimited
	Format     string
}

type Ref

type Ref struct {
	Kind      string `json:"kind"` // "def" | "use"
	File      string `json:"file"`
	Line      int    `json:"line"`
	Col       int    `json:"col"`
	Enclosing string `json:"enclosing,omitempty"`
	Text      string `json:"text"`
}

Ref is one occurrence of Symbol — a definition or a use.

type Result

type Result struct {
	Symbol    string   `json:"symbol"`
	Refs      []Ref    `json:"refs"`
	Defs      int      `json:"defs"`
	Uses      int      `json:"uses"`
	Truncated int      `json:"truncated,omitempty"`
	Skipped   []string `json:"skipped,omitempty"`
}

Result is the whole answer for one symbol. Refs is already capped (defs first, then file, then line); Defs/Uses count the true totals found before capping, and Truncated is how many were dropped.

Jump to

Keyboard shortcuts

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