scip

package
v1.37.0 Latest Latest
Warning

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

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

Documentation

Overview

Package scip provides utilities for reading and processing SCIP code intelligence indexes. Import alias: gocodescip "github.com/anatolykoptev/go-code/internal/scip"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheKey

func CacheKey(dir string) string

CacheKey computes a 16-hex-char key from the CONTENT of source files in dir. Hidden files and the .git directory are skipped for speed.

Content-based (not mtime-based) so that git checkout cycles don't cause false cache misses — switching branches back and forth changes mtimes even when file content is byte-identical.

func ConvertToEdges

func ConvertToEdges(idx *Index) []goanalysis.TypedEdge

ConvertToEdges converts a SCIP Index into a slice of TypedEdge call edges. It performs two passes:

  1. Build a definition map (symbol → defInfo) and per-file function ranges.
  2. For each non-definition reference, find the enclosing function and emit an edge.

func IndexerAvailable

func IndexerAvailable(binaryName string) bool

IndexerAvailable reports whether the indexer binary for the given binary name is present in PATH. Callers typically pass cfg.Name from DetectIndexer.

func RunIndexer

func RunIndexer(ctx context.Context, cfg IndexerConfig, dir string) (string, error)

RunIndexer executes the SCIP indexer described by cfg inside dir. It returns the path to the generated index.scip file. stdout and stderr from the subprocess are discarded. Returns an error if the binary is not found or the process exits non-zero.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache stores SCIP index files keyed by a content hash.

func NewCache

func NewCache(dir string) *Cache

NewCache creates a Cache backed by dir, creating it if needed.

func (*Cache) Get

func (c *Cache) Get(key string) (string, bool)

Get returns the path to a cached index.scip file for the given key. Returns ("", false) on a cache miss.

func (*Cache) Put

func (c *Cache) Put(key, indexPath string) error

Put copies the index file at indexPath into the cache under key.

type Index

type Index struct {
	Documents []*sciplib.Document
	Metadata  *sciplib.Metadata
}

Index holds the parsed contents of a SCIP index file.

func ReadIndex

func ReadIndex(path string) (*Index, error)

ReadIndex opens and streams-parses a SCIP index file at the given path. An empty file returns an empty Index without error. A missing file returns a non-nil error.

func (*Index) DocumentCount

func (idx *Index) DocumentCount() int

DocumentCount returns the number of documents in the index.

type IndexResult

type IndexResult struct {
	IndexPath string // path to the index.scip file
	Cleanup   func() // removes temp dir if one was created; nil if dir was writable
}

IndexResult holds the path to the generated index and an optional cleanup function.

func RunIndexerSafe

func RunIndexerSafe(ctx context.Context, cfg IndexerConfig, dir string) (*IndexResult, error)

RunIndexerSafe runs the indexer in dir, copying to a temp dir first if dir is read-only. Caller MUST call result.Cleanup() when done with the index.

type IndexerConfig

type IndexerConfig struct {
	Name string   // binary name (e.g. "scip-typescript")
	Args []string // default args to pass after the binary name
}

IndexerConfig describes how to invoke a SCIP indexer for a language.

func DetectIndexer

func DetectIndexer(lang string) (IndexerConfig, bool)

DetectIndexer returns the IndexerConfig for the given language. Returns (IndexerConfig{}, false) for unsupported languages.

Jump to

Keyboard shortcuts

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