Help us shape the future of Go! Take the 2026 Go Developer Survey

structure

package
v0.0.0-...-c703685 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package structure extracts declarations, lexical tokens, and logical source coordinates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Kind, Name, Receiver, Pointer, ValueType     string
	Line, EndLine, Level, From, NameFrom, NameTo int
	Complete                                     bool
}

Entry is a structural navigation fact. Byte offsets select its declaration and name; line spans are one-based and inclusive.

func (Entry) MarshalJSON

func (e Entry) MarshalJSON() ([]byte, error)

type Lines

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

func (Lines) At

func (l Lines) At(offset int) int

func (Lines) Len

func (l Lines) Len() int

func (Lines) Offset

func (l Lines) Offset(p Position) (int, bool)

func (Lines) Position

func (l Lines) Position(offset int) Position

func (Lines) Row

func (l Lines) Row(n int) (string, bool)

type Position

type Position struct {
	Line      int `json:"line"`
	Character int `json:"character"`
}

Position is a zero-based logical line and UTF-16 code-unit coordinate.

type Source

type Source struct {
	Source  string
	Lines   Lines
	Format  sourcekind.Format
	Entries []Entry
	Tokens  []Token
}

Source is a parsed snapshot. Consumers leave its source facts unchanged.

func Parse

func Parse(ctx context.Context, source string, format sourcekind.Format) (*Source, error)

Parse extracts source facts without opening files or starting resolvers.

func ParseOutline

func ParseOutline(ctx context.Context, source string, format sourcekind.Format) (*Source, error)

ParseOutline extracts structural facts without collecting semantic selector tokens.

type String

type String string

String serializes the otherwise unrepresentable lone-surrogate names accepted by ECMAScript and JSON without corrupting them into replacement text.

func (String) MarshalJSON

func (s String) MarshalJSON() ([]byte, error)

type Token

type Token struct {
	From int
	Text string
}

Jump to

Keyboard shortcuts

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