gitstack

grindlemire/go-tui code browser

533 B Go 19 lines 2026-07-10 · 0592ab2 raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package main

import (
	"path/filepath"

	"github.com/grindlemire/go-tui/internal/tuigen"
)

// loadPackageContext builds a PackageContext from the sibling files of
// inputPath's directory, so generation and analysis can detect user code
// declared outside the .gsx file itself.
func loadPackageContext(inputPath string) *tuigen.PackageContext {
	ctx := tuigen.NewPackageContext()
	self := filepath.Base(inputPath)
	ctx.AddDirectory(filepath.Dir(inputPath), func(filename string) bool {
		return filename == self
	})
	return ctx
}