parser

package
v0.1.31 Latest Latest
Warning

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

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

Documentation

Overview

Package parser is Atlas's multi-language code parser. It extracts symbols (functions, methods, types, classes, ...), import edges, and — the keystone Atlas adds over the pulse engine it is ported from — symbol-granular CALL edges that name the enclosing (caller) symbol and the callee reference.

Go is parsed with the native go/parser for compiler-grade fidelity; every other supported language (python, javascript, typescript, java, c, cpp) is parsed with tree-sitter.

Ported and adapted from the original parser service:

  • tree_sitter_parser.go (walk*AST / extract*Import)
  • code_intelligence_service.go (parseGoFile, parseGoCallEdges, parseTextCallEdges, parseCodeFile, languageForPath, symbolLeadingComments, symbolBodyExcerpts)

Atlas additions over pulse: stable line-independent NodeID (ComputeNodeID), first-class graph.DependencyEdge call/import edges, doc/signature population.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeNodeID

func ComputeNodeID(repoFullName, path, kind, name, signature string) graph.NodeID

ComputeNodeID derives a content-stable identity for a symbol node. It is the sha256 hex of repoFullName|path|kind|name|signature and — deliberately — does NOT include line numbers, so a symbol keeps the same NodeID across snapshots even when surrounding edits shift its position. This stability is what lets the temporal diff layer compute set differences between snapshots.

func IsDocumentFormat

func IsDocumentFormat(language string) bool

IsDocumentFormat reports whether a language is one of the binary document formats. The index walk uses this to apply a larger size ceiling — these files carry embedded media so they dwarf the source-file cap, yet only their (small) XML text is read.

func LanguageForPath

func LanguageForPath(path string) string

LanguageForPath maps a file path to its parser language, or "" when the extension is not one of the supported tree-sitter / native grammars.

func Supported

func Supported(lang string) bool

Supported reports whether the language has a first-class parser.

Types

type Result

type Result struct {
	Symbols []graph.CodeSymbol
	Edges   []graph.DependencyEdge
	Imports []string
}

Result is the parse output for a single file.

func Parse

func Parse(repoID, repoFullName, filePath, language string, content []byte) (Result, error)

Parse extracts symbols, import edges, and symbol-granular call edges from a single source file. repoFullName feeds the stable NodeID; repoID stamps each symbol's RepoID. SnapshotID is left empty here — the index layer assigns it when persisting (symbols/edges are snapshot-scoped at save time).

Jump to

Keyboard shortcuts

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