parse

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 19 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 parse turns source files into symbols and unresolved references.

Two boundaries define this package:

  • It never touches the database, the filesystem, or the network. It takes bytes and returns facts. That makes it trivially testable and safe to run across many goroutines.

  • It does NOT resolve references. Tree-sitter produces a syntax tree per file; it cannot tell you that `svc.updateStatus()` binds to `com.pay.TransactionService#updateStatus`. Parsing emits Reference values carrying the raw name and position, and the resolve layer binds them to symbols with a confidence level. Conflating the two would let syntactic guesses masquerade as resolved facts.

Index

Constants

View Source
const (
	// CMakeModule: Path names a module (`Foo` for Foo.cmake) and not a file.
	CMakeModule = "module"
	// CMakeIncludeEnd: Path names a file by its end, because the directory it was
	// written under is a variable the code does not define.
	CMakeIncludeEnd = "include-end"
)

The directives of a CMake import row (lang_modules.go has the others, and ModuleInclude is a file at its exact repository path).

View Source
const (
	ElixirAliasPrefix  = "alias:"
	ElixirImportAlias  = "import"
	ElixirImportPrefix = "import:"
	ElixirUseAlias     = "use"
)

The import rows of an Elixir file are directives, and a module is named by what it is called and not by where it is, so the rows carry the module name in Path and the directive in Alias:

alias Shop.Money                 Path Shop.Money, Alias alias:Money
alias Shop.Billing.Invoice, as: Inv        ... Alias alias:Inv
alias Shop.{Tax, Order}          one row each: Shop.Tax and Shop.Order
import Shop.Util                 Path Shop.Util, Alias import
import Shop.Fmt, only: [fmt: 1]  Path Shop.Fmt, Alias import:fmt
use Shop.Worker, retries: 3      Path Shop.Worker, Alias use
require Shop.Mod, as: M          like alias: it names M

A plain `require` names no function and no alias and is not a row. A module named by an Erlang atom (`:crypto`) or relative to the module it is written in (`__MODULE__.Sub`) is not one either.

The prefixes are read by the resolver (internal/resolve/infer/elixir.go).

View Source
const (
	FortranInterfaceSegment = "<interface>"

	// FortranPrivateSegment follows a module's name in the owner of a procedure the
	// module does not export: `private` by default, or named in a `private ::`
	// statement. A `use` of the module does not bring it in; the module's own code
	// still calls it.
	FortranPrivateSegment = "<private>"
)

