mirror of
https://github.com/hanzoai/numscript.git
synced 2026-10-30 18:26:57 +00:00
Refactored modules and exposed a public API so that it can be consumed by the ledger
25 lines
538 B
Go
25 lines
538 B
Go
package analysis
|
|
|
|
import "github.com/formancehq/numscript/internal/parser"
|
|
|
|
type GotoDefinitionResult struct {
|
|
Range parser.Range
|
|
}
|
|
|
|
func GotoDefinition(program parser.Program, position parser.Position, checkResult CheckResult) *GotoDefinitionResult {
|
|
hover := HoverOn(program, position)
|
|
|
|
if variableHover, ok := hover.(*VariableHover); ok {
|
|
resolvedVar := checkResult.ResolveVar(variableHover.Node)
|
|
if resolvedVar == nil {
|
|
return nil
|
|
}
|
|
|
|
return &GotoDefinitionResult{
|
|
Range: resolvedVar.Name.Range,
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|