Documentation
¶
Overview ¶
Package extract provides AST-based symbol extraction for Go and TypeScript/JavaScript files. It is a port of src/extraction/ from github.com/colbymchenry/codegraph (MIT).
Index ¶
- func DetectLanguage(filePath string) model.Language
- func DetectLanguageContent(path string, content []byte) model.Language
- func DetectSpecScore(filePath string, content []byte) bool
- func ExtractFile(path string, content []byte, lang model.Language) (model.ExtractionResult, error)
- func ExtractGoRoutes(filePath string, content []byte, fileNodeID string) ([]model.Node, []model.UnresolvedReference)
- func IsFileLevelOnly(lang model.Language) bool
- func IsGeneratedFile(filePath string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectLanguage ¶
DetectLanguage returns the model.Language for the given file path, based solely on the file extension. Mirrors EXTENSION_MAP in src/extraction/grammars.ts. File-level-only languages (yaml, twig, properties) return their own Language constant so the indexer records a file row with zero nodes, matching the original's behaviour.
func DetectLanguageContent ¶
DetectLanguageContent returns the model.Language for path, using content to disambiguate ambiguous extensions. For unambiguous extensions it delegates to the path-only DetectLanguage. For `.h` (which DetectLanguage defaults to C for back-compat) it sniffs content: Objective-C markers (`@interface`/`@protocol`/ `@implementation`/`#import`) win first → LangObjC; else C++ markers → LangCPP; else LangC. Callers that have the file content available (the indexer extract path, the parity test) should prefer this over DetectLanguage.
func DetectSpecScore ¶
DetectSpecScore reports whether the file at filePath is a SpecScore artifact: a `.md`/`README.md` file located under a `spec/` path segment whose leading YAML frontmatter (delimited by `---` … `---` at the very top) carries a `format:` key whose value is `https://specscore.md/<kind>-specification`. Only the leading frontmatter block is scanned, not the whole file.
func ExtractFile ¶
ExtractFile parses content as lang, extracts a file node (and, eventually, all symbols), and returns the result. The AST-walking logic for individual symbol kinds will be added in subsequent tasks; this skeleton always succeeds and returns at least the file node.
func ExtractGoRoutes ¶
func ExtractGoRoutes(filePath string, content []byte, fileNodeID string) ([]model.Node, []model.UnresolvedReference)
ExtractGoRoutes extracts net/http HandleFunc/Handle route registrations from Go source, mirroring the goResolver.extract() in src/resolution/frameworks/go.ts.
This is called from ExtractFile after the main tree-sitter walk.
func IsFileLevelOnly ¶
IsFileLevelOnly reports whether lang is tracked at the file-record level only — stored in the files table with zero symbol nodes. Mirrors isFileLevelOnlyLanguage() in src/extraction/grammars.ts.
func IsGeneratedFile ¶
IsGeneratedFile reports whether filePath looks like a tool-generated source file, based on its filename. Path-only — does not read content.
Types ¶
This section is empty.
Source Files
¶
- detect.go
- docstring.go
- extract.go
- walk_bash.go
- walk_c.go
- walk_cpp.go
- walk_csharp.go
- walk_dart.go
- walk_elixir.go
- walk_erlang.go
- walk_fsharp.go
- walk_go.go
- walk_go_fallback.go
- walk_gomod.go
- walk_haskell.go
- walk_java.go
- walk_julia.go
- walk_kotlin.go
- walk_lua.go
- walk_objc.go
- walk_packagejson.go
- walk_perl.go
- walk_php.go
- walk_powershell.go
- walk_python.go
- walk_r.go
- walk_ruby.go
- walk_rust.go
- walk_scala.go
- walk_specscore.go
- walk_sql.go
- walk_sqlite.go
- walk_swift.go
- walk_ts.go