a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
25 lines
788 B
Go
25 lines
788 B
Go
package contracts
|
|
|
|
import (
|
|
"github.com/zzet/gortex/internal/parser"
|
|
gosrc "github.com/zzet/gortex/internal/parser/tsitter/golang"
|
|
)
|
|
|
|
// ParseTreeForLang produces a fresh ParseTree for src using the
|
|
// grammar registered for lang. Returns nil if the language doesn't
|
|
// have a grammar Phase 1 supports — currently only "go". Used by the
|
|
// indexer's incremental re-walk path (extractContracts) which doesn't
|
|
// have a tree from the language extractor.
|
|
//
|
|
// The caller must Release() the returned tree when done.
|
|
func ParseTreeForLang(lang string, src []byte) *parser.ParseTree {
|
|
if lang != "go" || len(src) == 0 {
|
|
return nil
|
|
}
|
|
tree, err := parser.ParseFile(src, gosrc.GetLanguage())
|
|
if err != nil || tree == nil {
|
|
return nil
|
|
}
|
|
return parser.NewParseTree(tree, src, "go")
|
|
}
|