FortranInterfaceSegment and fortranLocalsSegment are the owners of a procedure declared in an interface block (an external or a dummy procedure's interface, which declares a procedure and does not define one) and of an internal procedure (one after the `contains` of another procedure). Neither can be named by a `use`.

View Source
const (
	ModuleAliasPrefix        = "alias:"
	ModuleImportAll          = "import"
	ModuleImportPrefix       = "import:"
	ModuleParent             = "parent"
	ModuleHidingPrefix       = "hiding:"
	ModuleShowPrefix         = "show:"
	ModuleInclude            = "include"
	ModuleExport             = "export"
	ModuleDirectiveSeparator = ";"
)

Erlang, Clojure and Julia reach a function through the MODULE it is in, named by what it is called and not by where it is kept: `money:zero()`, `(d/total ...)` after `[shop.data :as d]`, `Money.zero()` after `using .Money`. Their import rows therefore carry the module name in Path and what the directive does with it in Alias, the way Elixir's do (lang_elixir.go), and the resolver (internal/resolve/infer/modules.go) reads the two.

A directive can say several things about one module at once (`[a.b :as b :refer [f]]` binds a qualifier AND brings a name in), and a file can name one module in several directives, so Alias is a list of directives joined with ModuleDirectiveSeparator, and these languages keep a row per distinct Alias (see keepsEveryDirective).

alias:b        the qualifier `b` names the module
import         every function of the module is in scope under its own name
import:f,g/2   only the listed names are (Erlang writes the arity: g/2)
parent         Path names a package this one inherits from (Perl's
               `use parent` and `use base`)
hiding:f,g     every function of the module EXCEPT the listed (Haskell's
               `import A hiding (f)`)
show:f,g       only the listed names of the library (Dart's `show`)
include        Path names a FILE whose definitions join this file's module
               (Julia's include, Dart's `part`)
export         Path names a library this file re-exports: whoever imports
               this file reaches its names too (Dart's `export`)

The prefixes are read by the resolver; keep the two in step.

View Source
const ActiveBackendName = "purego"

ActiveBackendName is the runtime this binary parses with.

View Source
const DefaultMaxSourceBytes = 2 << 20

DefaultMaxSourceBytes is the largest file handed to a parser, and the largest whose text is indexed for search. It equals fs.DefaultMaxFileSize, so there is one size limit and not two.

A 256 KiB limit, chosen when a megabyte of source cost several hundred megabytes of parser arena, would silently drop the centre of real programs: in redis, server.c, server.h, module.c, redis-cli.c, t_stream.c, t_hash.c and cluster_legacy.c are all between 256 KiB and 700 KiB, and all hand-written.

Measured with gotreesitter v0.57.0, one file per process, peak resident memory of the whole process:

  693 KB  C     redis src/module.c         0.3 s   ~130 MB allocated
1,647 KB  C     five redis sources joined  0.9 s    170 MB
2,080 KB  C     module.c three times       0.9 s    298 MB
1,897 KB  C#    a 316 KB test file, x6     4.2 s    269 MB

So a file at the limit costs about 300 MB while it is parsed. The pipeline admits large files against a memory budget (see pipeline.admissionWeight), so that cost is paid for one or two files at a time, not for every worker.

Raise or lower it per repository with index.max_file_bytes in .graphlume.yml. A file over the limit is recorded as skipped with reason too_large, counted, and named by `graphlume index` and `graphlume status`.

View Source
const DefaultParseCeiling = 60 * time.Second

DefaultParseCeiling is the wall-clock time after which a single file's parse is stopped. It is a LAST-RESORT SAFETY NET, not the parse budget.

The budget is work, not time: gotreesitter stops a parse on its own iteration, node, stack-depth and arena-memory limits, every one of which is derived from the source length and counted by the parser. Those give the same verdict for the same bytes on any machine at any load, which is what keeps the index a function of the repository.

A clock cannot do that. A limit of five seconds of wall time would fail the same file on a busy machine and parse it on a quiet one: four redis files, 19 of 43 Newtonsoft.Json files and a 2,945-byte kernel header were measured flipping between runs. So the clock is set far above anything a real parse needs (the slowest file measured, 1.9 MB of C#, takes 4 s) and exists only so that an input the work limits do not catch cannot hold a worker forever. A file it stops is recorded as incomplete and its error text says the limit was the clock, because that verdict, unlike the others, can differ between machines.

What the work limits do not count is time spent inside one parser step. gotreesitter v0.50.1 had such a case: after a file-scope macro call, error recovery in an array initialiser took time that grew sevenfold each time the array doubled, and a 1.6 KB C file took eight seconds while staying far inside every limit. v0.57.0 bounds that path; the ceiling is what remains if another is found.

View Source
const DrainInterval = 128

DrainInterval is how many files an indexing run parses between drains.

A trade-off with no universally right answer: drain too often and every parse re-allocates its arena; drain too rarely and the pool grows without bound. 128 keeps the pool small enough that peak memory tracks concurrency rather than repository size, while amortising re-allocation across enough files that the cost does not show up in wall-clock time.

View Source
const IndirectCallSuffix = ".indirect"

IndirectCallSuffix is appended to the kind of a call whose callee is a local VALUE rather than a name for a definition: `callback()` where `callback` is a parameter, `handler(x)` where `handler` was assigned two lines up.

Such a call is real and its target is unknowable from the source, so the reference is kept — the call site still counts as one — and marked, and the resolver binds it to nothing. Unmarked, it was resolved like any other name: a parameter called `render` bound to whichever `render` the repository happened to define, at whatever confidence that tier reports.

A suffix on the kind rather than a field of its own because the kind is the open vocabulary every consumer already reads by substring ("call"), so the marked reference is still a call wherever calls are counted.

View Source
const MaxSourceBytes = DefaultMaxSourceBytes

MaxSourceBytes is the default limit under an alias, kept because the CGO backend and callers outside this package compile against it.

View Source
const OpaqueReceiver = model.OpaqueReceiver

OpaqueReceiver is the receiver recorded for a call made on an expression the parser cannot reduce to a name: `self.repo.save()`, `make().run()`, `rows[0].close()`.

It exists because an EMPTY receiver was doing two jobs. The receiver query captures only a simple identifier, so `save()` and `self.repo.save()` both arrived with no receiver, and the resolver could not tell a bare name — which can only be something the file defines or imports — from a method called on an object it knows nothing about. A18 in internal/resolve/infer records what reading the one as the other costs. Where this token is written, an empty receiver means the source wrote none.

Not a valid identifier in any language this package parses, so it can never collide with a real receiver, and short enough to fall under every LanguageSpec's MinTypeNameLength.

This walk writes it for Python. shape.go writes the same marker for every other language, and both record beside it the kind of receiver it stands for (model.ReceiverExpr), so the one representation serves all of them.

View Source
const PoolReturnLimit = 128 << 10

PoolReturnLimit is the largest source a parser may have read and still be returned to the pool. See putParser for why.

View Source
const RootedQualifier = `\`

RootedQualifier begins a supertype qualifier that was written with a leading backslash in a PHP file that declares a namespace: it is relative to the global namespace and to no other. internal/resolve/infer reads it.

Variables

View Source
var ErrCGOBackendNotBuilt = errors.New("parse: CGO backend not compiled in; rebuild with -tags cgo_parser")

ErrCGOBackendNotBuilt is returned by CGOBackend in the default build.

A sentinel rather than a panic: `graphlume doctor` reports which backend is compiled in, and asking for a backend that was not built is a fact to report, not a crash.

View Source
var RecoveredPanics atomic.Int64

RecoveredPanics counts how many AST extraction or heuristic panics were safely recovered.

Functions

func ArgCountQuery

func ArgCountQuery(language string) string

ArgCountQuery returns the argument-list query for a language, or "".

func ExtractsDefinitions

func ExtractsDefinitions(language string) bool

ExtractsDefinitions reports whether this build can produce a definition for a language: its grammar has a definition query, or it is a single-file component read through its script block.

A bundled grammar is not the same thing. Most of the grammars the backend carries have no definition query, and a file in one of those languages is indexed for full-text search only (reason text_only). TierFor reports TierParsed for them as well, because a tier says how far resolution goes once definitions exist, not whether extraction starts. Anything that describes language support to a person has to ask this question too; a count of grammars answers a different one.

func HandWrittenLanguages

func HandWrittenLanguages() []string

HandWrittenLanguages lists the languages whose definition query was written by hand and registered, sorted. Each must have a conformance fixture.

func HasMeasuredReceivers

func HasMeasuredReceivers(language string) bool

HasMeasuredReceivers reports whether a language's receiver handling is part of the `typed` tier's claim. See receiverLanguages.

func HasScopeAnalysis

func HasScopeAnalysis(language string) bool

HasScopeAnalysis reports whether the parser walks a language's scopes to state what a query over single nodes cannot: the class a definition belongs to and the class a receiver holds.

Derived from the same switch the parser dispatches on (see genericParser.analyzeScopes), so a language reports it exactly when the walk runs for it.

func ImportQuery

func ImportQuery(language string) string

ImportQuery returns the import-extraction query for a language, or "".

func InheritanceLanguages

func InheritanceLanguages() []string

InheritanceLanguages lists the languages that emit supertype references.

func InheritanceQuery

func InheritanceQuery(language string) string

InheritanceQuery returns the supertype-reference patterns for a language, or "". Appended to the tags query; see newGenericParser for the fallback that keeps a rejected one from costing the language its symbols.

func LanguagesInTier

func LanguagesInTier(t Tier) []string

LanguagesInTier returns the languages at exactly the given tier, sorted.

func ParamCountQuery

func ParamCountQuery(language string) string

ParamCountQuery returns the parameter-list query for a language, or "".

func ReadsImports

func ReadsImports(language string) bool

ReadsImports reports whether the parser reads a language's imports, by an import query or by walking the tree.

func ReleasePooledMemory

func ReleasePooledMemory()

ReleasePooledMemory returns cached parser arenas to the garbage collector.

THIS IS NOT OPTIONAL FOR BATCH INDEXING. gotreesitter pools the arenas it allocates for parse trees, and its own documentation is explicit:

"Arenas held in the pool are strong Go references and are not collected
 by the GC until explicitly drained or the process exits."

Indexing a repository is exactly the batch scan that warning describes. Left undrained, the arena for every file ever parsed stays reachable, so peak memory becomes the sum of every parse rather than the largest few — and a single directory of generated files pins hundreds of megabytes for the life of the process.

Measured on a 2,110-file Go corpus before this call existed: 6.7 GB peak heap with a 2 MiB parse cap, of which the great majority was pooled arenas that no live object referenced.

Safe to call concurrently with active parsing: a pool holds arenas that have been RETURNED, while a parser in progress owns its arena outside the pool. Draining costs the next parse a fresh allocation, which is why callers drain periodically rather than after every file.

func Supplement

func Supplement(language string) string

Supplement returns GraphLume's extra tag patterns for a language, or "".

func SupplementedLanguages

func SupplementedLanguages() []string

SupplementedLanguages lists languages carrying a GraphLume supplement. Used by tests and by `graphlume doctor` to report where coverage is strongest.

func TextOnlyLanguages

func TextOnlyLanguages() []string

TextOnlyLanguages returns the languages whose grammar is bundled but which have no definition query, sorted. Their files are searchable by text and yield no symbols.

func Tiers

func Tiers() map[string]Tier

Tiers reports the tier of every grammar the shipping backend carries.

func TooLargeError

func TooLargeError(size, limit int64) string

TooLargeError is the files.parse_error text for a file of size bytes that is over limit.

Types

type Backend

type Backend interface {
	// Name identifies the runtime in diagnostics and test output, e.g.
	// "purego" or "cgo".
	Name() string

	// Supports reports whether this backend has a grammar for lang. The
	// pure-Go backend covers all 206 embedded grammars; the CGO backend
	// covers only the languages whose grammar packages are compiled in.
	Supports(lang string) bool

	// Languages lists what Supports would accept, sorted.
	Languages() []string

	// Symbols extracts definitions from src. An unsupported language is an
	// error, not an empty result — silently returning nothing would let a
	// missing grammar look like an empty file.
	Symbols(ctx context.Context, lang string, src []byte) ([]TaggedSymbol, error)
}

Backend is a parser runtime capable of extracting symbols.

Implementations must be safe for concurrent use, and must never panic: both runtimes are handed source from repositories GraphLume did not write, so a hostile file has to degrade to an error for that file alone.

func ActiveBackend

func ActiveBackend() Backend

ActiveBackend returns the backend this binary was built with.

This is the compile-time swap. Callers get whichever runtime the build selected and never branch on it, so no code path can accidentally depend on one particular tree-sitter implementation.

func CGOBackend

func CGOBackend() (Backend, error)

CGOBackend returns the official C tree-sitter runtime, or an error when it was not compiled in.

func PureGoBackend

func PureGoBackend() Backend

PureGoBackend returns the gotreesitter-backed runtime. Always available: the module is a plain Go dependency, so there is no build tag guarding it and the differential test can reach it from either build.

type Drainable

type Drainable interface{ DrainPools() }

Drainable is implemented by registries that can release pooled memory. The pipeline uses it to keep peak memory a function of concurrency rather than repository size.

type Import

type Import struct {
	// Path is the module/package as written, e.g. "com.pay.repository" or
	// "./messaging-service".
	Path string

	// Alias is the local binding, when the language supports renaming.
	Alias string

	// Directive is the keyword that introduced the row when the import query
	// captured one (@directive): Dart's `export` and `part`, which name a file
	// and are not imports of it. A language's import fix reads it and turns it
	// into what the row stores; it is never persisted itself.
	Directive string

	// Clause is the text of the whole statement when the import query captured
	// it (@clause): Dart's `show` and `hide` combinators are read from it. A
	// language's import fix reads it; it is never persisted itself.
	Clause string

	Range model.Range
}

Import is a dependency declared by a file. The resolver uses these to narrow candidate targets, which is what separates a high-confidence binding from a bare name match.

type Parser

type Parser interface {
	// Language is the canonical language name, matching the grammar registry.
	Language() string

	// Parse extracts facts from src. It must honour ctx cancellation, and it
	// must never panic: a malformed or hostile file has to degrade to
	// StatusFailed for that file alone. Spec §13 requires parser failures to
	// be isolated to the affected file.
	Parse(ctx context.Context, path string, src []byte) (*Result, error)
}

Parser extracts facts from one language's source.

Implementations must be safe for concurrent use by multiple goroutines. The underlying tree-sitter parser is NOT concurrency-safe, so implementations are responsible for pooling or per-goroutine state.

type ParserOption

type ParserOption func(*parserConfig)

ParserOption configures a parser.

func WithIterationLimit

func WithIterationLimit(n int) ParserOption

WithIterationLimit replaces the parser's iteration limit, which is otherwise derived from the source length (30 iterations per byte, 10,000 at least).

The limit counts parser steps, so the verdict it gives is the same on every machine. It exists for tests, which need a small file to exceed its budget on purpose, and for an operator who wants a tighter deterministic bound than the library's.

func WithMaxSourceBytes

func WithMaxSourceBytes(n int) ParserOption

WithMaxSourceBytes overrides the size limit. A value <= 0 restores the default rather than disabling the limit.

func WithParseCeiling

func WithParseCeiling(d time.Duration) ParserOption

WithParseCeiling overrides the wall-clock safety net. A value <= 0 restores the default rather than removing the ceiling: an unbounded parse is the failure this option exists beside.

type Reference

type Reference struct {
	// Name is the identifier as written, e.g. "updateStatus".
	Name string

	// Kind mirrors tree-sitter tag kinds, e.g. "reference.call".
	Kind string

	// Receiver is the qualifying expression when the syntax exposes one, e.g.
	// "transactionService" in transactionService.updateStatus(). Empty when
	// unqualified. The resolver uses it to infer a target type.
	Receiver string

	// ReceiverKind says what Receiver is — nothing (a bare call), a name, a
	// path, the enclosing instance, the superclass, a stated type, a local
	// value, or an expression with no name. One of the model.Receiver*
	// constants for every call reference; empty for a reference that is not a
	// call. An empty Receiver therefore means "the source wrote none" only
	// when ReceiverKind is model.ReceiverBare — the distinction A18 in
	// internal/resolve/infer needed.
	ReceiverKind string

	// ArgCount is how many arguments this call site passes, where the parser
	// could determine that. model.ArityUnknown for every reference that is not
	// a call, for a call spreading a slice or a sequence, and for every
	// language with no argument query.
	//
	// Unknown is the default and it means exactly that. A18 is the reason the
	// type carries the distinction rather than using 0: an empty Receiver was
	// read as "the source wrote no receiver" when it meant "the query could not
	// express one", and every chained Go call broke. A count of zero and no
	// count are the same failure one field over.
	ArgCount model.Arity

	// Value is, for a call made on a local variable the source declares
	// without a type, the start of the call whose result initialised the
	// variable: the Range.Start of that call's own Reference in this file.
	// Zero when the variable was not initialised by one plain call. The
	// resolver binds that call and reads the return type of what it reaches.
	// See returnedValue in shape.go.
	Value model.Position

	// Reassigns is true when that call is the whole right side of an
	// assignment back to the variable it is called on (`x = x.f(a)`). The
	// resolver keeps the variable's producer only if f returns the type the
	// producer's result has. Migration 0001.
	Reassigns bool
	// Block is true for a call that passes a block: Ruby's `patch do ... end`
	// and `each { ... }`. Read for Ruby only; false everywhere else means
	// "not read". See migration 0001.
	Block bool

	Range model.Range
}

Reference is a use of a name that has not yet been bound to a definition.

It deliberately carries no target. Binding happens in the resolve layer, which attaches a confidence level; a Reference is raw evidence, not a fact about the graph.

type Registry

type Registry interface {
	// ForFile returns a parser for path, or nil when no grammar applies.
	//
	// It decides from the file NAME alone, and a name is not enough for an
	// extension several languages share: `.m` is MATLAB or Objective-C, `.h`
	// is C or C++. A caller that has the file's content detects the language
	// first (fs.Walker does, for every file it discovers) and asks ForLanguage.
	ForFile(path string) Parser

	// ForLanguage returns the parser for a grammar by name, or nil when the
	// name is empty or no grammar has it.
	ForLanguage(language string) Parser

	// Languages lists every language the registry can handle.
	Languages() []string
}

Registry resolves a file to the parser that should handle it.

func NewRegistry

func NewRegistry(opts ...ParserOption) Registry

NewRegistry builds a Registry covering every embedded grammar.

Grammars are loaded lazily: decompressing 206 parse tables up front would cost far more memory and startup time than a typical repository needs, since most repos use a handful of languages.

type Result

type Result struct {
	Language   string
	Status     Status
	Symbols    []model.Symbol
	References []Reference
	Imports    []Import

	// Reason is why Status is not StatusOK, as a stable token.
	// model.ParseReasonNone for a clean parse.
	Reason model.ParseReason

	// ErrorNodes and MissingTokens count what the parser reported when
	// Reason is model.ParseReasonSyntaxErrors: ERROR nodes (text it could not
	// fit into the grammar) and MISSING nodes (tokens it had to invent to
	// continue). FirstErrorLine is the 1-based line of the earliest of them.
	ErrorNodes     int
	MissingTokens  int
	FirstErrorLine int

	// ParsedBytes is how far into the source the parser got when Reason is
	// model.ParseReasonBudgetExceeded. Definitions past it are absent.
	ParsedBytes int

	// Qualifiers counts the tagged identifiers that were dropped because they
	// are the receiver or qualifier of a call, not a call: `reader` in
	// `reader.peek()`. Reported so the drop is counted rather than silent.
	Qualifiers int

	// MacrosMasked is how many unknown-macro tokens were overwritten with
	// spaces before the tree that produced this result was parsed, for a C,
	// C++ or Objective-C file whose masked parse the guard in cmacro.go kept.
	// Zero for every other file, and for every file the plain parse served.
	MacrosMasked int

	// BranchesBlanked is how many conditional-compilation branches (the text
	// after an `#else`, an `#elif`, or an `#if` that was not kept) were
	// overwritten with spaces before the tree that produced this result was
	// parsed, for a C, C++, Objective-C or C# file whose masked parse the
	// guard in cond.go and cmacro.go kept. A definition that exists only in
	// such a branch is not in Symbols. Zero for every other file.
	BranchesBlanked int

	// ConstructsMasked is how many spans of a language's own unreadable
	// construct were overwritten before the tree that produced this result was
	// parsed, for an F# or Groovy file whose masked parse the guard in
	// cmacro.go kept: a statically resolved member constraint call in F#, a
	// one-line doc comment in Groovy. Zero for every other file.
	ConstructsMasked int

	// RecoveredByShape is how many definitions were read by line shape from
	// text the grammar left in ERROR nodes (see fallback.go). Each is a
	// symbol of confidence medium. Zero for every file the grammar read.
	RecoveredByShape int

	// Err explains a status other than ok. Its text starts with Reason, so it
	// can be stored as files.parse_error unchanged. It is diagnostic text for
	// the file's record, never a reason to abort the indexing run.
	Err error
}

Result is everything one file yielded.

func (*Result) TextIndexable

func (r *Result) TextIndexable() bool

TextIndexable reports whether the pipeline should put this file's text in the full-text index.

type Status

type Status string

Status describes what the parser did with a file. It says nothing about what was extracted: a file that parses cleanly and declares nothing is StatusOK, and a file full of definitions the parser stumbled through is StatusPartial.

The values are the ones stored in files.parse_status; see pkg/model/parsestatus.go for the contract and for how old rows read.

const (
	// StatusOK means the parser read the whole file and reported no syntax
	// error.
	StatusOK Status = model.ParseStatusOK

	// StatusPartial means a tree was built but it is not a clean reading of
	// the whole file: the parser reported syntax errors, or the parse stopped
	// before the end because it exceeded its budget. Result.Reason says which,
	// and what was extracted is still usable.
	StatusPartial Status = model.ParseStatusPartial

	// StatusFailed means nothing usable came out. The file is recorded so the
	// gap is visible rather than silently absent.
	StatusFailed Status = model.ParseStatusFailed

	// StatusSkipped means no tree was attempted: the file is oversized or
	// empty, or its grammar has no definition query (Result.Reason is then
	// model.ParseReasonTextOnly and the file is indexed for search alone).
	StatusSkipped Status = model.ParseStatusSkipped
)

type TaggedSymbol

type TaggedSymbol struct {
	Name    string
	Kind    model.EntityKind
	RawKind string
	Range   model.Range
}

TaggedSymbol is one definition a backend found, before GraphLume attaches confidence and provenance.

Kind is the only kind field the two backends are compared on, because it is the only one GraphLume stores. RawKind is diagnostic detail: a backend that still holds the tree-sitter capture name reports it so a failing differential run can say WHY two kinds diverged, but genericParser collapses tag kinds internally and can only reconstruct it, so it is not a comparable field.

type Tier

type Tier int

Tier is how far GraphLume can go on a language. Ordered: higher is more.

const (
	// TierParsed: definitions and full-text search. The grammar exists and
	// the tags query yields symbols. No cross-file relationship is claimed.
	TierParsed Tier = iota

	// TierResolved: TierParsed plus imports, so references can be bound
	// across files and the call graph is meaningful.
	TierResolved

	// TierTyped: TierResolved plus discrimination between candidates of one
	// name — by argument count, or by the class the source states for the
	// receiver — which is what lets a reference reach `high` confidence rather
	// than `medium`.
	TierTyped
)

func TierFor

func TierFor(language string) Tier

TierFor reports the tier for a language name as the backend spells it. Unknown languages report TierParsed, which is the honest floor: if we do not know the language we certainly cannot resolve it.

func (Tier) Description

func (t Tier) Description() string

Description is the one-line explanation printed beside the tier.

func (Tier) String

func (t Tier) String() string

Source Files

Jump to

Keyboard shortcuts

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