scipwire

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 4 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 scipwire decodes the subset of the SCIP index format Kivgraph reads from `rust-analyzer scip`.

The schema is pinned: scip.proto of github.com/scip-code/scip v0.9.0, sha256 04cb20f2b8be73f6c0376b5b3e84c3ae20ebaff0ad3d23ba2d16f866b395ed7d. Only the messages and fields listed in this file are read; everything else is skipped by wire type, so a newer indexer that adds fields still decodes.

The decoder is written here rather than taken from the upstream Go bindings because Kivgraph reads six messages out of the schema and the bindings arrive with a formatter, a validator and their dependency trees. The wire format is fixed by protobuf itself, and every field number in this file is taken from the pinned schema.

Index

Constants

View Source
const (
	// RoleDefinition marks the occurrence that defines its symbol.
	RoleDefinition int32 = 0x1
	// RoleImport, RoleWriteAccess and RoleReadAccess are part of the schema
	// and are never set by rust-analyzer. They are named so a reader can
	// tell an absent role from an unknown one.
	RoleImport      int32 = 0x2
	RoleWriteAccess int32 = 0x4
	RoleReadAccess  int32 = 0x8
)

SymbolRole values, from the SymbolRole enum of the pinned schema. Only the roles rust-analyzer emits are named; the field keeps every bit it received.

Variables

View Source
var ErrMalformedIndex = errors.New("malformed SCIP index")

ErrMalformedIndex reports an index this decoder cannot read.

Functions

This section is empty.

Types

type Document

type Document struct {
	RelativePath     string
	Language         string
	PositionEncoding PositionEncoding
	Occurrences      []Occurrence
	Symbols          []SymbolInformation
}

Document is one indexed source file, with paths relative to the project root the indexer was pointed at.

type Index

type Index struct {
	ToolName        string
	ToolVersion     string
	ProjectRoot     string
	TextEncoding    TextEncoding
	Documents       []Document
	ExternalSymbols []SymbolInformation
}

Index is one decoded SCIP document set.

func Decode

func Decode(data []byte) (Index, error)

Decode reads an index. Unknown fields are skipped, malformed ones are refused: a partially read index would be a graph with holes nobody declared.

type Occurrence

type Occurrence struct {
	Symbol string
	Roles  int32
	Range  Range
	// EnclosingRange is the body of the definition this occurrence's symbol
	// has, when the indexer knew one in this same document.
	EnclosingRange Range
}

Occurrence is one span that mentions a symbol. Lines and characters are zero based; a character is a UTF-8 byte offset from the start of its line when the document says so.

func (Occurrence) Definition

func (occurrence Occurrence) Definition() bool

Definition reports whether this occurrence defines its symbol.

type PositionEncoding

type PositionEncoding int32

PositionEncoding is the Document.position_encoding enum.

const (
	PositionUnspecified PositionEncoding = 0
	PositionUTF8        PositionEncoding = 1
	PositionUTF16       PositionEncoding = 2
	PositionUTF32       PositionEncoding = 3
)

type Range

type Range struct {
	StartLine      int32
	StartCharacter int32
	EndLine        int32
	EndCharacter   int32
	Present        bool
}

Range is a half-open span. Present distinguishes an absent range from one that starts at the beginning of a file.

func (Range) Contains

func (span Range) Contains(other Range) bool

Contains reports whether other falls inside this range.

type SymbolInformation

type SymbolInformation struct {
	Symbol string
	// Kind is the SymbolInformation.Kind enum value. It is kept as the
	// number the indexer sent: the vocabulary is large and grows, and the
	// reader that needs a name owns the mapping.
	Kind            int32
	DisplayName     string
	Signature       string
	EnclosingSymbol string
	Documentation   []string
}

SymbolInformation is what the indexer knows about one symbol.

type TextEncoding

type TextEncoding int32

TextEncoding is the Metadata.text_document_encoding enum.

const (
	EncodingUnspecified TextEncoding = 0
	EncodingUTF8        TextEncoding = 1
	EncodingUTF16       TextEncoding = 2
)

Jump to

Keyboard shortcuts

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