scipgraph

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scipgraph parses SCIP indexes into storage rows.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrForbidden      = errors.New("forbidden")
	ErrInvalidRequest = errors.New("invalid_request")
	ErrNotIndexed     = errors.New("not_indexed")
	ErrIndexPending   = errors.New("index_pending")
	// Navigate used to collapse all four conditions below into ErrNotIndexed, which
	// reported a healthy, search-indexed repository as unindexed. They are distinct
	// causes with distinct operator remedies, so they get distinct sentinels.
	ErrStaleCommit     = errors.New("stale_commit")
	ErrSCIPUnavailable = errors.New("scip_unavailable")
	ErrSCIPStale       = errors.New("scip_stale")
	ErrSymbolNotFound  = errors.New("symbol_not_found")
)
View Source
var (
	ErrOccurrenceNotFound = errors.New("SCIP occurrence not found")
	ErrStaleIndex         = errors.New("stale SCIP index")
)
View Source
var ErrInvalidIndex = errors.New("invalid SCIP index")

Functions

func VersionlessSymbolKey

func VersionlessSymbolKey(symbol string) ([]byte, error)

Types

type Definitions added in v0.10.0

type Definitions map[string][]Occurrence

Definitions indexes, per document, the non-local definition occurrences that carry an enclosing range, so a reference can be attributed to the declaration whose body contains it.

func (Definitions) Enclosing added in v0.10.0

func (definitions Definitions) Enclosing(occurrence Occurrence) (Occurrence, bool)

Enclosing returns the innermost definition whose enclosing range contains the occurrence, in the same document. A definition does not enclose its own name token.

type DependencyReader

type DependencyReader interface {
	DependencySBOM(context.Context, int64, string, string) (githubapp.SBOM, bool, error)
}

type Document added in v0.10.0

type Document struct {
	Path, Language   string
	PositionEncoding int32
}

Document is one indexed source file in index order.

type Location

type Location struct {
	RepositoryID                                     int64
	RepositoryName, WebURL, Commit, Path, Symbol     string
	StartLine, StartCharacter, EndLine, EndCharacter int32
	PositionEncoding                                 int32
	Roles                                            int32
	Approximate                                      bool
}

type Occurrence

type Occurrence struct {
	Path, Symbol                                     string
	StartLine, StartCharacter, EndLine, EndCharacter int32
	PositionEncoding                                 int32
	Roles                                            int32
	Local                                            bool
	// Enclosing is the producer's enclosing_range of a definition: the whole
	// declaration, not just its name token. Nil when the producer omits it.
	Enclosing *Range
}

func (Occurrence) Definition added in v0.10.0

func (occurrence Occurrence) Definition() bool

Definition reports whether the occurrence carries the definition role.

type OccurrencePosition

type OccurrencePosition struct {
	UTF8, UTF16, UTF32 int
}

type Package

type Package struct {
	PURL, Manager, Name, Version string
}

func ParsePackageURL

func ParsePackageURL(value string) (Package, error)

type PackageMapping

type PackageMapping struct {
	Package  Package
	Relation string
	Source   string
}

type Range added in v0.10.0

type Range struct {
	StartLine, StartCharacter, EndLine, EndCharacter int32
}

Range is a zero-based source extent in the document's position encoding.

type Relationship

type Relationship struct {
	Path                                                  string
	Source, Target                                        string
	Definition, Reference, Implementation, TypeDefinition bool
}

type Service

type Service struct {
	Store      ServiceStore
	GitHub     DependencyReader
	MaxResults int
}

func (*Service) Navigate

func (service *Service) Navigate(ctx context.Context, principal authn.Principal, request api.SCIPNavigationRequest) (api.SCIPNavigationResponse, error)

func (*Service) RefreshGitHubDependencies

func (service *Service) RefreshGitHubDependencies(ctx context.Context, principal authn.Principal, repositoryID int64) (api.DependencyRefreshResponse, error)

func (*Service) SetDependencies

func (service *Service) SetDependencies(ctx context.Context, principal authn.Principal, repositoryID int64, purls api.RepositoryPackages) error

func (*Service) Upload

func (service *Service) Upload(ctx context.Context, principal authn.Principal, repositoryID int64, commit string, data []byte) error

func (*Service) ValidateUpload

func (service *Service) ValidateUpload(ctx context.Context, principal authn.Principal, repositoryID int64, commit string) error

type ServiceStore

type ServiceStore interface {
	AuthorizedRepository(context.Context, int64, []int64, int64) (repository.Repository, error)
	AnyAuthorizedRepository(context.Context, int64) (repository.Repository, error)
	ReplaceSCIP(context.Context, int64, string, Upload) error
	OccurrenceAt(context.Context, int64, string, string, int, OccurrencePosition) (StoredOccurrence, error)
	// SCIPIndexCommit reports the commit of the most recent SCIP upload for a
	// repository, or "" when none exists. Consulted only on the error path.
	SCIPIndexCommit(context.Context, int64) (string, error)
	Locations(context.Context, authn.Principal, StoredOccurrence, string, int) ([]Location, bool, error)
	ReplacePackages(context.Context, int64, string, []PackageMapping) error
}

type StoredOccurrence

type StoredOccurrence struct {
	UploadID, RepositoryID                           int64
	Commit, Path, Symbol                             string
	StartLine, StartCharacter, EndLine, EndCharacter int32
	PositionEncoding                                 int32
	Roles                                            int32
	Local                                            bool
}

type SymbolInformation added in v0.10.0

type SymbolInformation struct {
	Symbol, Kind, DisplayName, Documentation, Signature string
}

SymbolInformation is the producer's description of one symbol: its SCIP kind name, display name, joined documentation and signature text.

type Upload

type Upload struct {
	ProjectRoot, IndexerName, IndexerVersion string
	Documents                                []Document
	Occurrences                              []Occurrence
	Relationships                            []Relationship
	Symbols                                  []SymbolInformation
}

func Parse

func Parse(data []byte) (Upload, error)

func (Upload) Definitions added in v0.10.0

func (upload Upload) Definitions() Definitions

Definitions collects the upload's enclosing-range definitions by document.

Jump to

Keyboard shortcuts

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